Count the number of the files in your bucket
s3cmd ls -r s3://logs.mybucket/subfolder/ | wc -l
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
=== VIM notes | |
save: :w | |
save and exit: :x | |
Search forward: /pattern | |
Search backward ?pattern | |
Continue forward search n | |
Continue backward search N |
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
Bash / Terminal / Shell notes | |
================================ | |
* Script header | |
#!/bin/bash | |
* Decompression: | |
$ tar -zxvf filename.tgz | |
$ tar -zxvf filename.tar.gz |
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
# PythonNotes | |
## Started Jan, 2015 | |
== String | |
s="hello world" | |
s.replace("hello", "pillo") | |
s.upper() | |
b = s.split() | |
space=" " | |
space.joib(b) # combines list of strings with spaces in between |
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
== Midnight Commander | |
==== Esc | |
Quick change directory: Esc + c | |
Quick change directory history: Esc + c and then Esc + h | |
Quick change directory previous entry: Esc + c and then Esc + p | |
Command line history: Esc + h | |
Command line previous command: Esc + p | |
View change: Esc + t (each time you do this shortcut a new directory view will appear) | |
Print current working directory in command line: Esc + a |
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
# Read the last 10k lines, then read the 1st 5k lines from that. | |
cat myfile | tail -10000 | head -5000 > newfile |
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
show dbs // show all the existing dbs on the server. | |
use db_name // use the db with name 'db_name' | |
db // name of the db currently being used | |
show collections // show information in the db | |
db.collection_name.insert({title: 'Hey MongoDB'}) // Creating the collection 'collection_name' and adding an entry to it | |
db.collection_name.count() // give the count of entries in the collection | |
for(var i=0; i < 10; i++) db.collection_name.insert({ number: i }) // loops work in the mongoDB shell! :) | |
db.collection_name.find().pretty() // print everything in pretty format inside the 'collection_name'. | |
db.collection_name.find({ number: 2 }) // finds the collection with specific definition | |
db.collection_name.find().sort({number: 1}) // sorts based on the numbers increasing (in alphabetic order). To ger the reverse we can use {number: -1} |
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
// more here: https://github.com/scala/pickling | |
// note that for each element of the class, there needs to be an implicit function defning pickle/unpickle procedure. | |
def pickleCacheToFile(): Unit = { | |
println("saving to file ... ") | |
val cacheByteArray = objectVar.pickle.value | |
val fos = new FileOutputStream(objectVar) | |
fos.write(cacheByteArray) | |
fos.close() | |
} |
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
sortMapByValue(map) { | |
var tupleArray = []; | |
for (var key in map) tupleArray.push([key, map[key]]); | |
tupleArray.sort(function (a, b) { | |
return b[1] - a[1] | |
}); | |
var sortedMap = {}; | |
tupleArray.forEach(function (el) { | |
sortedMap[el[0]] = el[1] | |
}); |
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
// to Map | |
var tupleArray = [[1,2], [3,4]]; | |
var outputMap = {}; | |
tupleArray.forEach(function (el) { | |
outputMap[el[0]] = el[1] | |
}); | |
// from Map | |
var inputMap = {1: 2, 3: 4} | |
var tupleArrayOut = Object.keys(inputMap).map(function(e, i){ |