Like what I have to say? Subscribe to my blog via RSS or email, and you'll be notified whenever there's a new blog post!
 
Subscribe to Alvin Poh's Blog by RSS reader
Subscribe to Alvin Poh's Blog by Email

Gadgets, Technology, Public speaking and IT from an undergraduate's perspective.

ThinkPad x60s Battery Quirk

I love my Thinkpad x60s for its great durability and performance in a small and lightweight package. It has loads of programs, like its own harddrive protection system, its own wireless manager, encryption manager, computer diagnostics utility, and today, I discovered that it even has its own version of time!

No, I’m not kidding. I’m typing on it now as I’m sitting in this cafe, running on my 4-cell battery. It’s been showing that I have 6 min (5%) remaining left for the past 45 minutes. So either the battery manager is screwed, my battery is screwed, or it has it’s own version of time, where 5 Thinkpad minutes equal 45 normal minutes.

Heh. I get bored at times.

Subscribe to my blog: RSS reader    Email

Adobe Photoshop Text Tool - Paragraph Type and Point Type

I’ve been bugged about how sometimes I get text boxes that are word-wrapped (i.e. I can adjust the size of the box so that the text automatically fits into the textbox area) and text boxes that are free-form, without any boundaries. The problem was, I didn’t know how to switch from one mode to the other. And finally, I found out how.

To adjust the flow of characters within a bounding box is to use the paragraph type mode, and the free-form mode is known as the point type mode. Note though, that when you convert from paragraph type to point type, a carriage return is added at the end of each line of type (with the exception of the last line). Also, all characters that overflow the bounding box are deleted. So to avoid losing text, adjust the bounding box so that all type is visible prior to conversion.

To switch between modes, follow these steps:

  1. Select the type layer in the Layers palette.
  2. Choose Layer > Type > Convert To Point Text, or Layer > Type > Convert To Paragraph Text.

I realised that sometimes you can simply right-click on the text layer and select the option directly from the right-click menu. I say sometimes, because I’ve encountered times where the option goes missing and is replaced by an option to “Convert To Smart Object” (Till now, I have no idea why).

Subscribe to my blog: RSS reader    Email

How To Create a Stored Procedure using C#, SQL Server 2008, Visual Studio 2008

Microsoft’s Visual Studio 2008 is amazing. It truly is an integrated development environment, because EVERYTHING is integrated. I just learnt about stored procedures today and how creating stored procedures is so easy in Visual Studio. Here’s the steps that you need.

  1. In Visual Studio, create a solution if you haven’t, and to that solution, add a project of the type “SQL Server Project”
  2. Next, right click on that project (not the solution) and add an item of the type “Stored Procedure”, and choose “Stored Procedure” as the sub-type that we want.
  3. You should see the stored procedure added to your project as a file. I’m using C#, so it’s added as a new C# file, with some template code added already.
  4. Try adding this code chunk:

    SqlPipe p = SqlContext.Pipe;
    p.Send(”Hello!”);

  5. Now we can test out our new stored procedure by right-clicking on the project and selecting “Deploy”. This will create a DLL file and copy it over the SQL Server.
  6. Open up SQL Server Management Studio and click on the button titled “Create a New Query’. You should see a screen pop up on the right.
  7. Enter this code:

    USE [YourDatabaseName]
    GO
    EXEC [dbo].[WhatYouNamedYourStoredProcedure]
    GO

  8. Now right-click in that code space and select “Execute”. If you experience this error: “Execution of user code in the .NET Framework is disabled. Enable “clr enabled” configuration option”, then execute the following query first:

    sp_configure ‘clr enabled’, 1
    go
    reconfigure
    go

  9. You should see the text “Hello!” appearing in your output window :)
  10. To do something that’s actually useful, we can add in the following code to our stored procedure, which essentially selects all records in our database and outputs them:

    SqlConnection conn = new SqlConnection(”Context Connection=true”);
    SqlCommand cmd = new SqlCommand(@”SELECT * FROM YourTable”, conn);

    conn.Open();

    SqlDataReader rdr = cmd.ExecuteReader();
    SqlContext.Pipe.Send(rdr);

    rdr.Close();
    conn.Close();

  11. Done! You have just created and run your first stored procedure. Wasn’t that easy?

Subscribe to my blog: RSS reader    Email

What Does Blue Square Icon or Blue E Icon on iPhone Mean?

The iPhone uses a pretty simplified and minimalistic interface which is great 99% of the time, but occasionally it does show some icons that come without labels which I don’t understand.

For instance, I was trying to figure out what a solid blue square in the iPhone’s status bar meant. And sometimes it appears as a capital “E. Well, it turns out that the “E” means that the iPhone is connected to the EDGE network.

The solid blue square indicates that the iPhone can’t find a nearby EDGE network, and is instead connecting via standard GPRS. Generally, GPRS offer slower data transfer rates relative to an EDGE connection. Funny thing is, I seem to get these icons appearing when I’m 100% sure that I’m not connected to EDGE or GPRS.

Update:
To disable GPRS (or disable EDGE), here’s what you need to do:

Jailbroken / Unlocked iPhones
Download and install the Bossprefs application on to your iPhone. it’ll help you manage all your connection settings (which includes GPRS/EDGE)

Un-jailbroken iPhones (Contributed by Lor)
Go Settings > General > Network > Cellular Data Network: Set the APN name to DISABLED (or any other random name). Whenever the iPhone tries to switch to GPRS mode, the connection will be failing (and you will not be charged). Simple is good ;-)

Subscribe to my blog: RSS reader    Email

Zen Stories

I was watching Charlie Wilson’s War when I came to the part where Gust told Charlie the story of the Zen Master. It was something I had heard before, but nevertheless it still aroused my curiousity and led me to search around for Zen stories. Here’s a bunch of interesting ones that I found:

Maybe

There is a Taoist story of an old farmer who had worked his crops for many years. One day his horse ran away. Upon hearing the news, his neighbors came to visit. “Such bad luck,” they said sympathetically. “May be,” the farmer replied. The next morning the horse returned, bringing with it three other wild horses. “How wonderful,” the neighbors exclaimed. “May be,” replied the old man. The following day, his son tried to ride one of the untamed horses, was thrown, and broke his leg. The neighbors again came to offer their sympathy on his misfortune. “May be,” answered the farmer. The day after, military officials came to the village to draft young men into the army. Seeing that the son’s leg was broken, they passed him by. The neighbors congratulated the farmer on how well things had turned out. “May be,” said the farmer.

Working Very Hard

A martial arts student went to his teacher and said earnestly, “I am devoted to studying your martial system. How long will it take me to master it.” The teacher’s reply was casual, “Ten years.” Impatiently, the student answered, “But I want to master it faster than that. I will work very hard. I will practice everyday, ten or more hours a day if I have to. How long will it take then?” The teacher thought for a moment, “20 years.”

Temper

A Zen student came to Bankei and complained: “Master, I have an ungovernable temper. How can I cure it?”

“You have something very strange,” replied Bankei. “Let me see what you have.”

“Just now I cannot show it to you,” replied the other.

“When can you show it to me?” asked Bankei.

“It arises unexpectedly,” replied the student.

“Then,” concluded Bankei, “it must not be your own true nature. If it were, you could show it to me at any time. When you were born you did not have it, and your parents did not give it to you. Think that over.”

Concentration

After winning several archery contests, the young and rather boastful champion challenged a Zen master who was renowned for his skill as an archer. The young man demonstrated remarkable technical proficiency when he hit a distant bull’s eye on his first try, and then split that arrow with his second shot. “There,” he said to the old man, “see if you can match that!” Undisturbed, the master did not draw his bow, but rather motioned for the young archer to follow him up the mountain. Curious about the old fellow’s intentions, the champion followed him high into the mountain until they reached a deep chasm spanned by a rather flimsy and shaky log. Calmly stepping out onto the middle of the unsteady and certainly perilous bridge, the old master picked a far away tree as a target, drew his bow, and fired a clean, direct hit. “Now it is your turn,” he said as he gracefully stepped back onto the safe ground. Staring with terror into the seemingly bottomless and beckoning abyss, the young man could not force himself to step out onto the log, no less shoot at a target. “You have much skill with your bow,” the master said, sensing his challenger’s predicament, “but you have little skill with the mind that lets loose the shot.”

Time to Die

Ikkyu, the Zen master, was very clever even as a boy. His teacher had a precious teacup, a rare antique. Ikkyu happened to break this cup and was greatly perplexed. Hearing the footsteps of his teacher, he held the pieces of the cup behind him. When the master appeared, Ikkyu asked: “Why do people have to die?”

“This is natural,” explained the older man. “Everything has to die and has just so long to live.”

Ikkyu, producing the shattered cup, added: “It was time for your cup to die.”

Empty Your Cup

A university professor went to visit a famous Zen master. While the master quietly served tea, the professor talked about Zen. The master poured the visitor’s cup to the brim, and then kept pouring. The professor watched the overflowing cup until he could no longer restrain himself. “It’s overfull! No more will go in!” the professor blurted. “You are like this cup,” the master replied, “How can I show you Zen unless you first empty your cup.”

Real Prosperity

A rich man asked Sengai to write something for the continued prosperity of his family so that it might be treasured from generation to generation.

Sengai obtained a large sheet of paper and wrote: “Father dies, son dies, grandson dies.”

The rich man became angry. “I asked you to write something for the happiness of my family! Why do you make such a joke of this?”

“No joke is intended,” explained Sengai. “If before you yourself die your son should die, this would grieve you greatly. If your grandson should pass away before your son, both of you would be broken-hearted. If your family, generation after generation, passes away in the order I have named, it will be the natural course of life. I call this real prosperity.”

It Will Pass

A student went to his meditation teacher and said, “My meditation is horrible! I feel so distracted, or my legs ache, or I’m constantly falling asleep. It’s just horrible!”

“It will pass,” the teacher said matter-of-factly.

A week later, the student came back to his teacher. “My meditation is wonderful! I feel so aware, so peaceful, so alive! It’s just wonderful!’

“It will pass,” the teacher replied matter-of-factly.

Happy Chinaman

Anyone walking about Chinatowns in America will observe statues of a stout fellow carrying a linen sack. Chinese merchants call him Happy Chinaman or Laughing Buddha.

This Hotei lived in the T’ang dynasty. He had no desire to call himself a Zen master or to gather many disciples about him. Instead he walked the streets with a big sack into which he put gifts of fruit, candy or doughnuts. These he would give to children who gathered around him in play. He established a kindergarten of the streets.

Whenever he met a Zen devotee he would extend his hand and say: “Give me one penny.” And if anyone asked him to return to a temple to teach others, again he would reply: “Give me one penny.”

Once as he was about his play-work another Zen master happened along and inquired: “What is the significance of Zen?”
Hotei immediately plopped his sack down on the ground in silent answer.

“Then,” asked the other, “what is the actualization of Zen?”

At once Hotei swung the sack over his shoulder and continued on his way.

Subscribe to my blog: RSS reader    Email