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




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

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 path
here 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

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

Wednesday, March 28, 2012

Lubuntu 12.04 countdown!

The Lubuntu 12.04 countdown is ready

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]   DeprecationWarning
so 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

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




Total price was $12,000
Compare that with Amazon :Just checked AWS Elastic Cache’s pricing.
It would cost around 20k / month for ~ 800 GB of Memory. (12 * Quadruple Extra Large nodes / 68 GB)

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


cat /home/ubuntu/curl_cron.php


Thursday, February 02, 2012

Suhosin is disbled by default in Debian, and soon Ubuntu - i hope

I think is the right aproach 
I don't believe in security by obscurity (this random patch it will secure your php ... riiight)

suhosin shouldn't be a patch it should be inside of php core or as module (think like the selinux situation) , So debian guys are right use the upstream unpatched version , let the core php devels decide if suhosin is right or wrong for them :less bugs , less patches , life is better = more security and fast updates in debian

Did i told you that upstream doesn't test suhosin patch when they run the tests ?
And with that patch php core is not the same , there are some bugs that i found related to it  (in debian/ubuntu) and it happens only when that invasive patch is applied

Wednesday, February 01, 2012

updating passenger in rails and ubuntu 10.3 lts

I had one issue with an old instalation of passenger and nginx (kernel 2.6.32 doesn't quite deliver signals to the nginx 0.8.x)

I download the current dark passenger

wget http://rubyforge.org/frs/download.php/75548/passenger-3.0.11.tar.gz
tar -zxvf passenger-3.0.11.tar.gz
cd passenger-3.0.11/
rake package
sudo su # and make me a sandwitch
cd pkg gem install passenger-3.0.11.gem

start the nginx wizzard
/var/lib/gems/1.8/gems/passenger-3.0.11/bin/passenger-install-nginx-module
choose (1),(1)
enter enter enter
and all is installed

Read what is needed to add to nginx config if you do an upgrade

mainly the new passenger path

Please edit your Nginx configuration file (probably /opt/nginx/conf/nginx.conf),
and set the passenger_root and passenger_ruby configuration options in the
'http' block, like this:

  http {
      ...
      passenger_root /var/lib/gems/1.8/gems/passenger-3.0.11;
      passenger_ruby /usr/bin/ruby1.8;
      ...
  }

After you (re)start Nginx, you are ready to deploy any number of Ruby on Rails
applications on Nginx.

Press ENTER to continue.

The END

encoding decoding strings in python3.x


I like to think of  encoding of strings in python3 to the analogy of encrypting your plain text into a random stream of bytes

string (plain text) -> encode (encrypt) -> bytes (stream)
bytes (stream) -> decode (decrypt) -> string (plain text)

and the codec you choose is your key (utf-8 ...)


Sunday, January 29, 2012

Typing so many times the password in sudo is good or bad ?

Well if you watch National treasure  you will see how easy is to spot the common keys that you press with a special fluorescent/UV light , also the fingerprints on a keyboard are more visible on thouse keys (that would be the keys for sudo for example , or the login window) also some social engineering helps (knowing the person)


- I'm here.
- Give me the letters for her password.
What do you got for me?
Hit me with it.
A-E-F-G...L-O-R-V-Y.
Anagrams being listed.OK.
Top results: "A glove fry."...
...
- It's "Valley Forge"."Valley For..."
I don't have that on my computer.It's "Valley Forge" -she pressed the E and L twice.
Valley Forge was a turning pointin the American Revolution.C
an I marry your brain?
We're in.


That is why is better to use the ssh-agent , password-less sudo
and spread your password keys over your keyboard , and one more hint
it shouldn't be any reference to anything known about you in public/private life (eg if you love history:historical references with years dates , places)


Thursday, January 26, 2012

Welcome to the U-nderland

All you want is here , minus start menu and the close menus and minus the menus ,
Oh i told you that you shouldn't use menus , It's a paradigm shift , everything is search and google



Via doctormo who will be removed from the ubuntu holly planet
But dude where is my menu and close button
In the hud , in the hud  a small voice creeps into the ethereal space

 

Ubuntu Romania and Libre Software Romania (software liber) are against ACTA

Between revolutions we have to fight ACTA too , I will copy paste the message from Stas




Apparently, while most of the Romanians were busy with „Băsescu” crisis and snow, ourgovernment decided to sign ACTA.
To be honest, I’m not sure who’s job was to inform European population about this upcoming decision, but they did it in the worst possible way. Anyway, if you feel the need of blaming your regional/representative politician, you can get his address from here:agenda.grep.ro.
For those who just woke up in this world, and have no clue what’s this all about, take a look at this video.

About the picture above is from doctormo

Configuring pydev for django

I love some of the pydev features and here is my usual django/python setup

Install eclipse classic

Configure updates and add pydev

Configure updates and add eclipse themes

Install ipython
sudo easy_install ipython

Create or import pydev/django project

Configure java script editor (WTP webtools) in updates (in my case for indigo , choose from the repository manager in updates)



Learn and configure howto do remote debugging for django

The eclipse git plugin it crashed on me , aka it failed when i tried to do a push
It's slower than the c based implementation (eclpise plugin for git is written in pure java )
Did i told you that doesn't work , ok So you need to use command line for git , it's faster and better

Sunday, January 22, 2012

Why Zope fails and Django is better


I quote a thread from reddit and if you still use zope/plone you fail , there is nothing pythonic in the zope
I did a beginner mistake once to think that zope is somehow python and i could handle all the complexity and zope core ugliness but now I know the complexity monsters can't be tamed (include there XML , JAVA2EE, zope ... )

As a Python programmer, hardly anything you knew was useful when trying to do stuff in Zope. It was its own universe, with its own physical laws. You could do some simple things via the web interfaces, but as soon as you want to do stuff in Zope's odd variant of Python, you had to start from scratch.
And as a result, we lost a whole generation of Python web programmers.
In that respect, Django is more of an anti-Zope -- it's plain old Python pretty much all the time, you don't have to unlearn or relearn anything, and it has done more to get new programmers to pick up Python than any single Python library or application ever released before it. Heck, the Django mailing lists are almost as crowded as the Python mailing lists these days.