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
find /dir/ -iname "*.mp3" -print | |
# /dir/ - Search directory | |
# -iname - File name search pattern (case insensitive) | |
# -print - Display name of files on screen | |
find / -iname "*.mp3" -exec mv {} /new_dir/mp3 \; | |
# -exec mv {} /mnt/mp3 \; | |
# Execute mv command. | |
# The string '{}' is replaced by the file name. |
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
import re | |
import os | |
import locale | |
def inspect_file(file_name): | |
# Do stuff | |
return | |
def process_all(files_list): |
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.quotes.ensureIndex( { text_or_whatever : "text" }, { default_language : "german" } ) |
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 getQuery (searchString, callback) { | |
mongo.MongoClient.connect( | |
uri, | |
function(err, db) { | |
if(err) throw err; | |
query = { "$text": { "$search": searchString.toString() } }; | |
var cursor = db.collection("quotes").find( |
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
mongorestore --host mongodb1.example.net --port 37017 --username user --password pass /opt/backup/mongodump-2011-10-24 |
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 ArrayAdditionI(arr) { | |
// code goes here | |
var max = Math.max.apply( Math, arr ), | |
idx = arr.indexOf(max); | |
if (idx>-1) { arr.splice(idx, 1) } | |
return arr | |
} |
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
State of binary switches: 0,0,0,0,0,0 | |
Corresponding combination: | |
State of binary switches: 0,0,0,0,0,1 | |
Corresponding combination: 100 | |
State of binary switches: 0,0,0,0,1,0 | |
Corresponding combination: 5 | |
State of binary switches: 0,0,0,0,1,1 | |
Corresponding combination: 5,100 | |
State of binary switches: 0,0,0,1,0,0 | |
Corresponding combination: 4 |
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 array = [1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17], | |
c = {}, // counters | |
s = []; // sortable array | |
for (var i=0; i<array.length; i++) { | |
c[array[i]] = c[array[i]] || 0; // initialize | |
c[array[i]]++; | |
} // count occurrences | |
for (var key in c) { |
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 solutions = {}, | |
coins = [1,5,7,9,11]; | |
var process = function (t) { | |
if (t == 0) { | |
// solved | |
return 0; | |
} else if (t < 0) { | |
// wrong path; return really large number | |
return 2e10; |
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 f = function (n) { | |
var s = ""; | |
// 0 is falsy, the ternary then evaluates to the value right of the colon | |
s += n % 3 ? "" : "Fizz"; | |
s += n % 5 ? "" : "Buzz"; | |
// empty string is also falsy | |
return s ? s : n; | |
}; | |
console.log(f(7)); |