Rudimentary Art of Programming & Development

Promoting Open Source, Always…

Archive for January 2008

Flickr Backend

without comments

Early Flickr:

Flickr Architecture:

Written by didip

January 30, 2008 at 6:29 pm

Digg Backend

without comments

Written by didip

January 30, 2008 at 12:51 am

Super Sizing YouTube with Python

without comments

By Mike Solomon

Written by didip

January 29, 2008 at 9:11 am

The Theory of Psyco

without comments

Below is the theory behind Psyco, the Just In Time(JIT) Compiler, for Python

Written by didip

January 27, 2008 at 7:00 pm

Google Mondrian…

without comments

Is Guido Von Rossum’s project at Google.

He created online code review application for Google’s internal use.

Google Mondrian uses:

Resource: 

Written by didip

January 27, 2008 at 6:20 pm

LiveJournal Backend

without comments

August 2005: 

April 2004:

Written by didip

January 27, 2008 at 4:29 pm

Posted in memcache, mysql, scalability

PHP annoyance: MySQL now() vs PHP time()

with 3 comments

When your DBA is thinking differently than you, you might get:

MySQL

field: created_on

type: DATE

while, on PHP side:

$created_on = time();

Below is simple script that get rid of such annoyance.

From PHP to MySQL:

$created_on = date(‘Y-m-d H:i:s’, time());

From MySQL to PHP:

$query = “SELECT created_on FROM some_table WHERE id=1″;

$row = mysql_fetch_array(mysql_query($query));

$created_on = $row['created_on']; //created_on from MySQL in DATE format

list($date, $time) = explode(‘ ‘, $created_on);

list($y, $m, $d) = explode(‘-’, $date);

list($h, $i, $s) = explode(‘-’, $time);

$created_on = mktime($h, $i, $s, $m, $d, $y); //created_on timestamp

Written by didip

January 23, 2008 at 7:38 am

Posted in for dummies, php, tutorial

Scaling Twitter – PowerPoint

without comments

Written by didip

January 23, 2008 at 7:20 am

Posted in scalability, twitter

Why Python?

with 3 comments

Among other programming languages, why choose Python?

Let’s go over the basics first, these traits also exist in other programming languages:

  • Python is interpreted Programming Language. It is also a high-level programming language. Therefore, just like Ruby or Perl, Python is easy to learn and easy to get up to speed on sizable projects.
  • Python is also object-oriented language. But that’s nothing new, most modern programming languages are object-oriented anyway.

Naturally, readers will ask, if Python can only do what MY programming language already can… Why do I have to learn it? Below is my reasoning why… and hopefully readers will convert to Python :-P

1. Python does not have funky sigils or special system_call functions. The only one you have to memorize is: __someDefaultMethods__ By not having too many special characters, programmers spend less time browsing documentation or mailing list on Google.

2. Python tabbed indentation actually contributes to highly readable code. Readable code helps especially when you are juggling many different projects every week, it allows you to remember quickly what you did last time.

3. Python’s power and scalability is proven not hype.

4. For Back-end Programmers, Database Designer, and System Engineers:

  • Look at Twisted[1]. It is one kick ass networking library. It supports many networking protocols that allows building web servers, email, or chat easier.
  • Look at SQLAlchemy[2][3], I never seen ORM so powerful and yet so easy to learn.

5. For Application Developers:

  • Django is a complete out-of-the-box Web Framework. Their slogan — “For Perfectionists with deadlines”
  • TurboGear is also another awesome complete Web Framework solution. But I suggest readers wait until they included SQLAlchemy as their new database stack.

6. For Javascript Developers:

  • Look at Mochikit, It is a complete javascript framework that’s very Pythonic. Mochikit is still just Javascript, but have Python’s sense of elegance.

Below are quotes from Eric Raymond on why he likes Python:

– “In Python, I was actually dealing with an exceptionally good design. Most languages have so much friction and awkwardness built into their design that you learn most of their feature set long before your misstep rate drops anywhere near zero. Python was the first general-purpose language I’d ever used that reversed this process.

– “It (Python) is compact–you can hold its entire feature set (and at least a concept index of its libraries) in your head. C is a famously compact language. Perl is notoriously not;

– “What I really wanted was code that would analyze the shape and members of the initializer, query the class definitions themselves about their members, and then adjust itself to impedance-match the two sets… …This kind of thing is called metaclass hacking… …Thirty-two lines, counting comments… …Brace yourself: this code only took me about ninety minutes to write—and it worked correctly the first time I ran it.

– “So the real punchline of the story is this: weeks and months after writing fetchmailconf, I could still read the fetchmailconf code…

Summary:

Hopefully I provided enough examples on why Python can be your next favorite programming language. Programming in Python is fun indeed.

Resources:

  1. http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions
  2. http://www.sqlalchemy.org/
  3. http://en.wikipedia.org/wiki/SQLAlchemy
  4. If you are new in Programming, this E-book can help
  5. Why use Python in Windows XP?
  6. Python Doc – String
  7. Python Doc – Common OS path manipulation
  8. If you are familiar with apt-get, Python have something similar for its modules: easy_install

What Others Said about Why Python:

Written by didip

January 20, 2008 at 12:50 pm

Ruby: @, @@, !, ?, #, and {}

without comments

This is post is intended to be a quick reference page for basic ruby consumption.

What is @

It is a sigil for instance variable. That means, the variable scope is within an instance of a class.

What is @@

It is a sigil for class variable. When defined in a class, duh,  the value is shared by all of its instances.

What is !

Ruby allows its function namespace to have exclamation point(!). When a function is declared with (!) sign, it means that the function will overwrite the caller’s value. For example:

test = “awesome”

test.reverse!

puts test # test value is: emosewa


What is ?

Just like exclamation point, question mark is allowed in Ruby’s function namespace. When a function is ended with (?), the function is expected to return boolean value.

What is #

It is a sigil to mark the beginning of comment.

What is {}

It could means:

  1. a Hash. When assigned to a variable.
  2. beginning & end of a block (anonymous function).

Written by didip

January 14, 2008 at 10:55 pm

Posted in for dummies, ruby, tutorial