Skip to content

Instantly share code, notes, and snippets.

@pankaj28843
pankaj28843 / runinenv.sh
Created June 4, 2014 09:25
run a command inside virtualenv
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
shift 1
echo "Executing $@ in ${VENV}"
exec "$@"
import sys
from zipfile import ZipFile
from StringIO import StringIO
from PyPDF2 import PdfFileReader, PdfFileWriter
def burst_pages_of_pdf_file(pdf_file):
zipped_output = StringIO()
with ZipFile(zipped_output, 'w') as ziparchive:
pdf_file.seek(0)
import re
import requests
from lxml import etree
REGEX_FIND_NUMBER = re.compile(r'\d*\.\d+|\d+')
REGEX_FIND_COMMA = re.compile(r'\s*,\s*')
def get_price_from_text(text):
# Standard Library
import multiprocessing
DEFAULT_PROCESSES_COUNT = int(round(1.5 * multiprocessing.cpu_count()))
def spawn(f):
def fun(q_in, q_out):
while True:
i, x = q_in.get()
@pankaj28843
pankaj28843 / README.md
Last active August 29, 2015 14:09
MATLAB R2014a Desktop Shortcut

Run following command:

curl https://gist.githubusercontent.com/psjinx/526f32b69c0655624b87/raw/setup.sh | sh
@pankaj28843
pankaj28843 / extract_links_from_a_tweet.py
Created November 10, 2014 04:47
Extract Links for a particular Tweet, given absolute URL
@pankaj28843
pankaj28843 / README.md
Created November 13, 2014 07:55
Get links shared by someone on Twitter in your Pocket App
@pankaj28843
pankaj28843 / low-battery-notification.sh
Last active August 29, 2015 14:14
Sends a notification if laptop battery is lower than a minimum level
#!/bin/sh
while true;
do
# Minimum battery level in percentage.
# If remaning battery percentage is less than this then a notification will be shown.
MINIMUM_LEVEL=50;
# Determine battery status
BATTERY_STATUS=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state" | sed -E 's/state://' | sed 's/^[ \t]*//;s/[ \t]*$//');
@pankaj28843
pankaj28843 / xvfb.sh
Created February 11, 2015 07:44
Run xvfb on display 99 as a service
#!/bin/bash
# Description: Starts xvfb on display 99
if [ -z "$1" ]; then
echo "`basename $0` {start|stop}"
exit
fi
case "$1" in
@pankaj28843
pankaj28843 / README.md
Last active August 29, 2015 14:27
Embedding images in tex file as base64 strings?

Credits: Based on http://tex.stackexchange.com/a/208824/24794

Compile .tex file using following command:

# Increase buffer size to support large images
# Setting the environment variable to a higher value works here
export buf_size=99999999999