This file contains 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
function sortSelectOptions(selectElement) { | |
var options = $(selectElement + " option"); | |
options.sort(function(a,b) { | |
if (a.text.toUpperCase() > b.text.toUpperCase()) return 1; | |
else if (a.text.toUpperCase() < b.text.toUpperCase()) return -1; | |
else return 0; | |
}); | |
$(selectElement).empty().append( options ); |
This file contains 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
checkbox.attr("checked", !checkbox.attr("checked")); |
This file contains 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
// Usage: $ mongo dropAll.js | |
var dbs = db.getMongo().getDBNames() | |
for(var i in dbs){ | |
db = db.getMongo().getDB( dbs[i] ); | |
print( "dropping db " + db.getName() ); | |
db.dropDatabase(); |
This file contains 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
$var_str = var_export($page, true); | |
file_put_contents('K:\filename.txt', $var_str); |
This file contains 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.link_access.group( | |
{ | |
keyf: function(doc) { | |
var date = new Date(doc.date); | |
var dateKey = (date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear()+''; | |
return {'day': dateKey}; | |
}, | |
cond: {short_id: "N"}, | |
initial: {count:0}, | |
reduce: function(obj, prev) {prev.count++;} |
This file contains 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
var start = new Date(2013, 5, 4) | |
var end = new Date(2013, 5, 6) | |
db.mention_stat.find({"verification": {"$gte": start, "$lt": end}}) |
This file contains 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
var mention_id = 620996; | |
db.mentionStats.aggregate([ | |
{ $match: {'mention_id': mention_id}}, | |
{ $group: {'_id': { | |
'year': { '$year': "$verification_date" }, | |
'month': { '$month': "$verification_date" }, | |
'day': { '$dayOfMonth': "$verification_date" } | |
}, | |
'retweets': { $last: "$retweets" }}}, |
This file contains 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
mongoimport --db pcat --collection products < products.json |
This file contains 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.zips.find({city : { $regex : /^[0-9]/ }}) |
This file contains 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
function toTitleCase(str) { | |
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); | |
} |
OlderNewer