Skip to content

Instantly share code, notes, and snippets.

View ismaild's full-sized avatar
🥊
Building Things...

Ismail Dhorat ismaild

🥊
Building Things...
View GitHub Profile
@ismaild
ismaild / virtualenv_bootstrap.py
Created October 26, 2010 23:45
Include this in your call to create a virtualenv bootstrap script.
import glob
def get_ordered_files(path):
f = []
for ifile in glob.glob( os.path.join(path,"requirements", '*.txt') ):
if ifile.find("local")>-1:
f.append((0,ifile))
elif ifile.find("required")>-1:
--- Event Type
|----Metric
|---- Graph Hourly
For example:
--- VO EVENT
|---- Value Graph
|----- Hourly trend + previous 3 days
|---- Events Graph
@ismaild
ismaild / helloworld.py
Created August 26, 2011 12:55
Hello World
print "Hello World"
print "Welcome to Our Blog"
@ismaild
ismaild / jse_share_data.py
Created January 7, 2012 17:05
Grab Data from Moneyweb, send you an alert (via prowl)
import urllib2
import prowl
from BeautifulSoup import BeautifulSoup
from random import choice
import time
import pdb
user_agents = [
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 (.NET CLR 3.5.30729)',
@ismaild
ismaild / soundex.pl
Created January 20, 2012 13:06
Soundex Perl Example
sub soundex
{
local (@s, $f, $fc, $_) = @_;
push @s, '' unless @s; # handle no args as a single empty string
foreach (@s)
{
tr/a-z/A-Z/;
tr/A-Z//cd;
@ismaild
ismaild / fbsearch.py
Created February 7, 2012 08:16
Search Facebook Graph API for specific string and write to CSV
#!/usr/bin/env python
# encoding: utf-8
"""
fbsearch.py
ismail@zyelabs.net
"""
import facepy
import csv
fieldnames = [u'category', u'name', u'id']
@ismaild
ismaild / process_images.py
Created February 23, 2012 12:27
Crop, Resize & Convert Images
import os
from PIL import Image
from glob import glob
pwd = os.path.dirname(os.path.abspath(__file__))
ext = '.png'
ext_new = '.jpg'
fpath = os.path.join(pwd,'*'+ext)
img_list = glob(fpath)
left = 450
@ismaild
ismaild / get_products.py
Created February 23, 2012 14:44
get_products template tag for django >mezzanine > cartridge (Work in progress)
from django import template
from django.db.models import get_model
register = template.Library()
class ProductContentNode(template.Node):
def __init__(self, num, varname):
model = 'shop.Product'
self.num = int(num)
self.num_check = num*4
@ismaild
ismaild / test.py
Created June 13, 2012 17:49
testing mitmproxy
#!/usr/bin/env python
"""
Testing
"""
from libmproxy import controller, proxy
import os
class ModifyMaster(controller.Master):
def __init__(self, server):
controller.Master.__init__(self, server)
@ismaild
ismaild / data.csv
Created July 4, 2012 13:44
MongoDB Schema Design
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 29 columns, instead of 7. in line 7.
SERIAL,TIMESTAMP,CUSTOMER_ID,RESERVED01,PRODUCT_ID,CUSTOMER_TYPE,CUSTOMER_STATE,ChargeAmount_OF_UNITS,ChargeAmount_OF_FUND,ChargeAmount_FROM_ACCOUNT1,ACCOUNT1_BALANCE,ChargeAmount_FROM_ACCOUNT2,ACCOUNT2_BALANCE,WalletType1,UnitType1 ,ChargeAmount1 ,WalletBalance1 ,WalletType2,UnitType2 ,ChargeAmount2 ,WalletBalance2 ,WalletType3,UnitType3 ,ChargeAmount3 ,WalletBalance3 ,Bonus1 ,Bonus2 ,Bonus3 ,AddtionaInfo
379120186,20120701235122,1345567,0,555,0,1000000,0,0,5,664,0,0,200,1,5,664,0,0,0,0,0,0,0,0,,,,1234
379120190,20120701235124,1345568,0,1,0,1000000,0,0,4,108,0,0,200,1,4,108,0,0,0,0,0,0,0,0,,,,
379120197,20120701235132,1345569,0,4,0,1000000,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,,
379120203,20120701235136,1345570,0,1,0,1000000,0,0,0,346,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,,XXX
379120207,20120701235138,1345571,0,10,0,1000000,0,0,0,0,3,100,200,1,3,100,500,2,10,0,610,2,20,80,10,,,
379120208,20120701235138,1345571,0,1,0,1000000,0,0,3,306,0,0,200,1,3,306,0,0,0,0,0,0,0,0,,,,
379120211,20120701235141,1345573,0,1,0,1000000