Skip to content

Instantly share code, notes, and snippets.

Arnab Deka arnab

  • AWS
  • Seattle, USA
Block or report user

Report or block arnab

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
def done_remote(self, result):
remote_loc = result.split()[0]
repo_url = re.sub('^git(@|://)', 'http://', remote_loc)
# Replace the "tld:" with "tld/". See
tld_pattern = r'\.(com|net|org|co\..{2}):'
repo_url = re.sub(tld_pattern, r'.\1/', repo_url)
repo_url = re.sub('\.git$', '', repo_url)
self.repo_url = repo_url
arnab /
Last active Sep 12, 2017
Install and run riak in a distributed mode on Mac OSX using homebrew


  1. brew install riak
  2. cd `brew --prefix riak`
  3. copy the script into this dir
  1. run the script
  • chmod u+x
  • ./
arnab / detect_and_ternary_op.rb
Created Jun 27, 2013
Another weirdness between Ruby 1.8 and Ruby 1.9
View detect_and_ternary_op.rb
stuff = (1..10).to_a
# => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
stuff = stuff.detect { |stuff| stuff.even? } ? stuff : 'none found'
#### Ruby 1.8 #######
# => 2
# So, #detect first runs, finds 2 and the result is reassigned into "stuff"
# the ternary operation follows, with "stuff" set to 2
arnab / import_geonames_to_pg.sql
Created Jun 19, 2013
Import geonames data from into postgres.
View import_geonames_to_pg.sql
-- Data from
-- More details at
-- Steps at
CREATE TABLE geoname (
geonameid INT,
name VARCHAR(200),
asciiname VARCHAR(200),
arnab / search_results.txt
Last active Dec 17, 2015
Results for "And the Mountains Echoed" using
View search_results.txt
ruby ./get_prices.rb And the Mountains Echoed
search for: And+the+Mountains+Echoed
Aggregated reults:
store title price
========== ========================================================================================== ===========
arnab / example_controller_test.rb
Last active Dec 12, 2015
Figure out which tests are causing weird warnings.
View example_controller_test.rb
class ExampleControllerTest < Test::Unit
# setup etc.
test "something should do something" do
get :new
# assert something
# more tests
View benchmarking_example.rb
require 'benchmark'
require 'logger'
class LoggerBenchmark
def initialize
@logger ="/dev/null")
def benchmark
n = 10000
arnab /
Last active Dec 11, 2015
Things I had to do "differently" to migrate site to octopress
# Without setting thr LANG, I'd get errors from Ruby like this:
# YAML Exception reading invalid byte sequence in US-ASCII
# /Users/arnabdeka/Dropbox/websites/ `gsub': invalid byte sequence in US-ASCII (ArgumentError)
# from /Users/arnabdeka/Dropbox/websites/ `render_code_block'
# ...
# I got the idea while reading this rubygems issue:
export LANG=en_US.utf-8
You can’t perform that action at this time.