Skip to content

Instantly share code, notes, and snippets.

View girish's full-sized avatar

Girish Duvuru girish

  • Google
  • Seattle, WA
View GitHub Profile
@girish
girish / testlib.sh
Created October 12, 2012 16:17 — forked from rtomayko/testlib.sh
#!/bin/sh
# Usage: . testlib.sh
# Simple shell command language test library.
#
# Tests must follow the basic form:
#
# begin_test "the thing"
# (
# echo "hello"
# false
@girish
girish / ruby-1.9-tips.rb
Created June 29, 2012 22:26 — forked from igrigorik/ruby-1.9-tips.rb
Ruby 1.9 features, tips & tricks you may not know about...
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@girish
girish / gist:3021027
Created June 29, 2012 22:22 — forked from whiter4bbit/gist:2011424
Dijkstra using scalding
import com.twitter.scalding._
class DijkstraJob(args: Args) extends Job(args) {
val iteration = args.getOrElse("iteration", "0").toInt
Tsv(args("input"), ('node, 'dist, 'adjacent))
.read
.flatMap(('node, 'dist, 'adjacent) -> ('node, 'dist, 'adjacent)) { p: (String, Int, String) =>
val (node, distance, adjacent) = p
(node, distance, adjacent) +: adjacent.split(":").map { part: String =>
@girish
girish / simple5.Main.java
Created June 27, 2012 23:49
Cascading simple example #5 - source code
/*
* Copyright (c) 2007-2012 Concurrent, Inc. All Rights Reserved.
*
* Project and contact information: http://www.concurrentinc.com/
*/
package simple5;
import java.util.Properties;
@girish
girish / render_and_redirect.markdown
Created September 26, 2011 00:20 — forked from jcasimir/render_and_redirect.markdown
Render and Redirect in Rails 3

Render and Redirect

The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.

Render

The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.

:action

# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@girish
girish / pinger.rb
Created June 18, 2011 07:54 — forked from technoweenie/pinger.rb
ZeroMQ pub/sub demo
require 'zmq'
context = ZMQ::Context.new
pub = context.socket ZMQ::PUB
pub.setsockopt ZMQ::IDENTITY, 'ping-pinger'
pub.bind 'tcp://*:5555'
i=0
loop do
pub.send "ping pinger #{i+=1}" ; sleep 1
end
@girish
girish / rails_3_1_rc4_changes.md
Created June 17, 2011 19:40 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

latin = "a"
arabic = [0xfeb6].pack('U') # Sheen, ش
cjk = [0x3333].pack('U') # HUIITO, ㌳
kcodes = [ 'NONE', 'u', 's' ]
chars = [latin, arabic, cjk]
patterns = [ /\w/, /\W/, /[[:punct:]]/ ]
kcodes.each do |kcode|
$KCODE = kcode
@girish
girish / gist:1014787
Created June 8, 2011 16:40 — forked from Gregg/gist:968534
Code School Screencasting Framework

Screencasting Framework

The following document is a written account of the Code School screencasting framework. It should be used as a reference of the accompanying screencast on the topic.

Why you should care about screencasting?

You're probably aren't going to take the time to read this screencast if you're not interested, but there are a lot of nice side effects caused by learning how to create quality screencasts.

  1. Communicating more effectively - At Envy Labs we produce screencasts for our clients all the time. Whether it's demoing a new feature or for a presentation for an invester, they're often much more effective and pleasent then a phone call or screen sharing.