Skip to content

Instantly share code, notes, and snippets.

View gaurav's full-sized avatar

Gaurav Vaidya gaurav

View GitHub Profile
@gaurav
gaurav / gist:41182
Created December 29, 2008 05:03
A quick command to list all the files modified by an author in a repository
git log --name-status --pretty=format:'' --author=authorname | sort | uniq
perl -ne 'lc; $total = length; s/[^l]//g; print "Total: $total\tLs: " . length($_) . "\n";'
@gaurav
gaurav / gist:110333
Created May 12, 2009 05:42
A Perl one-liner to check that $seconds_since_the_house % $NO will distribute correctly across $NO machines.
# A one-liner to ensure that $seconds_since_the_hour % $NO will distribute equally.
perl -Mstrict -e 'my $NO = 6; my @a = (); push @a, int rand(60) for(1 .. 1_000); my %b = (); $b{$_ % $NO}++ for(@a); print "$_ => $b{$_}\n" for sort { $a <=> $b } keys %b;'
@gaurav
gaurav / perldoc-server for non-installed modules.diff
Created September 4, 2009 06:36
A first step to getting Perldoc-Server to work on local folders.
--- perldoc-server.original 2009-09-04 14:23:55.000000000 +0800
+++ perldoc-server 2009-09-04 14:35:57.000000000 +0800
@@ -31,6 +31,7 @@
GetOptions(\%options,
'perl=s',
'port=i',
+ 'search|l=s@',
'public',
'help|h|?' => sub{pod2usage(1)},
);
@gaurav
gaurav / file-upload.pl
Last active September 4, 2015 02:55
A small cookbook program showing how to upload files with Perl
#!/usr/bin/perl
use strict;
use warnings;
# This is intended as an easy-to-use cookbook example to getting started
# uploading files on Perl. Please let me (gaurav at ggvaidya dot com) know
# if you have any comments or suggestions for this example.
#
# It is made available under the same license terms as the Perl interpreter.
@gaurav
gaurav / Nature Precedings, partial fix.patch
Created July 18, 2010 06:12
Nature Preceedings plugin for CiteULike, partial fix
Index: plugins/python/naturepreceedings.py
===================================================================
--- plugins/python/naturepreceedings.py (revision 581)
+++ plugins/python/naturepreceedings.py (working copy)
@@ -107,7 +107,7 @@
abs = abstract.renderContents().strip()
abs = re.sub(r'<[^>]+>','',abs)
abs = unescape(abs)
- print "abstract\t%s" % abs
+ print "abstract\t%s" % abs.encode('utf-8')
@gaurav
gaurav / .vimrc
Last active April 29, 2017 04:09
My .vimrc file
" Activate pathogen.
call pathogen#infect()
call pathogen#helptags()
" These are a few of my favourite settings.
syntax on
set background=dark
set hlsearch
set incsearch
set smartindent
#!/usr/bin/perl
# This is the program I wrote to crack this fun little cipher: http://keiththomsonbooks.com/cipher-02022012.html
# The clue clearly indicates that this is just a simple substitution cipher [1]; even better, it looks like ROT13 [2],
# except that you clearly don't move every letter along by exactly 13 places. So how many letters do you need to move
# it along by? There's only 26 letters in the English alphabet: let's try every possible value!
#
# [1] http://en.wikipedia.org/wiki/Substitution_cipher
# [2] http://en.wikipedia.org/wiki/ROT13
@gaurav
gaurav / AtomZombieLog_Apr30.txt
Created April 29, 2011 20:20
A log of my first complete Atom Zombie Smasher game. At last!
Atom Zombie Smasher
Commander: Gaurav
Start date: April 26, 2011
Zeppelin: Five Howling Zeppelin
Codename: OperationProngLightning135
----------------------------------
JANUARY 1961: AURORA AUSTRALIS.
Shorter daytime.
@gaurav
gaurav / readgb.pl
Created June 14, 2011 10:37
ReadGB.pl: Reading a GenBank file with BioPerl
#!/usr/bin/perl
use 5.0100;
use strict;
use warnings;
# Load the SeqIO module.
use Bio::SeqIO;