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
Saturday, May 26, 2012
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
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
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
new fdb firebird driver example :execute insert statement
Here is my example for inserting one row in firebird database with fdb python driver
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
Old driver and soon to be deprecated , the recommended way is to use fdb
_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 link for the moment
and here is your first connection
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
Friday, April 27, 2012
Timezone offset in seconds php vs ruby
echo date('Z');
10800
and timizone seems to be set right
date_default_timezone_set('Europe/Bucharest');echo date('Z');
10800
and in ruby it gives
Time.zone.now.utc_offset()
=> -25200
seems that rails and php lives in different timzones
so try to use localtimezone and is correct now
l = t.getlocal
=> 2011-06-27 10:10:00 +0300
1.9.2p318 :025 > l.gmt_offset
=> 10800
10800
and timizone seems to be set right
date_default_timezone_set('Europe/Bucharest');echo date('Z');
10800
and in ruby it gives
Time.zone.now.utc_offset()
=> -25200
seems that rails and php lives in different timzones
so try to use localtimezone and is correct now
l = t.getlocal
=> 2011-06-27 10:10:00 +0300
1.9.2p318 :025 > l.gmt_offset
=> 10800
Monday, April 23, 2012
One way to avoid the Adobe tax
One coleague of mine extracted the layers from psd files with image magick
I wish gimp could preserve all these layers when you import the psd , or maybe we can do a python plugin that will extract the layers and import them in the the gimp layers
I wish gimp could preserve all these layers when you import the psd , or maybe we can do a python plugin that will extract the layers and import them in the the gimp layers
Sunday, April 22, 2012
I love pip install
Here is how easy it is to install fdb firebird driver
pip install fdb
Downloading/unpacking fdb
Downloading fdb-0.x.x.tar.gz (xxxKb): xxxKb downloaded
Running setup.py egg_info for package fdb
Installing collected packages: fdb
Running setup.py install for fdb
error: could not create '/usr/local/lib/python2.7/dist-packages/fdb': Permission denied
Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/mariuz/build/fdb/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-8bcPXK-record/install-record.txt:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/fdb
copying fdb/services.py -> build/lib.linux-x86_64-2.7/fdb
copying fdb/fbcore.py -> build/lib.linux-x86_64-2.7/fdb
copying fdb/ibase.py -> build/lib.linux-x86_64-2.7/fdb
copying fdb/__init__.py -> build/lib.linux-x86_64-2.7/fdb
running install_lib
creating /usr/local/lib/python2.7/dist-packages/fdb
error: could not create '/usr/local/lib/python2.7/dist-packages/fdb': Permission denied
----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/home/mariuz/build/fdb/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-8bcPXK-record/install-record.txt failed with error code 1
Storing complete log in /home/mariuz/.pip/pip.log
#Let's use the sudo super cow powers
mariuz@borki7:~$ sudo su
root@borki7:/home/mariuz# pip install fdb
Downloading/unpacking fdb
Running setup.py egg_info for package fdb
Installing collected packages: fdb
Running setup.py install for fdb
Successfully installed fdb
Cleaning up...
Monday, April 16, 2012
Firebird remote interface vs direct file access for firebird databases
The scenario it can happen when using firebird classic (see the end of the article) You skip the remote interface (tcp/ip) and access the database directly by typing
isql-fb database pathhere is my setup when i try to use the database directly or without password the server is not using the remote interface (There is no remote server/interface in the show version command)
sudo isql-fb /var/lib/firebird/2.5/data/rubyonfire.fdb Database: /var/lib/firebird/2.5/data/rubyonfire.fdb SQL> show version; ISQL Version: LI-V2.5.2.26466 Firebird 2.5 Server version: Firebird/linux AMD64 (access method), version "LI-V2.5.2.26466 Firebird 2.5" on disk structure version 11.2 quit;check if the server is up with telnet localhost 3050 and then force the tcp ip method to connect using the remote interface use locahost:path
SQL>connect "localhost:/var/lib/firebird/2.5/data/rubyonfire.fdb" user 'SYSDBA' password '********'; SQL> show version; ISQL Version: LI-V2.5.2.26466 Firebird 2.5 Server version: Firebird/linux AMD64 (access method), version "LI-V2.5.2.26466 Firebird 2.5" Firebird/linux AMD64 (remote server), version "LI-V2.5.2.26466 Firebird 2.5/tcp /P12" Firebird/linux AMD64 (remote interface), version "LI-V2.5.2.26466 Firebird 2.5/tcp )/P12" on disk structure version 11.2
Tuesday, April 10, 2012
What you can learn from instagram deal and become a billionare
If you look at the tech behind it:
- use Ubuntu server or debian on amazon ec2 (I guess you can choose your own cloud solution)
- use Django with a shraded relational database (I would chose firebird)
- use nginx with gunicorn or uwsgi
- you use memcache right ?
- for notifications on apple use pyapns , billions of messages are send with it
- create and write a android app
- use gearman
- redis
- scare the hell out of facebook
- profit
- use Ubuntu server or debian on amazon ec2 (I guess you can choose your own cloud solution)
- use Django with a shraded relational database (I would chose firebird)
- use nginx with gunicorn or uwsgi
- you use memcache right ?
- for notifications on apple use pyapns , billions of messages are send with it
- create and write a android app
- use gearman
- redis
- scare the hell out of facebook
- profit
Tuesday, April 03, 2012
Rails project bash aliases
To type less in the bash console on my Lubuntu
I use these bash aliases added in ~/.bashrc
I use these bash aliases added in ~/.bashrc
Wednesday, March 28, 2012
Sunday, March 25, 2012
Migrating to django 1.4
First i have fixed the warnings
[Sun Mar 25 21:15:41 2012] [error] DeprecationWarning [Sun Mar 25 21:15:42 2012] [error] /usr/lib/python2.5/site-packages/django/conf/__init__.py:75: DeprecationWarning: The ADMIN_MEDIA_PREFIX setting has been removed; use STATIC_URL instead. [Sun Mar 25 21:15:42 2012] [error] "use STATIC_URL instead.", DeprecationWarning) [Sun Mar 25 21:15:42 2012] [error] /usr/lib/python2.5/site-packages/django/core/cache/__init__.py:82: DeprecationWarning: settings.CACHE_* is deprecated; use settings.CACHES instead. [Sun Mar 25 21:15:42 2012] [error] DeprecationWarningso i have deleted the line ADMIN_MEDIA_PREFIX from settings.py and need to configure the "/media" for the admin url also replaced
CACHE_BACKEND = 'locmem://'with
{
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
Wednesday, February 15, 2012
For people who belive in ORM: Please learn SQL
Here is one example of what happens when django ORM can be optimized
Profiling Django Applications: A Journey From 1300 to 2 Queries
Profiling Django Applications: A Journey From 1300 to 2 Queries
Sunday, February 12, 2012
EC2 is about 10-20 times more expensive than dedicated hosting.
Quote of the day via ycombinator:
Even if reserved instances save us 22% over 3 years, it still doesn't even come close. Reserved instances also force me to commit to using a certain type of EC2 instance for 3 years with lots of money upfront. Moreover, IO is ridiculously bad on EC2 and there's nothing that can be done about it. Even RAIDing a gazillion EBS volumes together doesn't do much. I'm glad the truth about how expensive EC2 really is is starting to come out. Hopefully it will force them to revise their pricing, or at least offer more processing power for the same price.
I ran some benchmarks a few weeks ago that show how expensive EC2 really is
Agreed. Here's a good relevant blog post by mark maunder challenging the "cloud hype" http://markmaunder.com/2011/10/31/clouded-vision/
Another thing that is overpriced is the memory , here is a quote from the basecamp's next memory cache article (see the comments section)
They have brought 864GB of RAM that looks like below
Even if reserved instances save us 22% over 3 years, it still doesn't even come close. Reserved instances also force me to commit to using a certain type of EC2 instance for 3 years with lots of money upfront. Moreover, IO is ridiculously bad on EC2 and there's nothing that can be done about it. Even RAIDing a gazillion EBS volumes together doesn't do much. I'm glad the truth about how expensive EC2 really is is starting to come out. Hopefully it will force them to revise their pricing, or at least offer more processing power for the same price.
I ran some benchmarks a few weeks ago that show how expensive EC2 really is
Agreed. Here's a good relevant blog post by mark maunder challenging the "cloud hype" http://markmaunder.com/2011/10/31/clouded-vision/
Another thing that is overpriced is the memory , here is a quote from the basecamp's next memory cache article (see the comments section)
They have brought 864GB of RAM that looks like below
Saturday, February 11, 2012
Ati fglrx gpu blacklisted in latest chrome beta on Lubuntu/Ubuntu 11.10 with the fglrx driver
Although it works just fine if i use to ignore the blacklisting
Tested on two systems with the current drivers and quite new gpus
See bellow
Here are the details
:
Wednesday, February 08, 2012
php shell script that will run runs at specific hour with crontab and send emails with the html form extracted content
Here is how to create a daily crontab script that runs at specific hour
gets the web content and then saves the output in a file folder (the form must use a sumbit button with post) and then
it send email with the html file
you need to install php5-cli , php-pear
sudo apt-get install php5-cli php-pear
and then from pear Mail , Mail_Mime http://pear.php.net/package/Mail_Mime/redirected
sudo pear install Mail_Mime
sudo pear install Mail
crontab -l
# m h dom mon dow command
0 1 * * * /home/ubuntu/curl_cron.php
# m h dom mon dow command
0 1 * * * /home/ubuntu/curl_cron.php
cat /home/ubuntu/curl_cron.php
Subscribe to:
Posts (Atom)