Archives For Category 'Programming'Archives For Category 'Programming' Home » Blog » Category » Programming
You are browsing lesterchan.net blog archives page by category 'Programming'.
Friday, 16th September 2011Friday, 16th September 2011
Posted by Lester Chan at 08:42 in Programming

Google+ API is finally released. This initial API release is focused on public data only (it lets you read information that people have shared publicly on Google+).

Google+ API methods are RESTful HTTP requests which return JSON responses and it uses OAuth 2 for secure trusted access to user data.

Here are some sample codes from the Google’s blog post:

GET https://www.googleapis.com/plus/v1/people/108189587050871927619?key=yourAPIKey

And it will return:

{
	"kind": "plus#person",
	"id": "108189587050871927619",
	"displayName": "Chris Chabot",
	"image": {
		"url": "https://lh5.googleusercontent.com/-cQNLOQzkGpE/AAAAAAAAAAI/AAAAAAAAEjo/M9_pXL-ra4Q/photo.jpg"
	},
	"organizations":
	[
		{
			"name": "Google+ Developer Relations",
			"title": "Developer Advocate & Manager",
			"type": "work"
		}
	]
}

Check out the new Google+ Developer Website at developers.google.com/+/ for more information. There are also a few beta libraries already available (.NET, GWT, Java, Objective C, PHP, Python & Ruby) from Google.

Official Site: Google+ Developer Site
Official Blog Post: Getting Started on the Google+ API

Sunday, 17th July 2011Sunday, 17th July 2011
Posted by Lester Chan at 01:37 in Event, Programming

mig33 is about to unveil a new Developer program for developers and brands that want to build social games and apps for her 50 million registered users and thriving virtual economy.


mig33 Developer Program Launch

About mig33 Developer Program

The Developer Program is a joint initiative by our company, and also both East Asian social networking services: Japan’s GREE and China’s Tencent QQ, valued at USD$2.5 billion and $43 billion.

The launching event will be attended by our CEO and co-founder Steven Goh; our Vice President of Business Development Chris Chandler; and Director, Head of International Alliance Division at GREE Daisuke Kobayashi.

Developers and partners alike will gain a better insight into our basic technical architecture, the Developer Program, and the opportunities made available by our partnership with GREE.

Developer Program Launch

Date: 20th July 2011
Venue: Chijmes Hall, 30 Victoria Street, Singapore
Time: 5pm – 8pm

If you are a developer or have interest in apps whether it is business or development related, feel free to drop by.

You can RSVP over at Flickevents.

Looking forward to seeing you guys there!

PS: The Javascript code in the image above is real, try it out and see what is the output. It is written by my senior Software Engineer Timothee.

Copy and paste the code below in Firebug or Chrome Developer Tools:

n=17260027;s='';do{s+=String.fromCharCode((n&63)+50)}while(n>>>=6);s;
Friday, 15th July 2011Friday, 15th July 2011
Posted by Lester Chan at 13:29 in Programming

Just want to share some rsync code snippets that I used to backup my data to either Dropbox or Jungle Disk on my Mac.

I have problems finding/Googling the proper flags to use for rsync for Dropbox and Jungle Disk when I first got started with rsync on the Internet, hopefully this blog post will be useful for someone.

As Dropbox is essentially a folder on your Mac, the rsync flags are pretty straight forward, however the same cannot be said for Jungle Disk as it is using WebDAV and storing the file over at Amazon S3 or Rackspace Cloud Files where file modification times will not be accurate.

  • I am using rsync 3.0.8. You can compile rsync 3.0.8 on your Mac by following this tutorial. You just have to replace 3.0.7 with 3.0.8 in the commands.
  • For Jungle Disk, I am using Rackspace Cloud Files instead of Amazon S3 because Rackspace does not charge for data transfer and hence it will be cheaper.
  • I am doing an rsync from my remote host to my computer and any files not found on my remote host will be deleted on my computer.

 

Dropbox
/usr/local/bin/rsync -avz --delete --log-file='/path/to/Dropbox/logs/rsync/yourdomain.com.txt' --log-file-format='[%o] %f (%l bytes) (Last Modified: %M)' --exclude-from '/path/to/Dropbox/web/exclude_yourdomain.com.txt' -e ssh username@yourdomain.com:/home/username/public_html/ /path/to/Dropbox/web/yourdomain.com/

Rsync Flag Description

  • -a aka –archive is a short hand for -r -l -p -t -g -o -D. Quick way of saying you want recursion and want to preserve almost everything
    • -r aka –recursive Tells rsync to copy directories recursively
    • -l aka –links When symlinks are encountered, recreate the symlink on the destination
    • -p aka –perms Causes the receiving rsync to set the destination permissions to be the same as the source permissions
    • -t aka –times Tells rsync to transfer modification times along with the files and update them on the remote system
    • -g aka –group Causes rsync to set the group of the destination file to be the same as the source file
    • -o aka –owner Causes rsync to set the owner of the destination file to be the same as the source file
    • -D aka –devices –specials Causes rsync to transfer character and block device files to the remote system to recreate these devices as well as special files such as named sockets and fifos
  • -v aka –verbose Increases the amount of information you are given during the transfer
  • -z aka –compress Compresses the file data as it is sent to the destination machine, which reduces the amount of data being transmitted
  • –delete Tells rsync to delete extraneous files from the receiving side (ones that aren’t on the sending side), but only for the directories that are being synchronized
  • –log-file Tells rsync to log what it is doing to a file
  • –log-file-format Specify exactly what per-update logging is put into the file
  • –exclude-from Specifies a file that contains exclude patterns (one per line)
  • -e Specifies the remote shell to use

Layman’s Terms

  • I am logging the rsync operation to the file /path/to/Dropbox/logs/rsync/yourdomain.com.txt with the log format [%o] %f (%l bytes) (Last Modified: %M) which translate to (as an example) 2011/07/14 08:00:00 [755] [recv] path/filename.txt (1024 bytes) (Last Modified: 2011/07/13-01:00:00).
  • I am excluding all files and folders contained in this text file /path/to/Dropbox/web/exclude_yourdomain.com.txt. Each file or folder name you want to exclude should be on a new line in that text file.
  • I am logging into yourdomain.com with the username username via SSH. You will be prompted to key in your password.
  • Once my credentials are verified, I will be transferring all the files and folders in /home/username/public_html/ of the remote host to /path/to/Dropbox/web/yourdomain.com/ in my local computer.

 

Jungle Disk
/usr/local/bin/rsync --verbose --recursive --omit-dir-times --times --inplace --size-only --delete --log-file='/Volumes/webdav/web/logs/yourdomain.com.txt' --log-file-format='[%o] %f (%l bytes) (Last Modified: %M)' --exclude-from '/Volumes/webdav/web/excludes/yourdomain.com.txt' -e ssh username@yourdomain.com:/home/username/public_html/ '/Volumes/webdav/web/yourdomain.com/';

Rsync Flag Description

  • –verbose Increases the amount of information you are given during the transfer
  • –recursive Tells rsync to copy directories recursively
  • –omit-dir-times Tells rsync to omit directories when it is preserving modification times
  • –times Tells rsync to transfer modification times along with the files and update them on the remote system
  • –inplace Changes how rsync transfers a file when its data needs to be updated: instead of the default method of creating a new copy of the file and moving it into place when it is complete, rsync instead writes the updated data directly to the destination file
  • –size-only Modifies rsync’s “quick check” algorithm for finding files that need to be transferred, changing it from the default of transferring files with either a changed size or a changed last-modified time to just looking for files that have changed in size
  • –delete Tells rsync to delete extraneous files from the receiving side (ones that aren’t on the sending side), but only for the directories that are being synchronized
  • –log-file Tells rsync to log what it is doing to a file
  • –log-file-format Specify exactly what per-update logging is put into the file
  • –exclude-from Specifies a file that contains exclude patterns (one per line)
  • -e Specifies the remote shell to use

Layman’s Terms

  • WebDAV folders are mounted to /Volumes/ and assuming you have mounted Jungle Disk WebDAV folder to be called webdav.
  • I am logging the rsync operation to the file /Volumes/webdav/web/logs/yourdomain.com.txt with the log format [%o] %f (%l bytes) (Last Modified: %M) which translate to (as an example) 2011/07/14 08:00:00 [755] [recv] path/filename.txt (1024 bytes) (Last Modified: 2011/07/13-01:00:00).
  • I am excluding all files and folders contained in this text file /Volumes/webdav/web/excludes/yourdomain.com.txt. Each file or folder name you want to exclude should be on a new line in that text file.
  • I am logging into yourdomain.com with the username username via SSH. You will be prompted to key in your password.
  • Once my credentials are verified, I will be transferring all the files and folders in /home/username/public_html/ of the remote host to /Volumes/webdav/web/yourdomain.com/ in my local computer.

Take a look at Rsync Manual Page for more detailed explanations.

I am up for discussions under the comments =)

Wednesday, 19th January 2011Wednesday, 19th January 2011
Posted by Lester Chan at 08:39 in Programming

I think the logo looks pretty nice. I think I will get the t-shirt!


HTML5 Logo

An HTML5 Logo
It stands strong and true, resilient and universal as the markup you write. It shines as bright and as bold as the forward-thinking, dedicated web developers you are. It’s the standard’s standard, a pennant for progress. And it certainly doesn’t use tables for layout.

We present an HTML5 logo.

Official Site: WC3 HTML5 Logo
T-Shirt: HTML 5 Shirt

Saturday, 5th December 2009Saturday, 5th December 2009
Posted by Lester Chan at 13:06 in Programming

Packt Publishing has sent me a complimentary copy of Ext JS 3.0 Cookbook Book which I will be reviewing after I get back from my holidays.

As we all know, the web has always been dominated by either jQuery, scriptaculous and MooTools, just to name a few.

Ext JS is yet another JavaScript library which can be used to build rich internet applications. Check out the samples, I am pretty impressed on what it can do.

Here is a description of the book:

Using Ext JS you can easily build desktop-style interfaces in your web applications. Over 400,000 developers are working smarter with Ext JS and yet most of them fail to exercise all of the features that this powerful JavaScript library has to offer.

Get to grips with all of the features that you would expect with this quick and easy-to-follow Ext JS Cookbook. This book provides clear instructions for getting the most out of Ext JS with and offers many exercises to build impressive rich internet applications. This cookbook shows techniques and “patterns” for building particular interface styles and features in Ext JS. Pick what you want and move ahead.

It teaches you how to use all of the Ext JS widgets and components smartly, through practical examples and exercises. Native and custom layouts, forms, grids, listviews, treeviews, charts, tab panels, menus, toolbars, and many more components are covered in a multitude of examples.The book also looks at best practices on data storage, application architecture, code organization, presenting recipes for improving them—our cookbook provides expert information for people working with Ext JS.


Ext JS 3.0 Cookbook

Page 1 of 212