Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Saturday, October 30, 2010

How to add code post in Blogger

First we have to put this under <head> tag in the Edit HTML of Blogger.

<script language="javascript" src="http://google-
code-prettify.googlecode.com/svn/trunk/src/prettify.js" 
type="text/javascript">
</script>
<link href="http://google-code-prettify.googlecode.com/svn/trunk
/src/prettify.css" rel="stylesheet" 
type="text/css">
</link>

Second, search for <body> tag and put
onload="prettyPrint()"
as attribute.

Finally, when you want to add code post you can write.
<pre class="prettyprint">
......... your code .........
</pre>

p.s. js,stylesheet can be downloaded and upload to somewhere ex. google-site and then change the link to your site.

Fire Drill at ICT [Continue]

At that time, there are 2 main parts: theory and workshop.
In the first part, it is an introduction about how to deal with fire and basic things to do to prevent fire occurring in the buildings. => In this part I came late, when I arrived, there are 5 minutes before took an exam.

So, I knew that they are classified into 4 kinds of objects to be fired as following: A-normal wood, paper and cloth, B-liquid that can be fired and oil, C-gas that can be fired, D-metal chemical substances such as magnesium.

In the second part, I have to practice how to get out of the buildings when fire emergency occurred, and I have to practice to carry injured people out from the buildings too. Finally, we practice to use fire extinguisher. Type A can use water to extinguish a fire. Type B can use dry-chemical, foam. Type C,D can use dry-chemical also.

Finally, on that day is really fun and know a lot of things to do when the buildings are fired :).

Monday, October 25, 2010

Print without a new line or space in Python

Normally, when we use print function in Python, it will automatically put new line at the end of the string. we can't omit it. So, there are 2 solutions as following:

1.
import sys 
sys.stdout.write("Hello")

2.
from __future__ import print_function 
print("Hello",end="")

Normally, end="\n" and print is not a function that means after string it will  be add "\n" at the end. Using __future__ to import print as function.

Now, we can print without a new line.

Saturday, October 23, 2010

How to test if object is sequence, or iterable?

In the java or c# languages, we can found that it is very easy to know that class is a collection by checking the interface Collection. But in python some time it can't check by using isinstance, issubclass methods. So, the solution is we can just used the __iter__ attribute in that object.

Friday, October 22, 2010

How to clear screen in Python Interactive Shell

Most of the time when I deal with interactive mode, there are a lot of lines. , this is a simply solution to solve this problem.
There are 2 methods
1. Short Key: Under Linux/UNIX system (on x86 at least) you can use the CTRL+L
2. Writing a code:

import os
if os.name == "posix":
# Unix/Linux/MacOS/BSD/etc
os.system("clear")
elif os.name in ("nt", "dos", "ce"):
# DOS/Windows
os.system("CLS")
 

Quick open teminal in Ubuntu by using one click

From the last entry, Windows can open command window at the current path in one click. Also, Ubuntu can do that too. The solution is here.
1. Open terminal.
2. Type "sudo apt-get install nautilus-open-terminal"
3. Restart your machine.
4. After that, when you right click at that directory, it will show tab for openning terminal.
5. Click at that tab, the terminal will be shown at the current directory you click.
p.s. Linux Mint can do that without any installation.
For Windows: http://darkkung-blog.blogspot.com/2010/10/open-command-window-at-current-path-in.html
For Mac: http://darkkung-blog.blogspot.com/2011/02/quick-open-terminal-in-mac-by-using-one.html

Open Command Window at the current path in one click

Hi all, do you ever lazy to change current directory in Windows manually? for me, the answer is yes.
Today, I have an very easy solution to make you happy :)

1. Go to the current directory that you want to work on.
2. Hold SHIFT button + Right click.














3. Click at Open command window here.














4. You got it!!!

p.s. Actually, this method can only work on Windows Vista and Windows 7.
For Linux-Ubuntu: http://darkkung-blog.blogspot.com/2010/10/quick-open-teminal-in-ubuntu-by-using.html
For Mac: http://darkkung-blog.blogspot.com/2011/02/quick-open-terminal-in-mac-by-using-one.html

Wednesday, October 20, 2010

Fire Drill at ICT

On 27 Wed Oct 2010, ICT faculty has a training about Fire Fighting!
The schedule is shown as following:

Oct 27, 2010
12.30 - Register IT204
13.00 - 14.30  - Practice to use bucket, fire extinguisher, dry chemical, gas co2.
14.45 - 16.30 - Practice to flee from the building by simulate the event with sign of fire alarm.

On that day, I will write gained experience again.

Monday, October 18, 2010

My first Android game - Pig Hunter

According to one of my class, Wireless class, I have to write mobile application and also select game application. Because of having an Android phone - Sony Ericsson X10, so I will select Android application to write a game application.
The description said that the main character is a pig. Then, Natty, my teammate, will plot the game story that the pig will rule the world by destroying the other races for making the pig planet. So, I have an idea that we can use touch as a gun shot - -" and uses the pictures which can flip between front and back as targets.

Game Screenshots

Finally, I have a sound problem in Android that I can't use SoundPool class to manage multiple sound resources in X10[Android v1.6]. So, the game still has this bug. If someone know how to correct this problem, pls tell me :D

Credit:
Developed by Darkkung & Natty
Art by http://pixmac.com, http://zulva.com
Sfx by http://stonewashed.net


Download game apk:

Sunday, October 17, 2010

Greeting - The first post in my blog

Hi, it is the first time for me to write my own blog. The contents of this blog that I will write are about my journey that may be my life, technology, days experiences, programming, events or exhibitions, my works, and so on...

The main purpose of this blog is to write my own diary which can see it any time any place because I'm easy to forget a lot of things that I ever did -*-

p.s. If I have a time, I will write it as more as possible.