Make iso from folders, files in Ubuntu

Posted on November 8th, 2008 in Ubuntu | No Comments »

Making iso in ubuntu is fairy easily task to do, here is how i did it.

* Open brasero
* Choose Data project
* Find your files and just press the Add (plus button at the top left corner)
note: you cannot drag and drop
* Then select Burn

If you insert a cd/dvd it will as you for either burning it to your cd/dvd or to an Image File, choose the Image File
If you didn’t insert a cd/dvd, then there is only one option and that is the Image File

* Click burn and it would be at your home folder (Alt+F2 then nautilus)

Then you can save or distribute your iso files.

Limit your internet connection in Windows XP

Posted on November 7th, 2008 in Microsoft, Technology | No Comments »

I barely talk about windows stuffs but this time i have to share to you a wonderful application for developing web sites or flash or silverlight site. The application is call netlimiter, its not a free software so you have to buy the real thing or try it out for a few days. The cool thing about it is that it can limit individual application, this is handy especially in flash where you have to see the loading/progress bar if your loading an external file. Its good to prank your friends within the trial too, hahaha. But anyway go ahead and try it, its really a good software for web developers.

If anyone knows any freeware that do work, please comment below thanks.

Get Total count from datastore in app engine

Posted on November 3rd, 2008 in App Engine, Google, Programming | No Comments »

Before you continue to read the post, i have to warn you that this is not the best way of getting the total count and there would be a possible inaccuracy and may not be scalable (http://groups.google.com/group/google-appengine/browse_thread/thread/3abb2868ab5fc304?pli=1), please use shared counter as what david suggested.

Here is a way on how to get the total count from a datastore in app engine, this uses memcache to cache the count for one minute (you can change this by passing an argument), i’m not sure but this seems to be better coz it doesn’t need you to do some writing on datastore.

from google.appengine.api import memcache
def get_total_count(self,model,cacheTime = 60,maxNumber = 10):
cacheName = model.kind() + "_totalCount"
total = memcache.get(cacheName)
if total == None:
index = 0
currentTotal = total = len(model.all().fetch(maxNumber,0 ))
while currentTotal == maxNumber:
index += 1
currentTotal = len(model.all().fetch(maxNumber,maxNumber * index))
total += currentTotal
memcache.add(cacheName, total, cacheTime)
return total

To call it on your get function:
self.response.out.write(str(get_total_count(self,<your model>))
or
self.response.out.write(str(get_total_count(self,<your model>,3600,1000))

* Remember that the maxNumber argument can only support upto 1000 and i encourage you to set it to 1000 if your datastore is big

Explanation to the codes:
cacheName = model.kind() + "_totalCount"
Create a variable and name it as our model’s name with an underscore totalCount (you can change this one)

total = memcache.get(cacheName)
if total == None:
index = 0

Change if there is already a cached value, if not set a index variable to 0 and ….

currentTotal = total = len(model.all().fetch(maxNumber,0 ))
Set the currentTotal and total variable to the len of a fetched row limit by maxNumber starting with the row 0

while currentTotal == maxNumber:
index += 1
currentTotal = len(model.all().fetch(maxNumber,maxNumber * index))
total += currentTotal

Loop until the currentTotal is not equal to the maxNumber and add the currentTotal to the total variable and add one to the index. Why do a while loop on currentTotal == maxNumber? Since we set a upper limit on the maximum number of rows we could fetch, it logically means that if we loop with the upper limit it would come to a point where it would never be equal to that limit.

memcache.add(cacheName, total, cacheTime)
Cache our total

Hope i’m right and it helps :)

Installing phpmyadmin in ubuntu

Posted on November 2nd, 2008 in Ubuntu | No Comments »

Here is a simple way of installing phpmyadmin on ubuntu

sudo apt-get install phpmyadmin
cd /var/www
sudo ln -s /usr/share/phpmyadmin/ phpmyadmin

Fastest and Easiest way to install MySQL,PHP&Apache on Ubuntu Ibex

Posted on November 1st, 2008 in Ubuntu | No Comments »

Here is the command for the fastest and easiest way to install MySQL,PHP and Apache in Ubuntu Ibex
* Open terminal (Alt+F2 then gnome-terminal) and type
sudo tasksel install lamp-server

Done, just follow the wizard and your ready to go. To check if its okay
http://localhost

If it doest show you “It works” you need to start it. To start the apache
sudo /etc/init.d/apache2 start

These are optional
Enable .htaccess
sudo gedit /etc/apache2/sites-available/default
Change the line 11 (AllowOverride None, under directory /var/www) to AllowOverride All
Save and restart the apache
sudo /etc/init.d/apache2 restart

Enable Mod Rewrite
Open terminal and type
sudo a2enmod rewrite
Restart the apache
sudo /etc/init.d/apache2 restart

CamelCase in Python / Django

Posted on October 30th, 2008 in App Engine, Programming | 2 Comments »

Here is a small script for making CamelCase string in python

import re
from string import capitalize
def camelcase(value):
return "".join([capitalize(w) for w in re.split(re.compile("[\W_]*"), value)])

in django just add
@register.filter

making it
import re
from string import capitalize
@register.filter
def camelcase(value):
return "".join([capitalize(w) for w in re.split(re.compile("[\W_]*"), value)])

Hope it help.

Searching tv shows in chinese video sites

Posted on October 29th, 2008 in Hacks, Other | No Comments »

Say you want to watch your favorite tv shows online, (hulu is not available in other place, those people think that the only country in the world is US), and you really want to watch it. You can go to Chinese video sites like youku.com and search for the shows that you want to watch, all you have to do is locate the search box and start searching. But how?

Usually they would name tv shows like heroes 第三季 07, or heroes第三季 第07集, now what does this mean? The first Chinese words, 第三季, means the 3rd quarter or the 3rd season, then the 2nd Chinese words, 第07集, means the 7th part or the 7th article or 7th set. Now what if i want to watch the 2nd episode in season 2? You would search something like ‘heroes 第二季 第2集’ or ‘heroes 第二季 第二集’ .

If we put it into a mathematical formula it should be something like
let search = x 第y季 第z集
where x is your favorite tv shows
y is the season number
z is the episode number

And here are the numbers for you to substitute from
1 = 一
2 = 二
3 = 三
4 = 四
5 = 五
6 = 六
7 = 七
8 = 八
9 = 九
10 = 十

So getting heroes season 1 ep 9 is like
search = heroes 第一季 第九集

What about numbers getter than ten? To get numbers beyond 10 you have to mix them in the formula
let num = x十y (the second character is not a plus but the Chinese ten 十)
where x be the multiplier of ten except 1, you will understand why except one later on
where y is from one to nine, then y would be added to the results of x十

Say you want to search for the 25th, it should be
二十五
Why? x is the multiplier then 2(10), 二十, is 20 then add 5,五, then its equal to 25, 二十五
Thirty four would be 三十四
Forty nine would be 四十九

You could simple rephase the formula to
let num = (x multiply to 10) plus y

Now from 11 to 19, you don’t need to add 一 to the front coz its the same with or without it.
And so 18 would be 十八
Fifteen would be 十五

If you find this way to complicated then you can use Google Translate, btw i’m not Chinese, i just studied in Hong Kong when i was small so i do know their language a bit.

Hope it helps and lets all hope that big media company would realize that there people outside US.