Skip to content

Instantly share code, notes, and snippets.

View saurabhnanda's full-sized avatar

Saurabh Nanda saurabhnanda

View GitHub Profile
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
About the location: Balaji Nagar (in the Telco Nagar Area, Pune, Maharashtra) is a small area housing around 500 families or 270 households, each having 4-5 members. The people here mostly belong to Scheduled Tribes and Other Backward Classes. They are primarily engaged in daily wage labour to make a living.
There is a primary and a secondary school each; as well as a primary health centre. The area also has access to clean drinking water.
Initiation of the programme: Magic Bus initiated its sport for development session in this community started on with the youth mentor (YM) Smita Shinde in December 2011. Smita identified and trained two more volunteer youth leaders, Akasha Mane and Sachin, and reached out to 50 children in the area.
The local community has been very supportive of the sessions, and the programme as a whole. They fully cooperate in getting equipment, land and resources for conducting sessions, games and tournaments and community meetings.
A typical weekly Magic Bus session at Balaji Nagar
class Base64
##
def self.convert_to_char(n)
if (0..25).cover?(n)
return (65 + n).chr
elsif (26..51).cover?(n)
return (97 + n - 26).chr
elsif (52..61).cover?(n)
return (n - 52).to_s
@saurabhnanda
saurabhnanda / gist:5345025
Created April 9, 2013 11:40
Count the number of lines with the words TODO or HACK in each commit in a git repository.
#!/bin/bash
# The output of the following command was piped into the STDIN of this script:
# git log --before="2012-07-07" --format="format:%H %ai" > sha1
while read sha1 dt tm tz; do
git checkout -q $sha1;
cnt=`egrep -ri 'todo|hack' app lib|wc -l|tr -d ' '`
echo "$dt $tm,$cnt"
done
----- NEW -----
<script>
(function(_,e,rr,s){_errs=[s];var c=_.onerror;_.onerror=function(){var a=arguments;_errs.push(a);
c&&c.apply(this,a)};var b=function(){var c=e.createElement(rr),b=e.getElementsByTagName(rr)[0];
c.src="//beacon.errorception.com/"+s+".js";c.async=!0;b.parentNode.insertBefore(c,b)};
_.addEventListener?_.addEventListener("load",b,!1):_.attachEvent("onload",b)})
(window,document,"script","517d27c31d18436d160000b3");
</script>
----- OLD -----
@saurabhnanda
saurabhnanda / bare_activerecord_jdbc_adapter.rb
Created December 5, 2013 12:32
Checking Postgres array data-type support for activerecord-jdbc-adapter
require 'active_record'
require 'activerecord-jdbc-adapter'
ActiveRecord::Base.establish_connection({
:adapter => 'jdbcpostgresql',
:port => '5432'
})
conn=ActiveRecord::Base.connection
conn.execute("DROP TABLE IF EXISTS reproduce_bugs ")
--------- Apache processes ----------
PID    PPID  VMSize    Private  Name
-------------------------------------
4969   1     103.6 MB  0.7 MB   /usr/sbin/apache2 -k start
15541  4969  103.1 MB  0.7 MB   /usr/sbin/apache2 -k start
16402  4969  341.1 MB  22.2 MB  /usr/sbin/apache2 -k start
16439  4969  343.2 MB  24.3 MB  /usr/sbin/apache2 -k start
16796  4969  351.3 MB  32.7 MB  /usr/sbin/apache2 -k start
### Processes: 5
@saurabhnanda
saurabhnanda / stderr.md
Created December 18, 2013 03:19
Torqbox lite hanging while benchmarking with 10 concurrency
^C07:58:52,341 INFO  [org.jboss.web] (ServerService Thread Pool -- 19) JBAS018224: Unregister web context: 
^C^C^C^C^C^C^\2013-12-18 07:59:19
Full thread dump Java HotSpot(TM) Client VM (20.6-b01-415 mixed mode):

"SIGINT handler" daemon prio=9 tid=00000000035ed400 nid=0xb6951000 waiting for monitor entry [00000000b6950000]
   java.lang.Thread.State: BLOCKED (on object monitor)
  at java.lang.Shutdown.exit(Shutdown.java:168)
  - waiting to lock <0000000027116110> (a java.lang.Class for java.lang.Shutdown)
 at java.lang.Terminator$1.handle(Terminator.java:35)
@saurabhnanda
saurabhnanda / rails-fuck-up.md
Last active January 1, 2016 14:38
Simple benchmark to demonstrate what a horrible fuck-up Rails/ActiveSupport is with respect to JSON generation. More details at https://github.com/intridea/multi_json/pull/138#issuecomment-24468223

Let's start with a fresh IRB session, load the json gem (which is implemented in C) and run a base benchmark.

[0] % irb
1.9.3p332 :001 > require 'json'
 => true 
1.9.3p332 :002 > require 'benchmark'
 => true 
1.9.3p332 :003 > Benchmark.measure { 500000.times { {'a' => 1, 'b' => [1, 2, '3']}.to_json } }
 => 8.730000 0.020000 8.750000 ( 8.757620)