Skip to content

Instantly share code, notes, and snippets.

View imran31415's full-sized avatar

Imran Hassanali imran31415

View GitHub Profile
package bench
import (
"testing"
)
type Item struct {
Position int
name string
IsPin bool
import csv
import json
import sqlite3
from sqlite3 import Error
import csv
import datetime
'''Assumes there is a file resumes.json in the path with the input data.
1. Load input data and flatten it into list
#python 2.7+, 3
def get_subsets_recursive(l, c=0):
"""
Recursivemethod
l is the set of items to get all combination subsets
c is to track recursion depth for visibility
"""
c+=1
#end recursion loop once at the end of the list
from lxml import html
import json
import requests
from exceptions import ValueError
import re, urllib
import urllib3
import argparse
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from requests.packages.urllib3.exceptions import InsecureRequestWarning
import mailbox
import email.utils
from mboxparse import convert_to_json
filename = "metadatatest2525.mbox"
#the following returns a list containing message objects. Each message objects is composed of the components listed on line 20.
mbox = mailbox.mbox(filename)
import sys
import mailbox
import email
import quopri
import json
from BeautifulSoup import BeautifulSoup
def cleanContent(msg):
@imran31415
imran31415 / tutorialbuilder.py
Created November 28, 2015 03:32
A python script to build web page tutorial templates based on JSON data
import pprint
MANUAL_TEMPLATE = {
"title": "",
"header": "",
"warning": "Please make sure you have the following setup before starting",
"requirements":[],
"setup":
@imran31415
imran31415 / torproxy.py
Created April 28, 2015 22:28
Torproxy.py
import os
from selenium import webdriver
import subprocess
ff_prof = webdriver.FirefoxProfile()
#set some privacy settings
ff_prof.set_preference( "places.history.enabled", False )
ff_prof.set_preference( "privacy.clearOnShutdown.offlineApps", True )
ff_prof.set_preference( "privacy.clearOnShutdown.passwords", True )
ff_prof.set_preference( "privacy.clearOnShutdown.siteSettings", True )
@imran31415
imran31415 / coach_sync.py
Last active August 29, 2015 14:06
This is an example script of a program that uses CSV files for data storage, and every transaction with the program will sync the CSV. upon starting the script, it will look for a CSV file to load data from. 2 way sync: CSV-script Script-CSV
import time
import pprint
import os.path
def list_tocsv(list, filename):
import csv
with open(filename, 'wb') as f:
writer = csv.writer(f)
writer.writerows(list)
@imran31415
imran31415 / example_1.py
Last active August 29, 2015 14:04
orchard
'''
trivial orchard example
exploring multidimensional dynamic data types
'''
def create_orchard():
return {'orchard':[]}
def add_tree_row(orchard, n=1):
for x in xrange(n):
orchard['orchard'].append({'tree_row':[]})