Posts

Showing posts from March, 2012

Function prototyping in Perl

Today, I studied some old codes from year 2003. It has very weird Perl syntax which I have never seen before. I did some testing using the following code. Of course, I did try and error until I got what the $;$ means.

They are actually representing argument that is passing to the subroutine. One $ represent one argument. The ones before ; are required arguments, and the ones after the ; are optional arguments.

My colleague is smarter, she found this link online : http://perldoc.perl.org/perlsub.html#Prototypes. There are a lot more to learn in Perl!



use strict;

use Data::Dumper;
$Data::Dumper::Indent = 3;

sub sub0 () {
  print Dumper(@_);
}

sub subA ($;$) { 
  unshift @_, 'new from a';
  print Dumper(@_);
  goto &sub0;
}

sub subB () {
  subA("a", "b");
  subA("c");
}

subB();

1;

Blogger API - create a new post using JavaScript

I am a heavy Blogger user.I write blogs. I never thought of wanted to know Blogger API, but I do thought of get to know Google API. I am glad that my work gives me an opportunity to explore this, for work and for myself. :) 

I'd like to thank Brett Morgan and also those responded to Issue 42 in gdata-java​script-cli​ent. Without them, I won't be able to complete this piece of code. And also, not forgetting the original source code that provide me the baseline to start to work at available here.

This piece of code will do the Google account authentication and authorization process, it will then grab your blog list, and provide a simple form for you to select a blog, taking your new post entry's title and content, and then post it. I have tested on FF3.2.26, Safari 5, Chrome, and IE8. There'll be some prompts to proceed depends on the browser that you are using.

Some special handlings were happened during my weeks of getting this piece of code in place. I can only recal…

git stash

To save a change without commit. This is to enable checkouts. git stash save "Your comments" To see the list of stashed changes. git stash list To apply the saved change. git stash apply To delete the stashed changes. git stash clear Reference : http://book.git-scm.com/4_stashing.html

Basic commands of git

1. To initialize and setup a git central repository
> git --bare init central_repo

2. To push to central repo from clone
> git push origin master

3. To check available branches
> git branch

4. To create a branch
> git checkout -b <branch name> origin/master
> git checkout -b <branch name> origin/<existing branch name>

5. To reset changes on branch
> git reset --hard <old branch name>


http://help.github.com/git-cheat-sheets/