Skip to content

Instantly share code, notes, and snippets.

class Serializer():
"""
Class to provide serialization/deserialization functionality.
Mostly, other class will simple inherit this class to add
serializability functionality
"""
def serialize(self):
return jsonpickle.encode(self)
from datetime import datetime
from dateutil.relativedelta import relativedelta
def get_fancy_time(d, display_full_version = False):
"""Returns a user friendly date format
d: some datetime instace in the past
display_second_unit: True/False
"""
#some helpers lambda's
plural = lambda x: 's' if x > 1 else ''
function freeze_db() {
rc = db.runCommand({fsync: 1, lock: 1});
if (rc.ok == 1){
return 1;
} else {
return 0;
}
}
freeze_db();
ACCESS_KEY='YOUR AMAZON API KEY'
SECRET='YOUR AMAZON SECRET'
BUCKET_NAME='database_backup_bucket' #note that you need to create this bucket first
from boto.s3.connection import S3Connection
from boto.s3.key import Key
def save_file_in_s3(filename):
conn = S3Connection(ACCESS_KEY, SECRET)
bucket = conn.get_bucket(BUCKET_NAME)
#!/bin/sh
MONGODB_SHELL='/opt/mongodb/bin/mongo'
DUMP_UTILITY='/opt/mongodb/bin/mongodump'
DB_NAME='my_db'
date_now=`date +%Y_%m_%d_%H_%M_%S`
dir_name='db_backup_'${date_now}
file_name='db_backup_'${date_now}'.bz2'
#!/bin/bash
RESTORE_UTILITY='/opt/mongodb/bin/mongorestore'
DB_NAME='my_db'
log() {
echo $1
}
import base64
import hashlib
import hmac
import simplejson as json
def base64_url_decode(inp):
padding_factor = (4 - len(inp) % 4) % 4
inp += "="*padding_factor
return base64.b64decode(unicode(inp).translate(dict(zip(map(ord, u'-_'), u'+/'))))
HIRSUTE, http://2.bp.blogspot.com/_Pxd0QZ3r8LA/SnwHP4xISeI/AAAAAAAACGE/qxAQ2QyBW4I/s1600-h/hirsute.jpg
ABATE, http://2.bp.blogspot.com/_Pxd0QZ3r8LA/SnwJAOzvJKI/AAAAAAAACGU/ancOnEvbu9s/s1600-h/abate.jpg
ANONYMOUS, http://3.bp.blogspot.com/_Pxd0QZ3r8LA/SIGINps9Y5I/AAAAAAAAA2s/agz5owAGCqI/s1600-h/anonymous.jpg
AMAZON, http://4.bp.blogspot.com/_Pxd0QZ3r8LA/SIGHv_ABqPI/AAAAAAAAA2c/1pI2d29PLO0/s1600-h/amazon.jpg
ABIDE, http://1.bp.blogspot.com/_Pxd0QZ3r8LA/SIGINuZXkSI/AAAAAAAAA20/JTvB3ydCxDI/s1600-h/abiding.gif
ACCRUE, http://1.bp.blogspot.com/_Pxd0QZ3r8LA/SIGINzSWzPI/AAAAAAAAA28/OZnOftg1vq4/s1600-h/accrue.gif
AMBIGUOUS, http://2.bp.blogspot.com/_Pxd0QZ3r8LA/SIGIN1X3_2I/AAAAAAAAA3E/waa_kNdabUE/s1600-h/ambiguous.gif
ABSTRUSE, http://3.bp.blogspot.com/_Pxd0QZ3r8LA/SIGHvc36oJI/AAAAAAAAA18/ZrDnsp0B8RQ/s1600-h/abstruse.jpg
ANACHRONISM, http://2.bp.blogspot.com/_Pxd0QZ3r8LA/SIGImns8H9I/AAAAAAAAA3M/PCs6oHjeBiY/s1600-h/anachronism.jpg
ACETIC, http://1.bp.blogspot.com/_Pxd0QZ3r8LA/SIGHvqMHzhI/AAAAAAAAA2E/-oxoNTeStbI/s1600-h
{"word": "HIRSUTE", "word_list": ["HIRSUTE:", "\u25a0", "adjective", "hairy; shaggy; bristly", "Eg.\nForty-five", "hirsute women", "were enrolled\nin the study: 29 were hyperandrogenic and 16 had idiopathic\nhirsutism."], "img_url": "http://2.bp.blogspot.com/_Pxd0QZ3r8LA/SnwHP4xISeI/AAAAAAAACGE/qxAQ2QyBW4I/s1600/hirsute.jpg"}
{"word": "ABATE", "word_list": ["ABATE:", "\u25a0", "Transitive", "verb", "1. to make less in amount, degree, force, etc.", "2. to deduct", "3. Law to put a stop to (a suit or action), end (a nuisance),\netc.; terminate", "abated", "abat\u2032\u00b7ed", ",\nabating", "abat\u2032\u00b7ing", "Eg. The\nprevious evening there had been a violent storm which had only\npartly", "abated by the time", "that the young\nexplorer left home."], "img_url": "http://2.bp.blogspot.com/_Pxd0QZ3r8LA/SnwJAOzvJKI/AAAAAAAACGU/ancOnEvbu9s/s1600/abate.jpg"}
{"word": "ANONYMOUS", "word_list": ["ANONYMOUS:", "\u25a0", "adjective", "not identified by name; of unknown identity:", "an anonymous phone\ncall.", "havin
@droot
droot / merchant_integration.js
Created January 4, 2011 13:43
Merchant Integration JS
<script language="javascript" type="text/javascript">
ss_mi.add_products(
[{
prod_page_url: 'http://www.merchant.com/ProductPage1.htm', /*EXAMPLE ONLY*/
prod_img_url: 'http://www.merchant.com/Image1.jpg', /*EXAMPLE ONLY*/
prod_img_url_https:'https://www.merchant.com/Image2.jpg', /*EXAMPLE ONLY*/
prod_title:'Snoozeberry Travel Mug', /*EXAMPLE ONLY*/
prod_currency:'USD', /*EXAMPLE ONLY*/
prod_price:'19.99' /*EXAMPLE ONLY*/
},