This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.adminCommand("listDatabases").databases.forEach( function (d) { | |
if (d.name != "local" && d.name != "admin" && d.name != "config") | |
db.getSiblingDB(d.name).dropDatabase(); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Pool | |
from functools import partial | |
def parallel_function(f): | |
def parallize(f, seq): | |
pool = Pool() | |
pool.map(f, seq) | |
pool.close() | |
pool.join() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collection = db.getCollection('foo') | |
result = collection.aggregate( | |
[ | |
{"$group": { "_id": { fa: "$fa", fb: "$fb" } } } | |
] | |
); | |
printjson(result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install libatlas-base-dev gfortran | |
pip install scipy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
class DictToObject(object): | |
def __init__(self, dictionary): | |
def _traverse(k, v): | |
if isinstance(v, dict): | |
return k, DictToObject(v) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.extend(jQuery.validator.messages, { | |
required: "This field is required.", | |
remote: "Please fix this field.", | |
email: "Please enter a valid email address.", | |
url: "Please enter a valid URL.", | |
date: "Please enter a valid date.", | |
dateISO: "Please enter a valid date (ISO).", | |
number: "Please enter a valid number.", | |
digits: "Please enter only digits.", | |
creditcard: "Please enter a valid credit card number.", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope :by_quarter, lambda { |quarter| | |
date = Date.new(Date.today.year, quarter * 3) | |
where created_at: date.beginning_of_quarter..date.end_of_quarter } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lxneng=# SELECT 'YESTERDAY'::date, 'TODAY'::date, 'TOMORROW'::date; | |
date | date | date | |
------------+------------+------------ | |
2013-08-07 | 2013-08-08 | 2013-08-09 | |
(1 row) | |
lxneng=# select now(); | |
now | |
------------------------------- | |
2013-08-08 09:09:32.687512+08 |