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
| function convertTimestamp(timestamp) { | |
| var d = new Date(timestamp * 1000), // Convert the passed timestamp to milliseconds | |
| yyyy = d.getFullYear(), | |
| mm = ('0' + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0. | |
| dd = ('0' + d.getDate()).slice(-2), // Add leading 0. | |
| hh = d.getHours(), | |
| h = hh, | |
| min = ('0' + d.getMinutes()).slice(-2), // Add leading 0. | |
| ampm = 'AM', | |
| time; |
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
| var collectionNames = db.getCollectionNames(), stats = []; | |
| collectionNames.forEach(function (n) { stats.push(db[n].stats()); }); | |
| stats = stats.sort(function(a, b) { return b['size'] - a['size']; }); | |
| for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); } |
I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
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
| // This file is part of github.com/Trrnts/Trrnts - an upcoming alternative to The Pirate Bay. | |
| var bencode = require('bencode'), | |
| dgram = require('dgram'), | |
| hat = require('hat'), | |
| _ = require('lodash'), | |
| redis = require('../redis')(), | |
| geoip = require('geoip-lite'); | |
| // Put in a function. The returned function won't ever throw an error. This is |
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
| config: | |
| from_address: [email protected] | |
| carriers: | |
| alltel: | |
| name: Alltel | |
| value: @message.alltel.com | |
| ameritech: | |
| name: Ameritech | |
| value: @paging.acswireless.com |
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
| #with docker | |
| docker run -it -v "$PWD"/mongo_dump:/data/dump --rm mongo:3.0.5 sh -c 'exec mongodump --out /data/dump --host=1.2.3.4 --db the_database' | |
| docker run -it -v "$PWD"/mongo_dump:/data/dump --rm mongo:3.0.5 sh -c 'exec mongorestore --host=1.2.3.4 --db the_database /data/dump/the_database --drop' | |
| #dump | |
| sudo mongodump | |
| #restore (droping previous data) | |
| sudo mongorestore |