Saturday, May 26, 2012

How php compiles the source code ?

PHP compiles source code into Zend Engine bytecode - this is done by the Zend
compiler in zend_language_scanner.l, zend_language_parser.y and
zend_compile.c. This code is the executed by the opcode engine in
zend_execute.c and zend_vm_execute.h. The latter is generated from
zend_vm_def.h by means of the script zend_vm_gen.php.




For  a good intro to php internals there is a presentation in french 
http://julien-pauli.developpez.com/tutoriels/php/internals/presentation/


I saw it via this thread on php internals 






Thursday, May 24, 2012

Running thin server in development instead of mongrel

need to add to the  Gemfile

gem 'thin', :group => 'development'

then run

$ bundle install

to start it type
$ rails server thin

Tuesday, May 22, 2012

RubyRails for PHP programmers starting points

If you have php code that needs to be converted to ruby/rails there are a few starting points
hyperpolyglot should be your homepage:
http://hyperpolyglot.org/scripting

On the ruby site there is a nice intro on Similarities and Differences.

From Rails for Php Programmers i used this pdf PHP to Rails Reference (extract)
on the translating php cookies and session (params for post/get ...)

Also the PHP to Ruby reference is very good
https://github.com/maintainable/php-ruby-reference

Ps: main site http://railsforphp.com/ seems to be down at the moment but i guess you can fork and build the reference yourself

Saturday, May 19, 2012

Getting the list of friends and their feeds with python open_facebook

I use django facebook api and here is the example i use to list my friends and their feeds

import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_frontend.settings'
from open_facebook.api import *
access_token ='AAACEdEose0cBAKiYPHcTG17gBhuZAUauHWsJH2aP8Oj4yeZCF7jZCvoLK1WGodyluzgQ1PxPTlLNZAynJ6Qo8TAZBqftxa7FTA4rCiB63oQZDZD'
fb = OpenFacebook(access_token)
#print fb.get('me/accounts')
permissions = [p for p, v in fb.get(
'me/permissions')['data'][0].items() if v]
#print permissions
#print fb.fql("SELECT uid,name FROM user WHERE uid IN " \
# "(SELECT uid2 FROM friend WHERE uid1 = me())")
facebook_friends = fb.get('me/friends')
print facebook_friends["data"]
for element in facebook_friends["data"]:
# print element["name"][0]
for key in element:
print key
print element[key]
print fb.get(element[key]+'/feed')
#fb_feed = fb.get('me/feed')
#print fb_feed

new fdb firebird driver example :execute insert statement

Here is my example for inserting one row in firebird database with fdb python driver


# $ pip install fdb
# use this documentation for the moment http://www.firebirdsql.org/file/documentation/drivers_documentation/python/3.3.0/tutorial.html#connecting-to-a-database
import fdb as kinterbasdb
con = kinterbasdb.connect(dsn='/var/lib/firebird/2.5/data/rdbgraph.fdb', user='sysdba', password='masterkey')
cur = con.cursor()
# Execute the insert statement:
name="name"
facebook_id="facebook_id"
insert_query="INSERT INTO RDBGRAPH_NODES (NAME, FACEBOOK_ID,EMAIL,GOOGLE_ID,TWITTER_ID) VALUES ( ? , ?,'','','')"
cur.execute(insert_query,(name,facebook_id,))
con.commit()
cur.close()

Installing kinterbasdb on Ubuntu Server 12.04 64 bits (python 2.7.3)

 The official way is from svn , otherwise you will get this error

_kiservices.c: In function ‘_init_kiservices_ibase_header_constants’:
_kiservices.c:809:3: error: ‘isc_info_db_impl_isc_a’ undeclared (first use in this function)


Old driver and soon to be deprecated , the recommended way is to use fdb

svn co https://firebird.svn.sourceforge.net/svnroot/firebird/python/kinterbasdb/trunk/ kinterbasdb
cd kinterbasdb

sudo python setup.py install



Connect to firebird using the new python fdb driver

Install the firebird driver (you might need firebird2.5-dev headers)

 pip install fdb

use this documentation link  for the moment


and here is your first connection
#$ pip install fdb
#use this documentation for the moment http://www.firebirdsql.org/file/documentation/drivers_documentation/python/3.3.0/tutorial.html#connecting-to-a-database
import fdb as kinterbasdb
con = kinterbasdb.connect(dsn='/var/lib/firebird/2.5/data/rdbgraph.fdb', user='sysdba', password='pass')
view raw connect_fdb.py hosted with ❤ by GitHub

Thursday, May 10, 2012

What oracle really wants is

A full rewrite of the Java classees with core api and classes and that is what Microsoft "suffered" with the C# Yes C#/.net combo is a bad rewrite of the Java language with COM api and all the unportable DirectX included https://www.eff.org/deeplinks/2012/05/oracle-v-google-and-dangerous-implications-treating-apis-copyrightable