Skip to content

Instantly share code, notes, and snippets.

Avatar

Arnab Deka arnab

  • AWS
  • Vancouver, BC, Canada
View GitHub Profile
View sublime_github.py
def done_remote(self, result):
remote_loc = result.split()[0]
repo_url = re.sub('^git(@|://)', 'http://', remote_loc)
# Replace the "tld:" with "tld/". See http://rubular.com/r/FK3w7CVnx5
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
arnab / README.md
Last active Sep 12, 2017
Install and run riak in a distributed mode on Mac OSX using homebrew
View README.md

Install

  1. brew install riak
  2. cd `brew --prefix riak`
  3. copy the create_cluster.sh script into this dir
  1. run the script
  • chmod u+x create_cluster.sh
  • ./create_cluster.sh
@arnab
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
arnab / import_geonames_to_pg.sql
Created Jun 19, 2013
Import geonames data from http://geonames.org/ into postgres.
View import_geonames_to_pg.sql
-- Data from http://download.geonames.org/export/dump/
-- More details at http://download.geonames.org/export/dump/readme.txt
-- Steps at https://gist.github.com/EspadaV8/1357237
DROP TABLE geoname CASCADE;
CREATE TABLE geoname (
geonameid INT,
name VARCHAR(200),
asciiname VARCHAR(200),
@arnab
arnab / search_results.txt
Last active Dec 17, 2015
Results for "And the Mountains Echoed" using https://github.com/arnab/compricin/
View search_results.txt
ruby ./get_prices.rb And the Mountains Echoed
search for: And+the+Mountains+Echoed
flipkart: http://www.flipkart.com/search/a/all?query=And+the+Mountains+Echoed
ebay: http://search.ebay.in/And+the+Mountains+Echoed
junglee: http://www.junglee.com/mn/search/junglee?field-keywords=And+the+Mountains+Echoedinfibeam: http://www.infibeam.com/search?q=And+the+Mountains+Echoed
Aggregated reults:
store title price
========== ========================================================================================== ===========
@arnab
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
end
# more tests
end
View benchmarking_example.rb
require 'benchmark'
require 'logger'
class LoggerBenchmark
def initialize
@logger = Logger.new("/dev/null")
end
def benchmark
n = 10000
@arnab
arnab / octopress_migration.sh
Last active Dec 11, 2015
Things I had to do "differently" to migrate site to octopress
View octopress_migration.sh
# Without setting thr LANG, I'd get errors from Ruby like this:
# YAML Exception reading 2012-09-23-state-of-e-commerce-in-india.md: invalid byte sequence in US-ASCII
# /Users/arnabdeka/Dropbox/websites/arnab.github.com/plugins/backtick_code_block.rb:13:in `gsub': invalid byte sequence in US-ASCII (ArgumentError)
# from /Users/arnabdeka/Dropbox/websites/arnab.github.com/plugins/backtick_code_block.rb:13:in `render_code_block'
# ...
# I got the idea while reading this rubygems issue: https://github.com/rubygems/rubygems/issues/314
export LANG=en_US.utf-8
You can’t perform that action at this time.