Skip to content

Instantly share code, notes, and snippets.

@RamaRoberts
RamaRoberts / mongodb-mapreduce.js
Created July 3, 2013 19:54
Runs a map/reduce across a MongoDB data set.
var end = new Date();
var start = new Date();
start.setTime(start.getTime()-300000); //5 minutes prior
// print dates in the format YYYY-MM-DD HH:MM:SS so we can do Mysql LOAD IN FILE on them
// Note that in JS the month portion of the Date constructor is 0-indexed
var my_s = start.getFullYear() + "-" + (start.getMonth()+1) + "-" + start.getDate() + " " + start.getHours() + ":" + start.getMinutes() + ":" + start.getSeconds();
var my_e = end.getFullYear() + "-" + (end.getMonth()+1) + "-" + end.getDate() + " " + end.getHours() + ":" + end.getMinutes() + ":" + end.getSeconds();
print(my_s + ',' + my_e);
#!/usr/bin/perl
use strict;
use warnings;
my $file = $ARGV[0];
open FILE, "< $file" or die "Can't open $file : $!";
# save the total impressions across all creatives for this time period for use in reporting (Munin)
my $impressions_count_file = "/tmp/impressions-count";
@RamaRoberts
RamaRoberts / mongod-log-rotate.sh
Created July 3, 2013 19:45
Log rotation for MongoDB.
#!/bin/bash
LOGSDIR="/app/mongodb/logs"
# this causes mongo to rotate logs
killall -SIGUSR1 mongod
# now purge the older logs
logs=`find ${LOGSDIR}/ -type f -mtime +30`
for log in $logs; do
@RamaRoberts
RamaRoberts / hack.sh
Created April 1, 2012 01:37 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@RamaRoberts
RamaRoberts / gist:2174099
Created March 23, 2012 19:26
Velti Architecture Job Description
Overview
The Global Architecture team at Velti is essentially responsible for overseeing all engineering and operations teams
within the Business Units across the company. The team works on few pure coding projects. Instead we're responsible
for ensuring the various engineering teams produce reliable, scalable, performant systems that are intended to be
reused. You must be comfortable with the "entire stack", being hands off a large part of the time, and driven to stay
in touch with the latest technologies.
Responsibilities
#! /bin/sh
for pool in `zpool list -H -o name`; do
zfs snapshot -r $pool@auto:`date "+%FT%T"`
zfs list -H -t snapshot -o name | grep $name@auto: | \
sed -e 's/.*auto://' | sort -r | uniq | tail +14 | \
while read name; do
zfs destroy -r $pool@auto:$name
done
module Facter::Xvm
#
# Report if this a an Xvm Dom0 or a DomU. If its a Dom0, also report
# a list of any DomU's on the machine (that aren't shut off)
#
# ASSUMPTIONS:
# 1. 'uname -i' reports something unique to identify a Dom0 or a DomU
# 2. if the 'virsh' command *also* exists, its a Dom0
#