Thursday, October 27, 2011

To iOS or NOT

Last week, I attended a 4-hour seminar/showcase of iOS Application Development at Mint College in Fort Bonifacio. iOS basically is the operating system for iPhone and iPad devices. It integrates closely with Mac and of course Apple.

A few weeks before that, Steve Jobs passed away raising the question: "How will Apple and innovations from it without Steve Jobs?". You can come up with your own view of the matter, but we'll reserve that for some other time.

The market of mobile applications is increasing exponentially. It's just like the days when all companies and establishments wanted to have their own website and website application has been on the same rise. Now, establishments are clamouring for their own mobile application.

Mobile applications are not new to the horizon, even at the consumer level. Back in the early ages of cellphones, applications already exists and most are on the courrier's end. Eventually, they were made to adopt the Internet and made the system port to websites -- e-commerce came to play a great role, online-banking, and the fraud part, also joined the wagon.

When Apple launched its first version of iPad for the tablet framework, suddenly, the landscape of computing started to change. Despite the existence of tablets way before Apple released its own, (hence the legal battle that it is facing on all sort of countries from other players), tablets are not seen as usefull of to be considered consumer-based or business platform.

Apple changed the outlook on tablets down to the consumer level. Application development needs to pursue and grab the opportunities that it presents in almost all industries: Education for the technology-end; business operations; medical practice.... and the list goes on to coin the tag "I have an app for that".

A couple of years back, the challenge to develop for the mobile platform, as suggested by the increasing adoption of devices, came to play a role in the process. I am a web application developer, though I started my programming practice from DOS-based applications, I should be able to bridge any deficiencies or any adjustment for the web. In about a few weeks of searching for faster solution, I cam accross jQueryMobile - a javascript implementation that uses the industry-proven jQuery framework. It was in its Alpha-1 stage back then. Now, it's in RC2 release -- just about to go mainstream.

I was pulled by it. Going through the readings and searching, jQuerymobile pulled them too. The path is, I will not have must adjustment from how I develop my applications using PHP-MySQL-Javascript-CSS-XHTML and others. jQueryMobile provides really beautiful integration for the mobile platform. As part of the challenge, I had developed a mobile version of the school system I am improving. A restaurant/bar menu and ordering system came next. It was easy, you can build an application with database-integration and custom-views in a matter of hours or days, way faster that most available practices at that time.

There's a catch however, as it is web-based, it can only run with a mobile's browser. Well, by right now, most mobile devices comes with an Internet browser. From my tests and with the available devices I can lay hands on, there are browsers that do not interpret javascript and CSS -- you'll be doomed with text-only -- not good.

Development in the native form -- like iOS -- will eliminate such -- but you can only develop for iOS device -- the ones that ONLY come from Apple. I am not liking the way how it can go. Like when I dropped MS VB development -- thinking I'll be stucked developing for windows only. To this day, that had not changed much. I went to open source -- for the web.

The same dilemna approaches me. If I'm going to develop with iOS:

  • I'll get familiar with using Objective-C. (anyone knows who and what else uses Objective-C? I have not gone to knowing this yet)
  • I can build iOS apps definitely
  • Consequently, I may go away from my web-application development and into iOS. Because, they don't mix and match and the tendency is you'll accommodate one for the place of the other.

After drilling further, I came accross Adobe's Flex Builder with PHP(AFBP) -- SWEET!!!!! I can do Flash faster and I can exploit my PHP know-how.

It is SWEET!

Going through a little reading and tutorials, I found out that developing for iOS and Android can just be an option away from distribution. Build on one platform and implement on others. If I go iOS, the app can only work on iOS device. with AFBP, I can leverage to work on Android too..

Further, using PHP on the server-side gives me comfort. I can expand this to use databases -- mySQL is just a script away.

How about other adjustments? Well, I need to learn how to do Flex and Active Scripting -- but that's just part of the tutorials I can go through..

On to the next exercise...

Thursday, October 6, 2011

The Concerned Plumber

Being new at a city, a plumber, who's workplace is around the corner, rented a room at the first floor on a four-storey building. Starting on the next day, he would go out early to catch up his ride to his workplace and from work, he'll dip himself to the lone bed in his room.

One day, he woke up hearing some water dripping just next to his bathroom. We wondered if he left the faucet on the night before. He got up, guided by the familiar sound of the water dripping, led him to see that the water was coming from the ceiling. The problem is just not his own right to fix and do it right. So, he decided to talk to the building owner and suggested that he can take care of it at the expense of the owner or the occupant of the room above his.

The owner agreed and so he finished his work early at his workplace to give himself some time to take a look at the seemingly plumbing problem. He walked-up the stair and find his way to the room in question. He knocked cautiously not wanting to alarm anyone. The door opened to a few months old baby crying to its heart out carried by his mother while asking the stranger what he wants. The plumber obediently went in and calmly expressed his concern about the water leaking through the floor. As busy as the mother trying to ease up the baby crying, she just motioned to the guest to just go ahead and take a look at it himself.

The guest went through a sea-full of different toys and stuff cluttered on the floor and through a separate room leading to the kitchen. To his surprise, there really isn't any plumbing that needs to be done -- the kitchen sink is full of dishes and a few more stuffs and the faucet is left open.

As the concerned and affected plumber, what would be the best way to solve the problem?

Tuesday, September 20, 2011

Chaining scripts with LABjs

This article-guide on the use of LABjs may be simple or complex depending on how you approach.

Simple, if you're starting up or your scripts are located in external files and your chain of scripts are accessible from inside the <head> and are called the same from all over your scripts.

Complex, if you have otherwise and/or script blocks are inserted within or after the page. Changes can be all over.

The comment post of "Kevin Hakanson" provided the more simpler way to approach it, at least on how my projects are made : (script blocks can be anywhere you need them against putting all in one location and manipulating them there --- atomic approach may not always work). The method allows a single $LAB chain accross your pages, even if they are called separately or individually == define the instance of $LAB and use this variable in all independently called script blocks (taking his example):

  var instance = $LAB
.script("framework.js")
.script("myscript.js")
.wait(function(){ myscript.init(); });

instance.wait(function(){
framework.init();
framework.doSomething();
});

As you defined the variable as "instance", you can then call it on the other script blocks as "instance.script().wait()" chain to all script blocks.

Monday, July 25, 2011

MySQL "Push" backup strategy

A "pull" backup strategy can be achieved by a MySQL replication.

Alternatively, a "push" backup strategy can also be achieved through cron or task scheduler with the following 2-step strategy:

1. take a backup of the database

> mysqldump [options] database > backup.sql

2. send or dump the backup to the remote database

> mysql -u<user> -p<password> -h<remotehost> [options] < backup.sql

Note: the second step should have an explicit password, it should not be blank; to avoid prompt.

You can then add this to your cronjob or Task Scheduler (on Windows) to execute at a certain interval and frequency.

Friday, July 22, 2011

Duplicating MySQL table to another table

Method #1: [the better option]

  1. get the creation table information of the table to be duplicated
  2. change the table name
  3. execute the script

Method #2: this will remove the index definitions of the table though. Use:

CREATE TABLE <newtable>  SELECT * FROM <oldtable> WHERE 1 = 0;

the where clause just says you are ONLY copying the structure and not the data.

Method #3: Copy to and from another database

  1. Copy the table to another database[#2]
  2. Rename the table on the other database[#2]
  3. Copy back to the source database[#1]

 

Tuesday, July 19, 2011

Requirement Management in four notes

  • Planning good requirements: "What the heck are we building?"
  • Collaboration and buy-in: "Just approve the scope, already!"
  • Traceability and change management: "Wait, does the dev team know that changed?"
  • Quality assurance: "Hello, did anyone test this thing?"

http://bit.ly/n6cMjM

Friday, July 15, 2011

Scheduled Remote MySQL backup using PHP

There's a nice 10 ways to backup mysql database from here.

There's also the use of MySQL Administrator or MySQL Workbench if both machines are Windows-based.

However, if you have the MySQL remotely and can be on Linux; some are on Windows; on different machines; and you want to grab backup from all of them, this one can be helpful.

On my development desktop, I have PHP and MySQL installed. Though it is not necessary to have these installed, it's rather handy on a development workstation.

1. Copy, paste it to your favorite text editor and save it somewhere as backup.php (or any filename you wish, just make sure it's recognized by PHP). For the sake of this tutorial, I saved it at D:\DBbackup\

<?php
/**
* This should be run on command prompt
* @params
* host
* user
* password
* [db] defaults as {host}
* [port] defaults as 3306
*/
#host,user,password,database,port
$DATABASES = array(
array(
'user' => 'user1'
,'host' => '8.8.8.8.8'
,'password' => 'mypassword'
)
,array(
'user' => 'user2'
,'host' => 'mysql.mysql.com'
,'password' => 'anotherpassword'
,'port' => '6609'
)
,array(
'user' => 'user2'
,'host' => 'host.localdomain.net'
,'password' => 'itspassword'
,'db' => 'mydatabase'
,'port' => '3308'
)
# add as many database connection as needed using the structure above
);
if (defined('STDIN')){ # make sure it's only run on command line interface (CLI)
$start = date('H:i:s');
$date = date('Ymd');
foreach($DATABASES as $instance){
$port = (isset($instance['port']) ? $instance['port'] : '3306');
$db = (isset($instance['db']) ? $instance['db'] : $instance['user']);
exec("mysqldump "
." -h".$instance['host'] #host
." -u".$instance['user'] #user
." -p".$instance['password'] #password
." -P".$port
." --compress" #you may customize the options appropriate to your servers
." --create-options"
." --extended-insert"
." --no-create-db"
." --quote-names"
." --verbose"
." ".$db
." --result-file=".dirname(__FILE__).DIRECTORY_SEPARATOR.$date."-".$db."@".$instance['host'].".sql"
);
}
# you may add other routines here like:
# compress using 7z
exec("echo 'STARTED: ".$start." DONE: ".date('H:i:s')."' > ".$date.".txt"); #keep log
} else{
echo 'This should be run on a command line';
}
?>


2. Test it on your local
a. open a command prompt on d:\dbbackup\ directory
> d:
> cd dbbackup
b. test php [PHPpath]php --info
> C:\PHP\php.exe D:\dbbackup\backup.php
c. it will create *.sql files on d:\dbbackup\ directory for every database you want to backup

3. Add as task to automate execution
a. Open Task Scheduler
b. Add new task that starts a program.
Program to execute: C:\PHP\php.exe
Parameters (or add it to Program to execute depending on your Windows version)
: D:\dbbackup\backup.php
This will basically execute as
C:\PHP\php.exe D:\dbbackup\backup.php
Put the desired frequency and schedule to backup.

The length of time to execute the script will depend on the amount of data and speed of your connection to the server.