Skip to content

Instantly share code, notes, and snippets.

View shahidhk's full-sized avatar

Shahidh K Muhammed shahidhk

View GitHub Profile
@shahidhk
shahidhk / 0_reuse_code.js
Created November 16, 2013 05:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Installation using distribute and pip
NOTE: If you don't want to touch system files or you don't have root, please see this question on stackoverflow. For everyone else please read on...
Install distribute and pip
According to the distribute website setuptools and easy_install are old and busted (the version included in Ubuntu 12.04 doesn't work with python3), and distribute and pip are the new hotness. So we will use those:
curl -O http://python-distribute.org/distribute_setup.py
sudo python distribute_setup.py
sudo easy_install pip
from django.contrib import messages
messages.add_message(request, messages.INFO, 'Hello world.')
# Shortcut way to add messages
messages.debug(request, '%s SQL statements were executed.' % count)
messages.info(request, 'Three credits remain in your account.')
messages.success(request, 'Profile details updated.')
messages.warning(request, 'Your account expires in three days.')
messages.error(request, 'Document deleted.')
import pdfcrowd
try:
# create an API client instance
client = pdfcrowd.Client("username", "apikey")
# convert a web page and store the generated PDF into a pdf variable
pdf = client.convertURI('http://www.google.com')
# convert an HTML string and save the result to a file
import pdfcrowd
from django.http import HttpResponse
def generate_pdf_view(request):
try:
# create an API client instance
client = pdfcrowd.Client("username", "apikey")
# convert a web page and store the generated PDF to a variable
pdf = client.convertURI("http://www.google.com")
@shahidhk
shahidhk / wget_download.sh
Created March 23, 2014 05:33
Download a website using wget
wget --limit-rate=200k --no-clobber --convert-links -r -p -E -e robots=off -U mozilla http://django-notification.readthedocs.org/en/latest/

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@shahidhk
shahidhk / zero_file_delete
Created November 29, 2015 04:24
Delete all files having zero size and six character filenames. Used to fix issue on saarang server
find . -maxdepth 1 -name '??????' -size 0 -delete
#!/bin/bash
set -e
function init_ssl {
mkdir -p /etc/kubernetes/ssl
local TEMPLATE=/etc/kubernetes/ssl/ca.pem
[ -f $TEMPLATE ] || {
echo "TEMPLATE: $TEMPLATE"
mkdir -p $(dirname $TEMPLATE)
cat << EOF > $TEMPLATE