Kok-Yan's profileKok-Yan's blogBlogLists Tools Help
 

Kok-Yan Lo

Kok-Yan's blog

5/22/2009

URI decode script

Ever seen a URI like "http%3a%2f%2fklo-2k.spaces.live.com%2fdefault.aspx"? Wish you can decode it or paste it into your address bar? Well, I've got just the script for you:

#!/bin/bash

param=

# Idea from http://www.linuxquestions.org/questions/linux-software-2/bash-scripting-pipe-input-to-script-vs.-1-570945/#post2998640
if (( $# > 0 )); then
	param=$1	# Read from 1st parameter
else
	param=$(cat)	# Read from pipe
fi

eval "echo $(echo $param|sed -e "s/%\([a-z0-9][a-z0-9]\)/$'\\\x\1'/Ig")"

Call it "uridecode", chmod +x it, then you can do something like:

firefox $(uridecode http%3a%2f%2fklo-2k.spaces.live.com%2fdefault.aspx)

Nice eh!?

5/17/2009

A moving metaphor from "Bones"

Here's a rather moving metaphor from the season 4 finale of "Bones" - "The End In The Beginning":

You love someone, you open yourself up to suffering, that's the sad truth.

Maybe they'll break your heart, maybe you'll break their heart and never be able to look at yourself in the same way. Those are the risks.

You see two people and you think they belong together. But nothing happens. The thought of losing so much control over personal happiness is unbearable.

That's the burden. Like wings, they have weight, we feel that weight on our backs but they are a burden that lifts us. Burdens that allow us to fly...

Wouldn't it be nice if two people can love each other unconditionally in the first place; how there wouldn't be the barrier that erects itself automatically to protect them from any potential hurt, how they can share their thoughts and feelings in complete freedom, without the fear of being judged or misunderstood, for their love for each other is unconditional - kinda like the love God has for us and the freedom we have in our prayers to God.

Yeah, I guess "that's the sad truth" about love between human beings. But still, it's nice to be able to finally confirm that that Brennan really loves Booth, just like in Futurama when we get confirmation that Leela loves Fry.

4/9/2009

Consuming Fire

At St. Alban's yesterday, instead of the normal Bible study, we had a special service praising God, remembering Jesus and praying. During the service, we sung many hymns including my favorite "Amazing Grace", as well as being introduced to a new one.

The new song is called "Consuming Fire" and it was written by Tim Hughes. I have to say, the lyrics are beautiful, check it out:

There must be more than this,
O breath of God come breathe within,
There must be more than this,
Spirit of God we wait for You.

Fill us anew we pray,
Fill us anew we pray.

Consuming fire fan into flame,
A passion for Your Name,
Spirit of God (would you) fall in this place,
Lord have Your way,
Lord have Your way with us.

Come like a rushing wind,
Clothe us with power from on high,
Now set the captives free,
Leave us abandoned to Your praise.

Lord let Your glory fall,
Lord let Your glory fall.

Consuming fire fan into flame,
A passion for Your Name,
Spirit of God (would you) fall in this place,
Lord have Your way,
Lord have Your way...

Consuming fire fan into flame,
A passion for Your Name,
Spirit of God fall in this place,
Lord have Your way,
Lord have Your way with us.

Come like a rushing wind,
Clothe us with power from on high,
Now set the captives free,
Leave us abandoned to Your praise.

Lord let Your glory fall,
Lord let Your glory fall!

Consuming fire fan into flame,
A passion for Your Name,
Spirit of God (would you) fall in this place,
Lord have Your way,
Lord have Your way!

Consuming fire fan into flame,
A passion for Your Name,
Spirit of God (would you) fall in this place,
Lord have Your way,
Lord have Your way with us.

Stir it up in our hearts Lord,
Stir it up in our hearts Lord,
Stir it up in our hearts,
A passion for Your Name!
[Repeat until end]

And here is the song:

 
4/2/2009

St. Alban's Church's new website

St. Alban's logo

For those who don't know, I normally go to church on Sundays and I usually go to St. Alban's for the evening service. Well, St. Alban's had recently updated its website with a whole new look along with a bunch of new and extra stuff like sermon mp3 downloads and blogs by the pastors.

Go check it out for yourself:
http://www.stalbanslindfield.com.au

Oh, and for those of you who would like to subscribe to the pastors' RSS feeds, here is the link:
http://www.stalbanslindfield.com.au/createrssfeed.action?types=blogpost&sort=modified&showContent=true&showDiff=true&title=St+Albans&labelString=&rssType=rss1&maxResults=100&timeSpan=300

3/21/2009

ASP.NET ODBC Oracle error "ORA-01008: not all variables bound" solved

The other day I decided to try my hands on using named parameters in a query to query an Oracle database using ODBC when I got this message:

ERROR [07001] [Microsoft][ODBC driver for Oracle][Oracle]
ORA-01008: not all variables bound

From what I've found, it looks like if you are querying an Oracle database using the System.Data.Odbc class, you can only use unnamed parameters (defined by "?"). In order to use named parameters, you'll need to use the System.Data.OracleClient class instead (note you'll need to add that reference manually to your project).

Here's what I mean:

public DataTable queryDatabase_odbc () {
	OdbcConnection con = new OdbcConnection("Driver={Microsoft ODBC for Oracle};server=DBSERVER;uid=xxUserxx;pwd=xxPwdxx");
	con.Open();
	OdbcCommand ps = new OdbcCommand("alter session set current_schema = xxdbschemaxx", con);
	ps.Prepare();
	ps.ExecuteNonQuery();

	OdbcCommand ps2 = new OdbcCommand("select * from aTable where field = :AParam", con);
	ps2.Prepare();
	ps2.Parameters.Add("AParam",OdbcType.VarChar).Value="Some String Value";
	DataSet rs = new DataSet();
	OdbcDataAdapter da = new OdbcDataAdapter(ps2);
	da.Fill(rs);	// This will throw an exception
	return rs.Tables[0];
}

// The exact same code as above, just using the the OracleClient class
public DataTable queryDatabase_ora () {
	OracleConnection con = new OracleConnection("server=DBSERVER;uid=xxUserxx;pwd=xxPwdxx;");
	con.Open();
	OracleCommand ps = new OracleCommand("alter session set current_schema = xxdbschemaxx", con);
	ps.Prepare();
	ps.ExecuteNonQuery();

	OracleCommand ps2 = new OracleCommand("select * from aTable where field = :AParam", con);
	ps2.Prepare();
	ps2.Parameters.Add("AParam",OracleType.VarChar).Value="Some String Value";
	DataSet rs = new DataSet();
	OracleDataAdapter da = new OracleDataAdapter(ps2);
	da.Fill(rs);
	return rs.Tables[0];
}

However, I do have to point out there is one draw-back with using the OracleClient class - you can no longer use unnamed parameters...

But in a way, you do get more out of using named parameters than unnamed parameters (like when you have a query looking up the same value on multiple fields). Besides, you can always (sort of) hack named parameters to act like unnamed parameters by using an integer string as name...


Here a page I found with details in using parameterized queries in different DBMS:
http://weblogs.asp.net/cibrax/archive/2006/09/28/Parameterized-Queries-_2800_Oracle_2C00_-SQLServer_2C00_-OleDb_2900_.aspx

3/15/2009

Windows Live Hotmail POP3 access

Mail

Woohoo! You can now access your Hotmail account via POP3! Here are the details:

POP server: pop3.live.com:995 with SSL
SMTP Server: smtp.live.com:587 with TLS

Guess I won't need my WebMail Thunderbird Add-on anymore!

3/8/2009

TV Recommendation - Dollhouse

Dollhouse title screen

Here's another TV show I'd recommend - Dollhouse.

The story is based on a private underground organization who engages on mission-based tasks for clients using people called "Active"s, who have had their original personalities and memories wiped clean, and replaced with new ones specifically selected at the start of each mission (or "engagement"). At the end of each engagement, the Active's memories are wiped clean and returned to a child-like state.

The name of the shown comes from the fact that the Actives live inside a house with a controlled environment between engagements during which they are in a child-like state of mind, analogous to Dolls in a Dollhouse.

As the plot develops, the main character "Echo" (played by Eliza Dushku), started to show sings that she may have retained certain character traits of the personas she inherited during her previous engagements. There are of course other interesting twists to do with the ugly history of the organization and the organization's potential (but currently unknown) enemies.

I have no idea how the story is going to unfold, but I sure am looking forward to the next episode!

2/17/2009

Yes! It's now official - Leela loves Fry!

Leela and Fry kissing

Here's the moment all Futurama fans had been waiting for! It's official - Leela loves Fry!

1/27/2009

TV Recommendation - Lie to Me

"Lie to me" title screen

If you like Bones, here's a TV show I'd recommend you checking out - "Lie to Me".

"Lie to Me" presents a fictional story of a crime-fighting psychologist (Dr. Cal Lightman) and his team. The structure of the episode is similar to that of Bones' where they get a case at the beginning, and solves it in the end. The interesting part, for me, is to see how important clues that affects the outcome of a case, can be extracted accurately from the subtle expressions / body language of suspects during interrogations.

1/21/2009

FTP script example

A while back, I was uploading a bunch of stuff via FTP and needed a FTP script to automate things. However, I couldn't find a clear example script out there and this simple script ended up taking quite a bit longer to write.

Anyway, for anyone who's searching out there for a FTP script example, here's something you may appreciate:

#!/bin/bash
#...
# (Other commands in script)
# ...
ftpCmd="open someserverdomain.com 21
user aUser aPassword
passive
bin
cd uploads
mput *
bye
"
echo "$ftpCmd"|ftp -niv

The tricked as you can see is to store the FTP commands into a variable, then echo that to the "ftp" command.

Have fun FTP-ing, lol.