Skip to content

Instantly share code, notes, and snippets.

@pankaj28843
pankaj28843 / xvfb.sh
Created Feb 11, 2015
Run xvfb on display 99 as a service
View xvfb.sh
#!/bin/bash
# Description: Starts xvfb on display 99
if [ -z "$1" ]; then
echo "`basename $0` {start|stop}"
exit
fi
case "$1" in
@pankaj28843
pankaj28843 / low-battery-notification.sh
Last active Aug 29, 2015
Sends a notification if laptop battery is lower than a minimum level
View low-battery-notification.sh
#!/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]*$//');
View price_alert_flipkart.py
#!/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 / README.md
Created Nov 13, 2014
Get links shared by someone on Twitter in your Pocket App
@pankaj28843
pankaj28843 / extract_links_from_a_tweet.py
Created Nov 10, 2014
Extract Links for a particular Tweet, given absolute URL
View extract_links_from_a_tweet.py
@pankaj28843
pankaj28843 / README.md
Last active Aug 29, 2015
MATLAB R2014a Desktop Shortcut
View README.md

Run following command:

curl https://gist.githubusercontent.com/psjinx/526f32b69c0655624b87/raw/setup.sh | sh
View parallelize.py
# 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()
View get_price_from_amazon.py
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):
@pankaj28843
pankaj28843 / set_outer_border_for_range_xlsx.py
Last active May 28, 2021
A simple hack - set outer border for a range using xlsxwriter, a Python library
View set_outer_border_for_range_xlsx.py
from __future__ import absolute_import
try:
import cStringIO as StringIO
except ImportError:
import StringIO
# Standard Library
import re
import string
View burst_pdffile.py
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)