Skip to content

Instantly share code, notes, and snippets.

View chetan's full-sized avatar
🙌
like my work? sponsor me!

Chetan Sarva chetan

🙌
like my work? sponsor me!
View GitHub Profile
@chetan
chetan / gist:1189452
Created September 2, 2011 18:44 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job: Sr. Developer @ Evidon
Favorite Python project: boto
Favorite Conference: DEFCON
Python Experience Level: intermediate
@chetan
chetan / hadoop_combine_logs.pl
Created September 8, 2011 18:35
Combine hadoop log events into a single stream, sorted by date/time
#!/usr/bin/env perl
=cut
combine several hadoop (log4j) log files into a single stream, sorted by time
=cut
use File::Basename qw(basename);
my @logs;
@chetan
chetan / hadoop_snip_logs.pl
Created September 8, 2011 19:12
Snip hadoop logs between 2 timestamps
#!/usr/bin/env perl
=cut
usage:
cat foo.txt | hadoop_snip_logs.pl <time1> <time2>
e.g.
cat foo.txt | hadoop_snip_logs.pl 12:26 12:28
@chetan
chetan / vertica-ssh.sh
Created November 30, 2011 21:50
setup vertica user accounts with pubkey login
#!/bin/bash
if [[ -z "$1" ]]; then
echo "usage: $0 <host1> <host2> [host3 ...]"
exit 1
fi
SRC_HOST=$1
# see if src is setup yet with a key, if not create
@chetan
chetan / netverify.py.patch
Created November 30, 2011 22:48
patch for vertica5 installation script
--- netverify.py.orig 2011-11-30 17:26:33.000000000 -0500
+++ netverify.py 2011-11-30 17:32:45.000000000 -0500
@@ -1278,7 +1278,7 @@
# Get the hostname from the two different sources
- hvar = None
+ hvar = ""
for l in self.hostname_var:
if l.startswith("HOSTNAME ") or l.startswith("HOSTNAME\t"):
@chetan
chetan / install_cpanm_oneliner.sh
Created December 22, 2011 21:23
install cpanm in oneline
## don't screw around with cpan! just just cpan-minus!!
##
## run as root!
cd /usr/local/bin; curl -fsSLO http://xrl.us/cpanm; chmod 755 cpanm
## then install away!
## -q = queit, -n no test (who needs those pesky things?!)
cpanm -qn Moose
@chetan
chetan / install_perl_deps.sh
Created December 22, 2011 22:44
a simple way to install perl library dependencies from CPAN
#!/bin/bash
# a simple dependency installer using cpanm and the DEPS file
if [ ! -f `which cpanm` ]; then
echo "need to install cpanm!"
cd /usr/local/bin
sudo curl -fsSLO http://xrl.us/cpanm
sudo chmod 755 cpanm
@chetan
chetan / run.rb
Created January 21, 2012 04:08
simple performance testing wrapper around 'ab'
#!/usr/bin/env ruby
LONG_UA="-H \"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\""
DIR=ARGV.shift
URL="http://sewer3.evidon.com:8080/"
`mkdir -p #{DIR}`
(1..2).each do |i|
@chetan
chetan / install_openjdk7_hadoop.sh
Created January 27, 2012 04:04
Script for installing OpenJDK 7 and Hadoop on Ubuntu
#!/bin/bash
if [ ! -f /etc/apt/sources.list.d/cloudera.list ]; then
echo deb http://archive.canonical.com/ lucid partner > /etc/apt/sources.list.d/cloudera.list
echo deb http://archive.cloudera.com/debian lucid-cdh3u0 contrib >> /etc/apt/sources.list.d/cloudera.list
apt-get update
apt-get install --yes --force-yes hadoop
fi
if [ `uname -m` == "i686" ]; then
@chetan
chetan / log_wrapper.rb
Created January 30, 2012 20:56
Simple wrapper around Logger to allow reading back messages that were logged
require 'logger'
require 'stringio'
# simple little wrapper on logger that keeps a buffer of all logged messages
class LogWrapper
def initialize(file, level, rotation)
@file_logger = Logger.new(file, rotation)
@file_logger.sev_threshold = level