Skip to content

Instantly share code, notes, and snippets.

@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})
@ojas
ojas / people.json
Created September 27, 2013 16:28
Sample JSONs
[
{
"picture": "http://placehold.it/32x32",
"about": "Do do reprehenderit quis ipsum sit esse quis occaecat culpa enim excepteur. Consectetur deserunt pariatur laboris mollit eiusmod nulla exercitation nulla et aute aliqua commodo. Laboris irure ut cupidatat qui. Ut ut adipisicing cupidatat nisi sunt ipsum reprehenderit ullamco eiusmod incididunt sunt ullamco veniam tempor. Commodo reprehenderit tempor amet incididunt ea ea deserunt minim ex aliqua consectetur.\r\n",
"balance": "$1,651.00",
"name": "Hardy Davis",
"randomArrayItem": "cherry",
"phone": "+1 (881) 441-2106",
"gender": "male",
"age": 24,
[
["Days", "Orders", "Items ", "AOV", "Average Item/Order"],
["14-Dec-13", 45, 90, 45, 2],
["15-Dec-13", 15, 40, 23, 2.5]
]
@ojas
ojas / dnb_envs.py
Last active December 28, 2015 06:29
lulz
def enum(**enums):
return type('Enum', (), enums)
WORDS = enum(PARTIAL = 1, SANDBOX = 2, SCRAMBLED = 4, LEGACY = 8, PRODUCTION = 16, TRUNCATED = 32)
envs = {
'http://api.dnbdirectapps.com/dev/' : WORDS.SANDBOX + WORDS.PARTIAL + WORDS.SCRAMBLED + WORDS.TRUNCATED,
'http://dnbdirect-sandbox.dnb.com/' : WORDS.SANDBOX + WORDS.SCRAMBLED + WORDS.LEGACY,
'http://dnbdirect-api.dnb.com/' : WORDS.PRODUCTION,
}
@ojas
ojas / refresh_css.txt
Created September 19, 2016 16:43
Hacks
// run this in your console…
(function(){
var nc = (new Date()).valueOf();
jQuery('style').each(function() {
var c = this.innerHTML;
if (c.indexOf('@import')!==-1)
this.innerHTML = c.replace('.css?', '.css?' + nc );
});
})();