Here is the necessary sql to create a user and database of the same name. Note to my future self.

CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT USAGE ON * . * TO 'username'@'%' IDENTIFIED BY 'password' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
CREATE DATABASE IF NOT EXISTS `username` ;
GRANT ALL PRIVILEGES ON `username` . * TO 'usernamel'@'%';

Yes, the code is created using phpmyadmin.

The Chopsticks Nemisis

1 Dec 2009 In: Geek, Interesting, Random

It was a good dinner in the company of good friends. Lots of catching up and some alcohol to go along.

A pair of chopsticks

A pair of chopsticks

Till a almost mathematically perfect piece of honeydew was presented on my plate. It was shaped like a pyramid. Not those with a square base that housed mummies. The pyramid shaped honeydew had a triangular base, and almost have three rotational symmetries.

In my right hand I held a pair of chopsticks. Not the perfect or standard method of hold that will make my ancestors proud, but sufficiently good enough to feed myself since chopstick wielding age of 10.

Then it strikes me that a triangular based pyramid could possibly be the only 3D shaped object that a pair of chopsticks cannot effective lift or hold without resorting to piercing damage to the object.

With the honeydew as the only object of interest, I tried to lift it with my chopsticks only for it to slide around the plate.

Mentally I cannot visualize a straight line across a triangular based pyramid where I cannot apply a perpendicular clamping along to offer a good grip and lift it up.

What if it is a square based pyramid? Once can effectively flip it to rest on one of its triangular face and lift it up as an inverted pyramid. I was suppose to be engaging my friends in meaningful conversation, but my mind was much more interested in defining the perfect chopsticks nemesis.

The chopsticks may be a very useful eating utensils. But I am convinced that with one hand and using a pair of chopsticks, it is not possible to lift up a triangular based pyramid shaped object without resorting to piercing damage to the object.

Playing with QR Codes

23 Nov 2009 In: Geek, Interesting

Hello World
The above is the “Hello World” for QR Codes.

QR code (wiki) in short:

A QR Code is a matrix code (or two-dimensional bar code) created by Japanese corporation Denso-Wave in 1994. The “QR” is derived from “Quick Response”, as the creator intended the code to allow its contents to be decoded at high speed.

Come across it while looking up the Google Charts API. And the Google Charts API is kinda cool also.

And since I am at it, we have:
hackerspace.sg
Which is the QR Code for “ hackerspace.sg“.

Note that upper and lower caps matters.

The Blog Post on BarCampSg4

22 Nov 2009 In: Events, Geek, Interesting, Singapore

BarCampSg4 was held on the 21st Nov 2009. It was my second barcamp in as many week, having attended BarCampMelaka just the weekend before. Both Barcamp were enjoyable in the own ways and having presented at both, I believe that giving/sharing a presentation gives you another kind of experience at Barcamps.

BarCampSg4 topic wall early in the morning

BarCampSg4 topic wall early in the morning

The topic I presented was “How to pose like Star” in BarCampMelaka and renamed it as “How to pose as a Korean Start” for the Singapore version. The content that was shared comes directly from asianposes.com. Hence there is no need for myself to upload any presentation to slideshare. Yes, I can be that lazy post-barcamp.

I am not an expert in how the poses came about and was more than happy to share the amusement that I gotten from the site. There are in all (at the last count) 28 poses and the session include myself going over the 28 poses with the participants. It was fortunate that for both sessions, the demographics was rather young, and there was a slightly higher female to male ratio.

The purpose of the presentations were to discussed the rational of doing such poses, and at the same time, entertain both myself and the audience. I see such poses as decorative emoticons. Some emoticons like the smiley are used to portray certain emotion and are pretty straight forward. And there are some emoticons that are more decorated/complicated such may portray the same emotions/feeling, but in a more flamboyant way. Poses too does the same thing.

Poses maybe used in the same manner, to add more fun to photo taking sessions. Cam-whore rejoice!

I will add that as a presenter, I could have unfairingly enjoyed the session more than my audience. As I was running over the different poses, it can be observed from the vantage point of the presenter that some audience are unwittingly/ unknowingly/ unconsciously doing some action to mimic/mirror the poses shown on screen. Some less reserved members of the audience might even do the pose to the amusement of their friends. And yet most will refusing striking a pose for the camera.

Doing a pose for the camera finally

Doing a pose for the camera finally

Beyond the presentation experience, there were several great talks going on. JF of StoryKitchen did one on drawing on “Drawing with both side of the brain” which left me feeling rather inadequate in knowing that I cannot effectively think without words. I asked: “How can you think without words” and the reply I got was: “I cannot answer this for you as that will require me to use my left brain”.

Coleman “I yet to find True Love” Yee did 2 sessions, one on “For smart geeks: How to explain difficult concepts to lesser beings” and the other on “Design Thinking and finding True Love”. He is a great presenter and deliver great content as well. His talk does seems to attract some following. Remember his last one at BarCampSg3.

Adrianna Tan of Popangandhi’s session was packed as well on “How to hack your own travel channel” where she shared good insights on her experience. The take away was: Travel is the common interest of everyone.

Beyond that, 30 odd of us squeezed into a small room to check out Chris Gomez “Why your film sucks” to learn about something on film making. And was informed for the upcoming filmcamp.

And yes, I got my pokem. It is a Mad Killer. And I am willingly to trade for a ninja!

BarCampSg4 was followed by a visit to hackerspace.sg and the place was impressively done.

An angle of the many interesting things in hackerspacesg

An angle of the many interesting things in hackerspacesg

To all who made the BarCampSg4 successful, a big thank you. IDA and Yahoo too.

Django models have a great function get_FOO_display (which is actually _get_FIELD_display) that return the display name of the options that correlate to the stored value of the model.

To explain with an example

For a Charfield Model with the following declaration

textexamplefield = Model.Charfield(
max_length = 1,
choices = EXAMPLE_OPTIONS
)
EXAMPLE_OPTIONS = (
('u','undefined'),
('t','true'),
('f','false')
)

In the above, an instance with value ‘t’ for texamplefield will return true with the call: instance.get_textexamplefield_display.

Now going to another example:

integerexamplefield = Model.IntegerField(
choices = INT_EXAMPLE_OPTIONS
)
INT_EXAMPLE_OPTIONS  = (
('0','Option 0'),
('1','Option 1'),
('2','Option 2')
)

For this example, get_integerexamplefield_display will not work.

But declaring INT_EXAMPLE_OPTIONS as:
INT_EXAMPLE_OPTIONS  = (
(0,'Option 0'),
(1,'Option 1'),
(2,'Option 2')
)

will result in get_integerexample_field working as normal.
Just note the integer and character relation while declaring the options variable.

Beer Servers Anyone?

14 Oct 2009 In: Geek, Interesting

Was doing a traceroute of the new workplace to my servers just to check the network. Gotten this really interesting series of server names.

The screen shot said it all.

Servers named after beer!

Sake, Kirin, Budweiser, Beck.

Beer themed server naming convention. Someone in Singtel is having some fun.

Editorial note: Sake technically is not a beer.

Of Google Chrome Frame

22 Sep 2009 In: Geek, News

Chroium.org announced Google Chrome Frame. It was stated:

Today, we’re releasing an early version of Google Chrome Frame, an open source plug-in that brings HTML5 and other open web technologies to Internet Explorer.
We’re building Google Chrome Frame to help web developers deliver faster, richer applications like Google Wave. Recent JavaScript performance improvements and the emergence of HTML5 have enabled web applications to do things that could previously only be done by desktop software. One challenge developers face in using these new technologies is that they are not yet supported by Internet Explorer. Developers can’t afford to ignore IE — most people use some version of IE — so they end up spending lots of time implementing work-arounds or limiting the functionality of their apps.

It sounds exciting to allow Internet Explorer to run HTML5 and an improvement in Javascript performance. Seems like a great piece of technical engineering.

From a take up rate perspective, there are reservations. As seems in some of the comments, it seems that users who cannot upgrade their browsers does not have the rights to install a plugin as well? I do not have numbers or facts but digg have a blog post on their statistics. Yes their user base maybe tech savvy and hence the numbers slightly biased. But if their tech savvy use, of which 10% cannot help but to use IE6, I have a feeling that the general internet users will have a higher IE6 usage and likewise be unable to upgrade their browsers.

Yes, maybe installing a plugin might be easier or potentially possible from these users point of view. For new machines and those using IE7 and above, it is always a lesser issue for web developers as compared to IE6. Google Chrome Frame does bring HTML5 to IE, but it does not remove the existence of IE6.

It seems that Google Chrome Frame might give some clueless IT manager somewhere the idea that IE6 may have an extended shelf life.

Straits Times Image Caption Fail

10 Sep 2009 In: News, Singapore

From The Straits Times, we have this article on a book for single mums in Singapore. Everything was nice and rosy but the name dropping in the caption for the image… erm, a fail.

ST Image caption Fail. Lim Swee Say Not.

ST Image caption Fail. Lim Swee Say Not.

The person captured in the image is not Lim Swee Say for sure.

Check for Empty Array Element in Python

31 Aug 2009 In: Geek, Python

In PHP, there is the check for empty array elements using the empty() function. In Python there is no such one function and the same can be accomplished by a rather elegant try-catch block:

try:
iso_language_code = tweet['iso_language_code']
except KeyError:
iso_language_code = ‘zz’
try:
    new_var = array_var['element_name']
except KeyError:
    new_var = 'default_value'  # or None

I will say it is neat.

Geek Chat: Of Programming Languages

29 Jul 2009 In: Geek, Startup

Met up with Sau Sheong over coffee during a weekday evening. I have been following him on his blog and twitter since meeting him last year at a Yahoo developers event. Much have changed since then.

Hardware Programming anyone?

Hardware Programming anyone?

It was interesting to know that Sau Sheong is into consulting startup, putting his knowledge and experience into good use.  Generally the chat was causal and revolve around programming.

Of Java, PHP and other programming languages, there is a observation which I made.  Java seems to be made for the mass. Anyone with sufficient programming training can use Java as soon as possible. It makes it accessible for the masses. Something that on its own a beautiful thing.

Yet I hold a personal baised that Java “takes the thinking away” from the developer. When a problem arise, Java coders will search for the library to do the job. It is good or bad? It depends. As a real life working tool, it is a good idea. As a medium of teaching in schools, it is not a good idea as a first language, but generally a better idea as a tool to teach OO.

Java should deserve more social merits than it have. It have been successful in making programming approachable. Many developers who moved from C to C++ to Java will find that Java is breeze to program in. I been to that stage, but started at Pascal prior to C.

But as the developer mature technically, they tend to challenge themselves and question their tools. That is when some purist will comment that Java is a “Lego-ish” language. Taking the thinking away from the developer. Likewise there are another school of thought that since Java is a first language for many, it means that it tend to produce “noob-ish” developers.  Same concept applies to see PHP developers as noobish as most web developers started off with PHP. I am guilty of such thoughts and did question myself after talking to Sau Sheong.

Hacking, in its core is a form of DIY. And in DIY, there is no right or wrong way. It is always my way or your way, but either way, it is the way of DIY. The spirit of DIY is something to be celebrated. The tool is not essential in DIY. It is the user of the tool that matters.

About this blog

ThinkingNectar talks about the interest of Chin Yong, a PHP/Python/Web developer residing in Singapore. Life, society, and codes should entails most of what goes between the ears of this coffee drinker.

What makes you think?


Sponsors