Skip to content

Instantly share code, notes, and snippets.

@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 / parse_youtube_urls.py
Created February 26, 2012 18:00
Download multiple youtube videos at once
# -*- coding: utf-8 -*-
from BeautifulSoup import BeautifulSoup
input_file = file('input.txt')
soup = BeautifulSoup(input_file.read())
for a in soup.findAll('a'):
if 'watch?v=' in a['href']:
print 'http://www.youtube.com'+a['href']
java -cp /opt/Multivalent.jar tool.pdf.Compress /tmp/5dd69f32-b97b-4f43-9bfa-f182e972f6ef.pdf
@pankaj28843
pankaj28843 / api.py
Last active December 18, 2015 03:59
So, you want to create users using django-tastypie
from django.contrib.auth.models import User
from django.contrib.auth.hashers import make_password
from tastypie.authentication import (
Authentication, ApiKeyAuthentication, BasicAuthentication,
MultiAuthentication)
from tastypie.authorization import Authorization
from tastypie.resources import ModelResource
from tastypie import fields
@pankaj28843
pankaj28843 / app.js
Created August 6, 2013 06:10
Using SessionAuthentication of django-tastypie with AngularJS for POST/PUT/DELETE
'use strict';
angular.module('App', ['ng', 'ngCookies', 'ngResource']);
angular.module('App').run(function($rootScope, $http, $cookies) {
$http.defaults.headers.common['X-CSRFToken'] = $cookies.csrftoken;
});
@pankaj28843
pankaj28843 / pnr-beep-beep.sh
Last active December 29, 2015 10:19
Go beep-beep-beep-beep-beep when Railway Chart is prepared for your PNR
while true;
# echo date/time
date;
do
# make a post request to Indian Railways PNR Enquiry page and search for "CHART NOT PREPARED"
if curl --silent -X POST -d "lccp_pnrno1=$1&submitpnr=Get+PNR+Status" http://www.indianrail.gov.in/cgi_bin/inet_pnrstat_cgi.cgi | grep "CHART PREPARED"
then
# Chart prepared :)
echo "Chart prepared. \n\n";
@pankaj28843
pankaj28843 / profiler.py
Created January 6, 2014 12:21
Django view profiler - a decorator function to profile your code
import hotshot
import os
import time
from django.conf import settings
import tempfile
try:
PROFILE_LOG_BASE = settings.PROFILE_LOG_BASE
except:
PROFILE_LOG_BASE = tempfile.gettempdir()
@pankaj28843
pankaj28843 / india-data-visualization-google-map.html
Created May 3, 2014 07:34
India data visualization google map
<html>
<head>
<script type='text/javascript' src='http://www.google.co.in/jsapi'></script>
<script>
google.load('visualization', '1', {
'packages': ['geomap']
});
google.setOnLoadCallback(drawMap2);
@pankaj28843
pankaj28843 / aes_cipher.py
Created July 28, 2015 12:03
Encrypt & Decrypt using PyCrypto AES 256
'''
Based on Stackoverflow Answer: http://stackoverflow.com/a/12525165/353550
'''
import base64
from Crypto.Cipher import AES
from Crypto import Random
BS = 16
@pankaj28843
pankaj28843 / example.html
Last active March 9, 2017 17:45
A hack to open links in new window or parent in a published Google Doc which is embedded as iframe. Demo at https://cdn.rawgit.com/psjinx/1f2317a50eb2b506ed84/raw/example.html
<!DOCTYPE html>
<html>
<head>
<title>psjinx's Resume</title>
</head>
<body>
<iframe id="google-doc-iframe" srcdoc="" style="height: 1050px; margin: 0 auto;" align="middle" frameborder="0" width="100%" height="100%" scrolling="no">
</iframe>