Skip to content

Instantly share code, notes, and snippets.

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)
@pankaj28843
pankaj28843 / set_outer_border_for_range_xlsx.py
Last active September 1, 2022 21:48
A simple hack - set outer border for a range using xlsxwriter, a Python library
from __future__ import absolute_import
try:
import cStringIO as StringIO
except ImportError:
import StringIO
# Standard Library
import re
import string
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 / price_alert_flipkart.py
Created December 18, 2014 10:51
price alert flipkart
#!/usr/bin/python2.7
import re
import requests
from envelopes import Envelope, SMTP
from lxml import etree
from splinter import Browser
REGEX_FIND_NUMBER = re.compile(r'\d*\.\d+|\d+')
@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