Filter your video collection with Python and IMDbPY

Posted August 23rd, 2010 in Python by Florentin

If you have a large collection of movies (documentaries, dvd rips, etc) and you would like to decide on what worth watching next, this script may come in handy.
It’s a small Python script which scans your movie collection, collects data about each one from imdb.com and allows you to filter the movies by genres, actors or publishing studio.

The movies are collected from subdirectories (of indefinite depth) of a single parent directory which is either the default path (defined in the DEFAULT_MOVIES_PATH variable inside the script) or specified by the “-p” (or –path) parameter.
movies.py is looking for directories which contain at least one movie file (a file having the extension .avi, .mkv or .mpeg) The name of the movie is extracted from the directory name, not the file name.

Examples:
├── temp
│   ├── Capitalism.A.Love.Story
│   │   └── cd1
│   │   └── movie.avi
│   ├── Home.tt1014762
│   │   ├── imdb.html
│   │   ├── imdb.info
│   │   └── movie.dvdrip.avi
│   ├── Religuous.tt0815241
│   │   ├── imdb.html
│   │   ├── imdb.info
│   │   └── moviefile.avi
│   ├── stuff
│   │   └── nothinghere.txt
│   └── Tapped.tt1344784
│   ├── file.avi
│   ├── imdb.html
│   └── imdb.info

movies.py -p temp will identify the following directories as movies: “Home.tt1014762″, “Religuous.tt0815241″, Tapped.tt1344784 and “Cd1″
“Cd1″ is only a subdirectory but is seen as a movie because there is one movie file inside it.
You will have to move the movie.avi file from inside “Cd1″ to it’s parent, so that “Capitalism.A.Love.Story” will be recognized as a movie name.
If your movie is not properly identified on imdb, you may rename the directory and add the imdb movie id to it, e.g., “Capitalism.A.Love.Story.tt1232207″ or “Capitalism.A.Love.Story.1232207″

In order to use movies.py, you will need a couple of things:
1. Python 2.6 on a Linux machine (I have Ubuntu 10.04)
2. imdbpy library available
sudo pip install imdbpy
OR
sudo easy_install imdbpy
3. prettytable library
sudo pip install prettytable
OR
sudo easy_install prettytable

Download the script on your machine and execute:
# A) this will make your script executable
chmod +x yourusername
# B1) use an alias to run the ‘movies’ script from anywhere
alias movies=”/your/path/to/movies.py”
# B2) alternatively, you can make use of symbolic links
sudo ln -s /your/path/to/movies.py /usr/local/bin/movies.py

Examples of how to use the script, in case you have put movies.py somewhere in your PATH (method B2)

scan and refresh movies from inside the path “/home/elmo/Movies”. In case you don’t use “-p”, the default path is stored in the script variable DEFAULT_MOVIES_PATH (defined inside the script code)
movies.py -p “/home/elmo/Movies” -s -r

show movies with “Andy Serkis” but not with “Brad Pitt”
movies.py -l -a “+andy serkis,-brad pitt”

movies with at least one of these actors playing
movies.py -l -a “?andy serkis,?angelina jolie”

movies with at least one favorite actor playing
movies.py -l -o actor

comedy movies but no dramas
movies.py -l -g “+comedy,-drama”

movies made by “lionsgate” production company
movies.py -c “lionsgate”

movies made by any of the favorite production companies
movies.py -o company

There are a couple of ‘predefined’ filters.
For example, in the script’s code you will see a large list of (good) actors. If you want to find movies where at least one favorite actor is playing, run:
movies.py -o actor
The same is true for production companies
movies.py -o company

Example of output:
movies.py -l -g “+documentary,-drama”
+———+———–+——————–+——+———————+
| Imdb ID | Movie | Genres | Rate | Basename |
+———+———–+——————–+——+———————+
| 1014762 | Home | documentary | 8.4 | Home.tt1014762 |
| 0815241 | Religuous | documentary,comedy | 7.8 | Religuous.tt0815241 |
| 1344784 | Tapped | documentary | 6.8 | Tapped.tt1344784 |
+———+———–+——————–+——+———————+

View the whole list of options using:
movies.py -h
OR
movies.py –help

I hope you will enjoy the script and stay tuned for updates :)

Download here

Ubuntu Lucid VPS hosting

Posted July 16th, 2010 in Ubuntu by Florentin

Virtual Private Server (VPS) vs Shared web hosting

Virtual Private Server (VPS)

Shared Hosting

Pro

high level of control, root access, has it’s own IP(s) and system libraries

faster than the counterpart shared host (same price category)

install and configure any software and service (as long as you respect the seller’s terms of service)

guaranteed and configurable hardware resources, upgrades are possible

unlimited number of domains, sql databases, services, etc

resell hosting services

cheap unmanaged VPS providers are available (2)

several operating system to choose from

simplicity and easy to use, suitable for small sites

control panels availables, easy to setup domains, emails, user and ftp accounts, mysql databases

some hosts offer automatic backups, a necessity for the web businesses

usually the number of domains allowed is limited, number of sql databases restricted

if purchasing an unique IP is not possible, your sites will be found on the same IP as many more others which might affect SEO if you are in a ‘bad neighborhood’

cheap (3)

Con

often hacker attacks, daily port scans

requires more time and energy from you

Managed VPS
expensive

UnManaged VPS

you are responsible for the server administration and security, installing security updates, upgrading your software

usually bad support,

overselling happen often, which means too many hosts sharing the same CPU power, too many using the same connection, etc

less resources available even if the hosting have ‘unlimited resources’ advertised (1)

low level of control, pre-configured services

usually no ssh access which prevents you from using softare versioning systems, install custom libraries, etc

difficult to secure completely because multiple users access the same system

quite a few bits of downtime

(1) Unlimited bandwidth is actually limited to the type of connection you have. On a 10baseT port, if you sustained 10 mbps for 30 days you would move 3200 GB’s of data. Shared hosts will probably limit you to a much lower port speed.
Unlimited disk space has it’s own limitations. Most hosts won’t let you store files which have nothing to do with your sites, like backup files, your private photos, etc.
Your CPU access is limited, speed and processes CPU usage and time is also limited. For example, Dreamhost sometimes doesn’t let me zip some larger directories because the zip process use too much CPU.
(2) My recommendation is www.dmehosting.com I have tried agnihost.com (which seems to be a virpus.com reseller) and burst.net before.
(3) I have been a Dreamhost client for 3 years. It stands out by allowing ssh access and python/django + ruby/rails support along with Php and Mysql.

Good to know when buying a VPS

  • Xen virtualization is better than OpenVz
  • test the server’s IP from the area where you get the most traffic on your sites
  • get as much RAM as your budget allows
  • 10Mbps unmetered or 3200GB bandwidth? Choose the 3200GB package if it’s on a 100baseT port. If it’s a 10baseT port either way, 10Mbps allows a maximum of 3200GB transfered in a month.
  • search for special offers on forums, www.webhostingtalk.com is very good
  • there are free alternatives to control panels like CPanel and Plesk. I am using webmin.com
  • find some reviews on the service/company you are interested in. Stay away from those who generally made a bad impression to users.
  • don’t go with the cheapest VPS, i learned that from experience :) A well established company will offer higher uptime, better support, more services.
  • i like HyperVM better than SolusVM
  • see if you can find out details about the CPU power offered with the package, unamanged VPS sellers usually advertise only ‘equally shared CPU’
    My first VPS had an AMD Opteron 270 which gave low benchmark scores. Currently, dmehosting is offering me i7 CPU 920 @ 2.67GHz, 4 cores
  • 32 bit operating system consumes less memory than the 64 bit equivalent.

My setup

  • I went with dmehosting.com after trying a virpus.com reseller and burst.net
  • my hardware setup is similar to VPS 3, with the few customizations.
  • the operating systems selection is large, I went with Ubuntu Lucid 10.04 32 bit because I use Ubuntu for both my desktop and laptop computer, 32 bit consumes less memory and Ubuntu Lucid is Long Term Support (LTS)
  • webmin.com control panel, allows you to control most aspects of the VPS (apache, mysql, postfix, logs, etc)
  • http://webmin.com/virtualmin.html for managing the domains and users
  • http://www.configserver.com/cp/csf.html was my chosen firewall because of the integration with webmin and easy to use interface
  • zend server community edition (Php 5.2) because some of my sites don’t work with Php 5.3 (which comes default with Ubuntu Lucid 10.04)
  • server hardening operations.
    Find good server hardening here:
    http://delicious.com/search?p=server%20hardening&u=&chk=&context=main&fr=del_icio_us&lc=0
    http://delicious.com/florentin/hardening

Why dmehosting worked fine for me

  • affordable prices
  • use their own DNS servers
  • choose from several server locations
  • great CPU power, uptime, connection speed for the price you pay
  • good customer support so far (only used twice, other people complain about the support)
  • hardware configuration flexibility
  • good presence on the webhostingtalk forum

Cheap unmanaged VPS services

  • http://www.dmehosting.com/budget-linux-vps.php – I am happy customer there :)
  • https://www.burst.net/linvps.shtml
  • http://www.webhostingtalk.com/showthread.php?t=956901
  • http://www.webhostingtalk.com/showthread.php?t=956764
  • http://hostlatch.net/vps.html
  • https://secure.hazenet.co.uk/cart.php
  • https://www.2host.com/support/cart.php
  • http://www.webhostingtalk.com/showthread.php?t=958605
  • http://www.neutrino.us/en-us/services/vserver/default.aspx

Find the latest VPS offers

  • http://www.webhostingtalk.com/forumdisplay.php?f=104
  • http://www.lowendbox.com

Find VPS benchmark scores

  • http://www.dmehosting.com/forums/showthread.php?172-Post-your-VPS-Benchmark
  • http://www.webhostingtalk.com/showthread.php?t=924581

Zend Server Community Edition on Ubuntu

Posted July 16th, 2010 in Php, Ubuntu by Florentin

What is Zend Server CE (Community Edition)

You can think of Zend Server as a bundle of software and Php modules.
For Linux, ZSCE has it’s own php-*-zend-server packages which replace the ones offered by the host Os, usually php5-*
ZSCE automatically installs lighttpd-zend-server used for the web-based administration.

Why to use Zend Server CE

  • Easy to start with specially useful for Php newcomers
  • Production-ready, integrated PHP stack for non-critical applications
  • PHP bytecode caching (Zend Optimizer+) – increases performance with no application changes
  • Data caching – a set of functions that allow developers to cache data in shared memory or to disk )
  • Zend Debugger available out of the box but possible to disable it and install Xdebug
  • Available on Windows, Linux and Mac
  • All in one install taking care of all the dependencies and needed libraries
  • Integrated administration console for setting up Apache and Php configurations
  • Free (the CE version) and supported by Zend which takes care of bug fixes and future improvements
  • Easy way to install Php 5.2 on Ubuntu Lucid or other distros which offer Php 5.3 by default
  • Easy to uninstall with no traces left on the system
  • Ability to install both Php 5.2 and Php 5.3 on the same system as described here http://ireallylikesushi.com/blog/2009/12/21/installing-both-zend-server-ce-php-5-2-php-5-3-on-snow-leopard/

Sources

http://www.zend.com/en/products/server-ce/

http://devzone.zend.com/article/4295

Installation (Ubuntu Lucid 10.04)

echo deb http://repos.zend.com/zend-server/deb server non-free > /etc/apt/sources.list.d/zend.list
wget http://repos.zend.com/deb/zend.key -O- | sudo apt-key add -
apt-get update
apt-get install zend-server-ce-php-5.2 # for Php 5.2
apt-get install zend-server-ce-php-5.3 # for Php 5.3

Please find the official installation details here:

http://files-source.zend.com/help/Zend-Server-Community-Edition/zend-server-community-edition.htm#deb_installation.htm

Installing Xdebug on Zend Server (an alternative to Zend Debug)

Option 1 (recommended)
# get archive, configure and compile it. First check the latest version on xdebug.org
wget http://www.xdebug.org/files/xdebug-2.1.0.tgz # replace it with the latest version
tar -xzf xdebug-2.1.0.tgz
cd xdebug-2.1.0/
/usr/local/zend/bin/phpize
./configure --enable-xdebug --with-php-config=/usr/local/zend/bin/php-config
make


# move the xdebug.so somewhere on the server
cp modules/xdebug.so /work/xdebug/xdebug.so
# edit zend-server's php.ini to enable xdebug
sudo gedit /usr/local/zend/etc/php.ini
# add to the end of the file
zend_extension=/work/xdebug/xdebug.so


# optionally, add some xdebug directives to that php.ini
[xdebug]
xdebug.profiler_output_dir = /tmp
xdebug.profiler_enable_trigger = 1
xdebug.remote_enable=1
xdebug.remote_host=localhost

xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.var_display_max_data=10000
xdebug.var_display_max_depth=20

Option 2

ZSCE comes with a package named php-5.2-xdebug-zend-server. At this moment, the Xdebug version offered by ZSCE is older (2.0.4) than the official one (2.1.0)

# install xdebug.so in /usr/local/zend/lib/php_extensions/
apt-get install php-5.2-xdebug-zend-server
# Add the following line to /usr/local/zend/etc/php.ini
zend_extension=/usr/local/zend/lib/php_extensions/xdebug.so
# You may also add the xdebug directives described in Option 1.

Controlling Zend Server

# show all commands
sudo /usr/local/zend/bin/zendctl.sh -h

# restart zend server, including apache server and lighttpd server
sudo /usr/local/zend/bin/zendctl.sh restart

The end

# My bookmarks regarding Zend Server

http://delicious.com/florentin/zend-server

# Other bookmarks

http://delicious.com/search?p=zend%20server&u=&chk=&context=main&fr=del_icio_us&lc=0

Chuck Norris Programming facts

Posted March 16th, 2010 in Funny by Florentin
  • The system works because Chuck Norris tells it to work
  • Chuck Norris doesn’t need a test suite. The test suite needs Chuck Norris.
  • CPUs run faster to get away from Chuck Norris
  • Chuck Norris normalizes all schema just by inserting random data
  • Packets travel faster than the speed of light for Chuck Norris, but he can still catch them
  • Chuck Norris’s brain is his revision control, and it works better than git
  • Chuck Norris can finish an infite loop in 1.3 seconds.
  • Code written by Chuck Norris cannot be optimized.
  • Chuck Norris never dies.  He simply returns 0.
  • Chuck Norris can break Moore’s Law
  • Chuck Norris doesn’t need compilers nor editors. He roundhouse kicks the disk and the bytecode appears.
  • Chuck Norris doesn’t use GOTO. Code comes to him.
  • There is no theory of probability, just a list of events that Chuck Norris allows to occur.
  • 90% of the worlds spam is handtyped by Chuck Norris. It takes him only 3 minutes.
  • Chuck Norris can parse invalid XML
  • Every time you don’t use “use strict” Chuck Norris kills a kitty.
  • The best compression algorithm in existence are Chuck Norris fists.
  • Chuck Norris can divide by 0.
  • Chuck Norris can compile syntax errors
  • The one true bracing style is the one Chuck Norris uses.
  • Every program Chuck Norris has written can be run backwards. It will rollback whatever it did.
  • No matter how you encrypt your traffic, Chuck Norris can read it by just looking at the cable. His ears can intercept wifi transmissions.
  • Chuck Norris can enrich himself simply by hacking your bank account. He does not do this because there is no challenge in it.
  • MVC actually stands for Model-View-ChuckNorris. Controller is just one of his nicknames.
  • Chuck Norris was written in C# which itself was written in Chuck Norris
  • You don’t follow Chuck Norris on Twitter. He follows you, finds you, and kills you
  • The design of Silverlight DeepZoom was directly inspired by Chuck Norris’ powers of bionic vision.
  • Chuck Norris doesn’t write code…oh no, he thinks about the finished product and the code appears.
  • Chuck Norris has no need for virtual methods. Nothing can override Chuck Norris.
  • A synchronize operation doesn’t protect against Chuck Norris, if he wants the object, he takes it.
  • Chuck Norris invented recursion to see what would happen if he roundhouse kicked himself.
  • Chuck Norris can multi-thread on a single processor by breaking it into pieces.
  • Chuck Norris wrote a program that calculated the last digit of pi.
  • Chuck Norris’ compiler is afraid of displaying warnings to him. It just fixes the code automatically.
  • Chuck Norris uses Vista with UAC turned on. He has received no warnings. Ever.
  • Chuck Norris monitor has no glare…no-one glares at Chuck Norris.

El cartel rules

Posted March 15th, 2010 in Uncategorized by Florentin

1. You can’t succeed unless you try.

2. Always have an exit strategy.

3. When you’ve got the right strategy, execute.

4. There’s no such thing as a once in a lifetime opportunity.

5. When you discover you’ve executed the wrong strategy, stop.

6. Follow your passion.

7. Don’t ignore your problems.

8. The most valuable asset in any venture is thought.

9. Success begins by surrounding yourself with quality people.

10. Opportunity is a liability, not an asset.

11. Never ignore the signs.

12. Success comes by doing many things right, over a very long time.

13. Success is never guaranteed.