Skip to content

Instantly share code, notes, and snippets.

View maggiben's full-sized avatar

Benjamin maggiben

  • Frávega
  • Argentina
View GitHub Profile
@maggiben
maggiben / analytics.js
Last active August 29, 2015 14:08
mongo logs by intervals
var until = new Date(2015,1,1);
var since = new Date(2010,1,1);
var digestor = '535b97507899a672c49dd490'
db.logs.aggregate([
{
$match: {
time: {
$gt: 0
},
@maggiben
maggiben / percentile.js
Created October 31, 2014 22:51
calculate percentiles
$scope.percentiles = metrics.map(function(metric, index) {
return {_id: metric._id, percentiles: (function(arr) {
function getPercentile(percentile, array) {
var index = percentile * arr.length;
var nearest = Math.floor(index);
if(index % 1 === 0) {
return (array[nearest-1] + array[nearest]) / 2;
} else {
return array[nearest];
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maggiben
maggiben / catacomb.sh
Created November 20, 2014 14:55
openssl use ssh keys to crypt & decrypt strings (plain strings no files)
encrypt() {
PUBLIC_KEY="~/.ssh/id_rsa"
echo $1 | openssl rsautl -encrypt -inkey <(openssl rsa -in ~/.ssh/id_rsa -outform pem 2> /dev/null | openssl rsa -pubout 2> /dev/null) -pubin | openssl base64
}
decrypt() {
PUBLIC_KEY="~/.ssh/id_rsa"
echo "$1" | openssl base64 -d | openssl rsautl -decrypt -inkey <(openssl rsa -in ~/.ssh/id_rsa -outform pem 2> /dev/null)
}
NOOK=$(encrypt "Hello world")
@maggiben
maggiben / world-50m.json
Created November 30, 2014 04:58
world-50m.json
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maggiben
maggiben / world-110m.json
Created November 30, 2014 05:15
world-110m.json
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maggiben
maggiben / world-100m.json
Created November 30, 2014 05:18
world-100m.json
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maggiben
maggiben / countries-50m.json
Created December 1, 2014 14:23
countries-50m.json
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maggiben
maggiben / malwares.json
Last active August 29, 2015 14:14
top malware threats
[
{
"avatar": "http://www.iconpng.com/png/windows8_icons2/biohazard.png",
"name": "bot cutwail",
"uname": "@cutwail",
"followers": "51904740",
"following": "134",
"tweets": "5456"
},
{
{
"query":{
"count":41,
"created":"2013/12/02T13:09:27Z",
"lang":"en-US",
"results":{
"quote":[
{
"date":"2013/11/29",
"Date":"2013/11/29",