Tuesday, January 27, 2009

Plugin to Bookmark a Page in Your PDF files

Books in PDF formats are very popular nowadays. But annoying thing is that the Adobe Reader which is the standard PDF reader at work doesn't come with a bookmark functionality. I just need a simple bookmark like those good old paper bookmarks. Well I found one that does the job, a plugin from this post. Thank you very much.

Friday, January 23, 2009

How to make a quick copy of SQL Server database table

Here's how to create a quick copy of a database table including the data in SQL Server.

select * into [dbo].[TableName_Bak] from [dbo].[TableName]

Wednesday, January 07, 2009

My very first perl6 program

I know, I know, I promised to do some perl6 hacking over the holidays, but as it turned out, I didn't have the time to do it. Having 2 kids in the family and tons of activities lined up over the holidays didn't really gave me much room to doing other things like hacking with my computer. Anyways, another thing I did over the holidays was... tada I got a G1. And I really, really love it! Absolutely amazing piece of work. The downside is, it's going to hurt on our monthly utility bills. So my wife and I were thinking cutting down our cost. We are thinking of giving up our landline, since we both have wireless anyway. But of course wireless minutes aren't cheap either, so we gotta figure out who are actually calling us and who do we call from our landline.

Well, that can be done very easily. Since we are subscribed to comcast, incoming and outgoing phone calls are easily downloadable from their website. And so, this is a good opportunity for me to use the perfect tool for the job. Perl. But this time, I want to use Perl6. And here's what I came up with.

#!/usr/bin/perl6

my %number_of;

my $file = "CallRecords.txt";
if (my $fh = open $file, :r) {
    for =$fh -> $line {
        next if $line !~~ /Answered/ or $line ~~ /Private/;
        my ($name, $phone) = $line.split("\t")<2, 3>;
        %number_of{$name.uc} = $phone;
    }
else {
    say "Could not open $file";
}

for %number_of.sort.kv -> $name, $phone {
    say $name ~ ' ' ~ $phone;
}

Here's the output:

0 ABXXON ROLLY  (408) 386-XXXX
1 AGUXXAR R & J (408) 251-XXXX
2 AGUXXAR RONNIE        (408) 768-XXXX
3 ALMXXEN FAMILY        (408) 997-XXXX
4 XXER FRATERNAL        (408) 984-XXXX
5 AQXXNO GREG   (408) 297-XXXX
6 AQXXNO GREG R (408) 297-XXXX
7 ARGONCXXLO S  (408) 937-XXXX
8 ARGONCXXLO SUSA       (408) 937-XXXX
9 ASXXAS DAISY  (831) 240-XXXX
10 BALIXXIT VENTUR      (408) 251-XXXX
11 XXNK OF AMERICA      (866) 512-XXXX
12 BEXXER LIVING I      (408) 561-XXXX
13 BOUXXER      CO      (303) 786-XXXX
14 CALIFOXXIA EAR       (650) 494-XXXX
15 CAMXXHO GEMMA        (408) 849-XXXX
...

(I replaced some letters and numbers with X's in this post for security purposes.)

Oh my goodness! What an elegant piece of code that is. And it didn't take me a while to figure it out. I simply read tutorials from Gabor and Jonathan. I tell you, I can't believe the expressiveness of the latest and greatest perl. I have barely scratched the surface, it's got tons of other amazing stuffs! Try it for yourself.

Monday, January 05, 2009

Safari Login

My little secret Safari Login. Just for me to see if I can access Safari from my T-Mobile G1 with Google Phone, Black (T-Mobile).

Yey! It's working, now I can read books from my G1.

Sunday, January 04, 2009

Project setup using GitHub

Just taking notes on how to setup project in GitHub. These notes are from GitCasts and GitHub Guides.

1. Setup, Initialization and Cloning

Global setup, these apply to all projects on the system:

git config --global user.name 'User Name'
git config --global user.email username@gmail.com
git config --global color.status auto
git config --global color.branch auto
git config --global core.autocrlf true

To save project in git repository:
1. First, create the project.
2. cd to the project, then do the following:

git init
git add .
git ls-files --cache
git commit -m "Initial Commit"
git status
git log

To clone existing code in the git repo:

git clone git://github.com/sammydc/publictalkscheduler.git

If it's your own repo, use this instead:

git clone git@github.com:sammydc/publictalkscheduler.git 

2. Normal Workflow

Create .gitignore file, this is to specify which files we don't want to add to git, like as follows:

log/*.log
tmp/**/*

Editing files and commiting to repo:

git status
git add [filename]
git commit
OR:
git commit -a -m 'My Next Commit' #automatically add and commit all changed files
git ls-files --stage
git rm public/robots.txt #remove a file, git not to track the file anymore
git status
git commit -m 'robots file removed'

Now push to remote repo:

git remote add origin git@github.com:sammydc/publictalkscheduler.git
git push origin master

Take note that if you get the error message:

fatal: protocol error: expected sha/ref

You need to make sure that .git/config [remote "origin"] url entry is in the form of

git@github.com:sammydc/publictalkscheduler.git

When working on another machine, to get latest changes:

git pull