Recently, my gf has to work on a project where she organizes games on by posting questions to facebook pages. Page’s followers who answer correctly and with a bit of luck will receive a small gift. The game is part of an ads campaign for her customer.
So I had to do a database migration which concerns importing massively external data into current production database. Since I have already implemented quite a few methods to do all validation, duplicate handling and so on using django orm, I don’t want to write those code again using raw mysql commands. It would be a pain if I forget to set a certain field which breaks the system later on. I decided to look around on the internet for help to import existing django project to my script. It turns out to be straight foward (thankyou internet!)
Basically, I needed to add my project path to system path and tell python to import my project settings:
from <app_name>.models import *
from <app_name>.views import <whatever method you need>
For my case, I wanted to run a multithread process to boost the data processing speed on my quad-core cpu, so I needed to close the django db connection before invoking the threads. The reason is django only uses a single connection for all threads and this causes confict between them. By explicitly closing db connection before starting a thread, each thread will create it own connection.
from django import db
for alias, info in db.connections.databases.items():
//start your thread
I just found an interesting thing about django database queryset laziness: The query would not be executed until the object is referenced. That means only when we actually get the value of the result of the query, the sql query is executed.
//would not work
Reason is simple: first statement does not fire the reference to the returned value so the query is not executed. The query is executed in 2nd statement when the array reference () is called.
More info: https://docs.djangoproject.com/en/dev/topics/db/queries/#querysets-are-lazy
p/s: the .get() method returns the object, not a queryset so we do not need the  for sql to be executed.
To use it, simply create a div with id=select_slot where you want to put it and call setup_slot_select() passing 2 arrays with the row and column values.
You can find the example features in index.html of the archive at here
After trying to exploit the XSRF (previous post), it is considerable to put in mind techniques to prevent against the this attack. This post will try to evolve from very basic protection and to better security approach by discussing their weaknesses. The technique discussed in this post including changing state by POST request, CAPCHA, prevention token and crytographic token.
Cross-site request forgery (XSRF) is an attack which exploits websites that have weak authorization by taking the advantage of browser session and same-origin policy. To understand clearly about Cross-site request forgery, you can read the wiki page here. This post will demonstrate a simple exploitation using this technique.
I have developed several websites using Zend framework in the past. Recently, I have just started to read a book about Ruby on Rails and trying to learn a little bit about it since every body is talking about Ruby on Rails and stuffs. Since I quited web programming a long time ago, this is only my personal comparison between Rails 2012 vs Zend 2010.
This is an assignment of my multimedia course. I tried to code a small application that allows people to draw on computer by moving 2 pieces of color paper. This application is based on the idea of color tracking.
Recently, I’m involved in a project where I have to test the ads banner by putting it on several websites. Of course I don’t have the money to buy ads slots on all of those sites, so I have to write several scripts to replace the banners on those websites with my banner on my browser.
It’s a project for Software analyst and design, but we were too lazy to do it as the summer vacation has already begun when the project was announced.
So 3 days working including more than 2 days for documentation and 3 or 4 hours of coding and we have this application.
It’s can resize/rotate/gray-scale multi-image.
It’s really a shame but I want to post it here anyway.
I was responsible for Designing the solution and coding (which take about 5 or 6 hours in total!), Quoc did the GUI and Nam did the document based on my design.