Skip to content

Instantly share code, notes, and snippets.

@iambibhas
iambibhas / rom_clean_install_steps.txt
Created May 3, 2013 16:27
Steps to clean install Android ROMs
Format system
Format data
Format cache
Wipe data
Wipe cache
Wipe Dalvik cache
Install Rom!
@iambibhas
iambibhas / date_regex.txt
Created May 5, 2013 20:02
Regex to match a date in the format YYYY-MM-DD
(19|20)([0-9][0-9])\-(0[1-9]|1[0-2])\-(0[1-9]|1[0-9]|2[0-9]|3[0-1])
@iambibhas
iambibhas / copy_selected.sh
Created May 13, 2013 15:46
Copy only listed files to somewhere
FILENAME=$1
while read LINE
do
cp "$LINE" ./destination-folder/
done < $FILENAME
@iambibhas
iambibhas / fab_upload_tar.py
Last active December 5, 2018 18:04
Deploy only changed files from last deployed commit using Fabric
def upload_tar():
# First, get the last deployed commit's short hash. 1st time, just create the file manually.
last_deployed = local('cat last_deployed', capture=True)
# get the last commit's short hash
current_commit = local('git rev-parse --short HEAD', capture=True)
# get the list of changed files since last deployed commit, put them in a tgz file, named as the commit to be deployed.
local('git archive --format tar HEAD $(git diff --name-only HEAD %s) | gzip -9 > %s.tgz' % (last_deployed, current_commit))
# put the .tgz file to server, in project's archive/ directory
put('%s.tgz' % current_commit, '%s/archive/' % env.path)
# move the local file inside the archive/ directory, so the root is clean
@iambibhas
iambibhas / commands.sh
Created May 17, 2013 14:03
Adding JPEG, PNG, ZIP and FREETYPE2 support to PIL
sudo apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
pip install PIL
@iambibhas
iambibhas / nginx.log
Last active December 17, 2015 13:29
Nginx configs to read about later for static files
# This block will catch static file requests, such as images, css, js
# The ?: prefix is a 'non-capturing' mark, meaning we do not require
# the pattern to be captured into $1 which should help improve performance
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
# Some basic cache-control for static files to be sent to the browser
expires max;
# Does the same as Cache-Control: public
add_header Pragma public;
@iambibhas
iambibhas / pylibmc.sh
Created June 10, 2013 06:27
Errors with PyLibmc
# Error: _pylibmcmodule.h:42:36: fatal error: libmemcached/memcached.h: No such file or directory
# install these
sudo apt-get install -y libmemcached-dev zlib1g-dev libssl-dev python-dev build-essential
@iambibhas
iambibhas / git_based_deploy.sh
Created June 23, 2013 18:05
One-liner git based deployment command
echo "cd /mnt/project_name_beta/;git pull origin dev;sudo supervisorctl restart project_name" | ssh -i ~/Works/keys/project_name.pem [email protected]
@iambibhas
iambibhas / copy_db.sql
Created July 11, 2013 13:03
PostgreSQL Copy a Database
# Execute this from a user who has permission to create database
CREATE DATABASE newdb WITH TEMPLATE originaldb OWNER dbuser;
@iambibhas
iambibhas / vital_packages.sh
Created July 28, 2013 18:39
My list of packages to install when setting up local machine
sudo aptitude install nginx python-dev libmysqlclient-dev libmemcached-dev zlib1g-dev libssl-dev python-dev build-essential libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev rubygems python-setuptools chromium-browser postgresql mysql-server terminator postgresql-server-dev-9.1 curl git mercurial