Skip to content

Instantly share code, notes, and snippets.

@ojas
ojas / Requirements Cat PS1 Reverse Zeno
Created March 28, 2013 14:49
Requirements Cat: PS1: Reverse Zeno Paradox
<sharmaskarma> how can we build before we know the requirement
<sharmaskarma> KNOW THE REQUIREMENT
<ojas> how can you really know the requirement? it's like reverse zeno's
paradox.... you know you must end up at a requirement (at t1), but when you
start (t0) you have no requirement. there must be some point between t0 and t1
where half of the requirement is known, and between t0 and that point where one
half of one half of the requirement is known, and so on...
<ojas> but not matter how far you go back, you can never start w/ zero
requirement. hence, it's impossible to even get a single requirment defined.
QED
@ojas
ojas / gist:5489837
Created April 30, 2013 16:22
csvkit examples
csvsql --db sqlite+pysqlite:///test.db -e iso-8859-1 --insert ./test-file-209.csv
@ojas
ojas / with-blocks.py
Created August 9, 2013 21:34
with-blocks in python
class MyClass():
def __init__(self, *args, **kwargs):
print '>> init'
self.label = kwargs.get('label')
def __enter__(self):
print ' >> enter'
return self
def __exit__(self, type, value, traceback):
@ojas
ojas / bir.py
Created August 20, 2013 19:04
Get BIR report from D&B Direct 1.x API
#!/usr/bin/python
"""
Usage:
python bir.py <duns_number>
"""
import sys
import requests
import traceback
@ojas
ojas / requirements.txt
Last active December 23, 2015 07:29
Hoover's API Snippets
suds==0.4
wsgiref==0.1.2
#!/usr/bin/env python
import sys
import json
CHUNK_SIZE = 500
def chunks(l, n):
""" Yield successive n-sized chunks from array l
"""
@ojas
ojas / resize
Created September 20, 2013 17:40
ImageMagick tips
convert Sreeni3.png -resize 600x400 -gravity Center -crop 400x400+0+0 +repage sreeni.jpg
@ojas
ojas / duns.txt
Created September 22, 2013 15:59
Example DUNS
214567885
247933872
302150912
362241452
362328580
362528379
364744867
481794956
654502665
754683795
@ojas
ojas / import-export
Last active December 24, 2015 00:58
MongoDB tips
# Load a MongoDB collection with test data
## Let's load some sample data in mongo
curl -s 'http://www.json-generator.com/j/cdQGOkHUoi?indent=4' | mongoimport --db playpen --collection people --jsonArray
mongo playpen
## Create facets based on this [walkthru](http://blog.mongodb.org/post/59757486344/faceted-search-with-mongodb)
db.people.ensureIndex({"facets3.age" : 1})