Obfuscating / Hiding Python code


python -OO -m py_compile <your program.py>

Storing your PHP sessions using memcached


sudo apt-get install memcached
sudo apt-get install php5-memcache

and change some of your PHP settings :

sudo nano /etc/php5/apache2/php.ini

session.save_handler = files
; session.save_path = "N;/path"

to :

session.save_handler = memcache
; change server:port to fit your needs...

sudo service apache2 restart

To see if its working:


echo "stats settings" | nc localhost 11211

This shows that the Memcached is now listening on port 11211 with localhost connections only. We will change this to the, catch-all, IP by changing the line: “-l” to “-l” in the file “/etc/memcached.conf”. After changing the config you can see if we can now make a connection from external machines use the following command:

netstat -ln4t | grep :11211

Raspberry PI + Extend SD card life


sudo swapoff --all

You must also prevent it from coming back after a reboot:

  • For Raspbian which uses dphys-swapfile to manage a swap file (instead of a “normal” swap partition) you can simply sudo apt-get remove dphys-swapfile to remove it permanently. Best to remove because setting the CONF_SWAPSIZE to 0, as explained in this answer, doesn’t seem to work and still creates a 100MB swap file after reboot.

Directories in RAM

Highly used directories such as /var/tmp/ and possibly /var/log can be relocated to RAM in /etc/fstab like this:

tmpfs /var/tmp tmpfs nodev,nosuid,size=50M 0 0