Sri Prasanna sriprasanna

View keybase.md

Keybase proof

I hereby claim:

  • I am sriprasanna on github.
  • I am batman (https://keybase.io/batman) on keybase.
  • I have a public key whose fingerprint is CB89 1086 D0BD D5B8 0D19 551F DF4D 28C8 3CFD 49C8

To claim this, I am signing this object:

View rapidftr-debian-packaging.sh
1 2 3 4 5 6 7 8 9 10
sudo apt-get update
sudo apt-get install --yes apt-file && apt-file update
sudo apt-get install --yes python-software-properties
sudo apt-add-repository --yes ppa:longsleep/couchdb
sudo apt-get update
sudo apt-get --purge --yes remove libcurl3
sudo apt-get clean
sudo apt-get --print-uris --yes install libcurl3 couchdb imagemagick openjdk-7-jdk ruby1.8 thin openssh-server rubygems1.8 libxslt-dev libxml2-dev libzip2 libzip-dev build-essential | grep ^\' | cut -d\' -f2 > dependencies.txt
mkdir debs && cd debs
wget -nc -i ../dependencies.txt
View lein2-issue.md

Sample Project

Starting from:

lein new foo
cd foo

Say I have a random JAR file that is not available in any repository:

touch README.md
View test_nothing.rb
1 2 3 4 5 6 7 8 9 10
require "rubygems"
require "rspec"
 
class TestNothing
def do_nothing
end
 
def return_nil
nil
end
View gist:2465475
1 2 3 4 5 6 7 8 9 10
#!/Users/dustyeike/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
require "rubygems"
require "test/unit"
require "date"
 
EPOCH = Date.new(1970, 1, 1)
 
#
# Returns the number of seconds from the epoch to date
def epoch_seconds date
View gist:824203
1 2 3 4 5 6 7 8 9 10
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
View gist:749181
1 2 3 4 5 6 7 8 9 10
@game = {}
@p1_success_probability = 1.to_f / 2
@p1_failure_probability = 1 - @p1_success_probability
 
def game(p1_points_to_win,p2_points_to_win)
return @game[[p1_points_to_win,p2_points_to_win]] if @game[[p1_points_to_win,p2_points_to_win]]
return 1 if p2_points_to_win <= 0
return 0 if p2_points_to_win > 0 and p1_points_to_win <= 0
strategies = [2]
while strategies.last < 2*p2_points_to_win
View Closures & Variable hoisting
1 2 3 4 5 6 7 8 9 10
// Simple example to show the power of closure when exploited w.r.t scope
function power_of (power) {
return function (number) {
return Math.pow(number, power);
};
}
 
var power_of_3 = power_of(3),
power_of_4 = power_of(4);
View How smart am I?
1 2 3 4 5 6 7 8 9 10
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
 
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>How smart am I?</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Sri Prasanna">
<!-- Date: 2010-02-17 -->
View reincarnation.rb
1 2 3 4 5 6 7 8 9 10
# Reincarnation for classes
 
class Class
def reincarnate
buried = Object.__send__(:remove_const, self.name)
Object.const_set(self.name, Class.new(buried))
end
end
 
class Abc
Something went wrong with that request. Please try again.