Official ObjectGraph Blog
Saturday, January 20, 2007
FireFox bug report filed
I filed a bug report for mozilla not being able to parse php tags. You can track it here.
https://bugzilla.mozilla.org/show_bug.cgi?id=367602
Initial impressions from other developers show that this is not a duplicate bug. The weird thing is this happens in Mac safari as well.
Labels: "firefox bug", dom
posted by gavi at 9:47 PM | 0 comments |
bug in FireFox?
<html>
<head><title>Bug in Mozilla?</title></head>
<script type="text/javascript">
function AlertAll(tagname)
{
var arr=document.getElementsByTagName(tagname);
for(i=0;i<arr.length;i++)
{
code=arr[i].innerHTML;
alert(code);
}
}
</script>
<body>
<pre id="python">
print "Hello";
</pre>
<pre id="php">
<?php
printf("Hello");
?>
</pre>
<script type="text/javascript">
AlertAll("pre");
</script>
</body>
</html>
click here for the live version.
The second messagebox will be empty in FireFox. It works good in IE 6 and 7
posted by gavi at 11:03 AM | 2 comments |
Friday, January 19, 2007
PIL on captcha - Transparency and Masking for CAPTCHA
It seems that there are no good introductions for how to create transparent image text. However we want it for common image module like CAPTCHA which is an image authentication method. It's easy to just draw text on image, but in order to rotate the text, you have to rotate the image with the text. I think one of the solution is using mask after rotation. You need 3 images to do this.
1. Background
2. Text
3. Mask
2 and 3 must be in a same size, and when you "paste" the text, you can specify the mask as the extra paramter.
This is simple exapmle, to rotated "Hello" on the background
import Image,ImageDraw,ImageFont # Create a background image image = Image.new('RGB', (300, 50), (220,210,190)) draw = ImageDraw.Draw(image) # Create a text image textImg = Image.new('RGB',(150,40),(0,0,0)) tmpDraw = ImageDraw.Draw(textImg) textFont = ImageFont.truetype('ARIAL.TTF',36) tmpDraw.text((0, 0), 'Hello', font = textFont, fill = (10,200,200)) textImg = textImg.rotate(-10) # Create a mask (same size as the text image) mask = Image.new('L',(150, 40),0) mask.paste(textImg,(0,0)) # Paste text image with the mask image.paste(textImg,(100,0),mask) image.save('hello.jpg')
In order to generate CAPTCHA-like image, you might want to apply random xy, color, font size, lines, etc...
So it'll be like this:
This is entire source for these examples. Please install PIL (do easy_install PIL) first.
Download Source Code Here (7.95KB)
Labels: python
posted by Kiichi Takeuchi at 1:44 PM | 0 comments |
Tuesday, January 16, 2007
Practical AJAX Solution @ Travel Industry
This is a simple case study that I implemented for my client with Ajax Technique.
Problem: A travel company dispatchers need to look at their tour guide's schedule in one shot. Data is grouped by their job information; however, dispatchers need to look at them grouping by flight number too. Because if the arrival schedules are close enough, they want to merge two jobs in case of extra capacity in other car.
Solution: At the 1st level, it groups by the job. In the second level, user paints some colors on each job to identify similar flight schedules across all different categories: Arrivals, Departures, and Optional Tours.
Implementation: I added paint can icon , and popup color picker to fill the panel.
Result: user can look at similar flights as below:
In my opinion, in this kind of business application, AJAX works in pinpoint for a specific purpose. If we make it work just like Gmail, using AJAX all over the places, the development cost will increase a lot.Labels: ajax
posted by Kiichi Takeuchi at 10:30 AM | 0 comments |
Monday, January 15, 2007
Prof. Devi's Game Engine
Professor Devi released the first version of his 3D Game engine library, MSGA3D, which is based on Irrlicht library. According to our discussion, he introduced to use "ID" to control all objects, such as Node, Mesh, Sound, and even call back functions. This coding style dramatically improves student's learning curve. In terms of the functionality, his improvement is more drastic such as Timeline and Event Model Change, Sound, etc...
This is a demo to download DeviEngineDemo.zip (2.86MB)
This is a sample project file in VC++6.0 DeviEngine.zip (5.26MB)
Amount of code is minimal, and easy to control like this:
int main(void) { MSGAEngine3D engine(800,600,16); // Screen Size engine.NodeLoadCameraFPS(100); // camera ID=100 // Load Rotating Cube engine.TextureLoad(300,"sample.jpg"); // create texture ID=300 engine.NodeLoadCube(200,200); // cube ID=200 engine.NodeSetTexture(200,300); // texture to the cube engine.NodeAddPosition(200,950,600,600); // move cube engine.AnimatorRotation(200,30,1,31); // rotate cube engine.GameLoop(); return 0; }
That's it! this program just load cube with the texture. The original library download page should be ready soon on his Website (http://comine.com). In demo example, I included a simple FPS-look demo, texture, level, sound, and timer event within 40 lines of code (with bunch of comments and spaces).
Labels: game development
posted by Kiichi Takeuchi at 1:20 PM | 0 comments |
Sunday, January 14, 2007
Line numbers and other cool stuff Added to Pygments.com
I added line numbers and some formatting capabilities to Pygments.com
Now the script tag renders line numbers by default. Also RTF download of colored code is available on the Test Page for those nice looking word documents
Check it out @ http://www.pygments.comLabels: pygments.com, python
posted by gavi at 3:08 PM | 0 comments |
Saturday, January 13, 2007
Pygments.com Launched
I purchased Pygments.com domain yesterday. Iam surprised the domain is still available. i guess the Pygments guys dont really care about the .com domain name.
Any way access it via http://www.pygments.com
You can use the code colorizer by going to the Colorizer Test Program.
But the cool thing i added is, a javascript service to colorize any code. Lets say you have a webpage with code, that needs colorizing, Just add this Javascript to the end of the page (Before you close the body tag)
<script src="http://www.pygments.com/js/init.js" type="text/javascript"></script>
All you will need to do is define your code in <pre> tags with unique ids that include some information about the type of the language.
For example:
<pre id="python_1">
print "Hello World"
</pre>
It will automatically colorize the page by making JSON type requests to pygments.com with the code in the page.
So the above would come out like this
print "Hello World"
BTW: pygments javascript is enabled on this site
Labels: json, pygments.com, python
posted by gavi at 5:59 PM | 5 comments |
Thursday, January 11, 2007
Pygments Test Program
posted by gavi at 4:06 PM | 0 comments |
Saturday, January 06, 2007
Pygments!
I was able to create a simple django project that used Pygments to colorize python code and here is the outcome.
You can download the source code here
posted by gavi at 10:21 AM | 0 comments |
Friday, January 05, 2007
Recompilining Apache with mod python
So i decided to compile Apache from source and it works beautifully.
And apache is very clean, when you compile from scratch. I was able to compile the latest version (2.2) and recompile mod python.
Removed all httpd related packages from CentOS
php-5.1.6-1.2.1.centos php-mysql-5.1.6-1.2.1.centos php-pear-1.4.9-1.2.centos php-pdo-5.1.6-1.2.1.centos httpd-suexec-2.0.52-28.ent.centos4 httpd-2.0.52-28.ent.centos4
Then got the latest version of apache.
#wget http://apache.mirrormax.net/httpd/httpd-2.2.3.tar.gz #tar xvfz httpd-2.2.3.tar.gz #cd httpd-2.2.3 #./configure #make #make install
this time mod python was again complaining. You will have to compile with the apxs installed by the new apache 2.2.3
#./configure --with-apxs=/usr/local/apache2/bin/apxs
So what did i learn from this exercise.
Always recompile everything unless you want to stick to versions of python that came with the distro.
posted by gavi at 10:28 AM | 0 comments |
Thursday, January 04, 2007
Installing mod_python on Apache
#wget http://apache.mirror99.com/httpd/modpython/mod_python-3.2.10.tgz
#tar xvfz mod_python-3.2.10.tgz
#cd mod_python-3.2.10
#ls -al
#./configure
I get an error at this stage saying apxs or apxs2 not found. So basically its looking for httpd-devel packages.
Just did
#yum install httpd-devel
and I was able to build it successfully.
#./configure
#make
#make install
it put mod_python.so in
/usr/lib/httpd/modules
The next step would be to configure Django with Apache.Labels: apache, centos, mod_python
posted by gavi at 11:33 AM | 0 comments |
Wednesday, January 03, 2007
Installing Python 2.4.4 on Cent OS 4.4 (Final)
class Test: def __init__(self): print "Hello World!" def sum(self,a,b): return a+b @staticmethod def sum1(a,b): return a+b t=Test() print t.sum(10,10) print t.sum1(10,10)After a lot of struggle to find a binary package of Python 2.4.4 for Cent OS, I gave up and compiled python from source. It was pretty straightforward and i am happy with the results. This is what i did.
#wget http://www.python.org/ftp/python/2.4.4/Python-2.4.4.tgz
#tar xvfz *.tgz
#cd Python-2.4.4
#./configure
#make
#make install
Just run python to see if it is the version 2.4.4
Now python is cleanly installed. The site-packages folder under /usr/local/lib/python2.4 are empty. So get the latest version of django and install it
#svn co http://code.djangoproject.com/svn/django/trunk/ django
#cd django
#python setup.py install
Similary you can install MySQLdb and other libraries you want on python.
Now the next steps for us is to get django running on Apache using mod_pythonposted by gavi at 10:02 PM | 2 comments |
Tuesday, January 02, 2007
AJAXified Contact Page
Most of the code for JavaScript is in
http://www.objectgraph.com/js/sendmail.js
I also played with Google Maps API to put a small map of our office location. Check it out.
The code for it is in
http://www.objectgraph.com/contact.html
I wanted to add weather settings to the map, but NOAA service seems like broken for ASP.NET, maybe i will try it in Python :-)
Labels: ajax, google maps
posted by gavi at 10:57 AM | 0 comments |
Monday, January 01, 2007
Happy New Year!
This year OGians will be launching a slew of products. In the mean time checkout the positioning tutorial on CSS
http://www.objectgraph.com/wiki/pmwiki.php?n=CSSTutorial.Positioning
It 'clears' your mind!
Labels: css
posted by gavi at 12:21 PM | 2 comments |