Skip to content

Instantly share code, notes, and snippets.

Suresh Prajapati toddlers

Block or report user

Report or block toddlers

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:5442133
#!/usr/bin/env ruby
# A simply utility to show character counts for each line of input and
# highlight lines longer than 80 characters.
#
# Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html
#
# Examples:
#
# $ hilong Gemfile
View monitoring-stack-ubuntu-precise.md

Follow these steps to install Graphite on a fresh Ubuntu 12.04 instance. Make sure you read and understand the commands because by the time you read this, things could be outdated.

Graphite

Installing dependencies

# apt-get install libpq-dev
# apt-get install python-dev python-pip python-cairo python-psycopg2
# apt-get install python-django python-django-tagging
@toddlers
toddlers / remote_diff
Created May 6, 2013
remote_diff: grab a path from 2 websites and diff them a naive implementation, diffs the md5's if the files are not text
View remote_diff
#!/bin/bash
path1=`echo $1 | awk -F, '{print $1}'`/$2
path2=`echo $1 | awk -F, '{print $2}'`/$2
if `curl -Ss $path1 | file - | grep text`; then
diff <(curl -Ss $path1) <(curl -Ss $path2)
else
diff <(curl -Ss $path1 | md5) <(curl -Ss $path2 | md5)
fi
@toddlers
toddlers / test_config.sh
Created May 28, 2013
Simple YAML fine validation for syntax
View test_config.sh
#! /bin/bash
file=$1
set -a
if [ -z "$file" ]; then
echo "need YAML file as first arg"
exit 2
fi
if [ -f $file ]; then
View fixtime.pl
#!/usr/bin/perl
use strict ;
use warnings ;
use constant DEBUG => 0 ;
my ($adjtimex) = grep { -f $_ } qw(/sbin/adjtimex ./adjtimex);
die "Need adjtimex - install or download from http://linux.brong.fastmail.fm/2012-06-30/adjtimex and put into current dir\n"
@toddlers
toddlers / ruby_calculator.rb
Created Jun 2, 2013
simple ruby calculator
View ruby_calculator.rb
class Calculator
def initialize
@cal={
add: ->(a,b) { a + b },
subtract: ->(a,b) { a - b },
divide: ->(a,b) { a / b },
multiply: ->(a,b) { a * b },
power: ->(a,b) { a ** b }
}
View gitlog.txt
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
And every time you need to see your log, just type in
git lg
Or, if you want to see the lines that changed
git lg -p
@toddlers
toddlers / poweroftwo.rb
Last active Dec 18, 2015
Write A Function To Determine If A Number Is A Power Of 2
View poweroftwo.rb
def power_of_2?(number)
return false if number == 0
while(number % 2 == 0)
number = number / 2
end
return false if number > 1
true
end
View backend-architecures.md

Backend Architectures

ARCHITECTURES

Twitter

ror, scala, jetty, erlang, thrift, mongrel, comet server, my-sql, memchached, varnish, kestrel(mq), starling, gizzard, cassandra, hadoop, vertica, munin, nagios, awstats

@toddlers
toddlers / password.rb
Last active Dec 18, 2015
passwd file parsing
View password.rb
# On a system the /etc/passwd has entries with duplicate uids, can you write a python program to print
# the users with duplicate uids.
# User x,y,z duplicate uid 10001 on line 4,7,8
# User x,x duplicate uid 10001 on line 4,10
# This is the initial need to update this
#!/usr/bin/ruby
require 'pp'
z = {}
You can’t perform that action at this time.