Skip to content

Instantly share code, notes, and snippets.

View arnab's full-sized avatar

Arnab Deka arnab

View GitHub Profile
@arnab
arnab / get-emacs-starter-kit.sh
Created June 3, 2012 10:29
Emacs setup steps (for GNU Emacs with Clojure and CommonLisp). See http://www.arnab-deka.com/notes/emacs-setup/
mv ~/.emacs.d ~/.emacs.d.bak
cd ~/.emacs.d
git clone <your-clone-of-esk>
@arnab
arnab / setup.sh
Created June 11, 2012 10:49
Set up Rails 3.2 with Rspec and Cucumber
# Works with Rails 3.2.x (and this keeps changing due to the large amounts of gems and their author's philosophies differing all the time)
# 1. Create new Rails app
rails new <thing> --skip-testunit
# 2. Add the following to Gemfile:
group :development, :test do
gem 'rspec-rails'
gem 'cucumber-rails', :require => false
@arnab
arnab / open_last_capybara_page.sh
Created June 27, 2012 06:41
Capybara's launchy integration, without installing the launchy gem
# From inside a Rails root directory
# After you call save_and_open_page in Capybara (and you don't have or want launchy)
open -a "Google Chrome" "tmp/capybara/"`ls -tr tmp/capybara/ | head -2 | tail -1`
@arnab
arnab / controller.rb
Last active April 6, 2021 15:02
Allow & test CORS requests in Rails
before_filter: allow_cors_requests
def allow_cors
headers["Access-Control-Allow-Origin"] = "*"
headers["Access-Control-Allow-Methods"] = %w{GET POST PUT DELETE}.join(",")
headers["Access-Control-Allow-Headers"] = %w{Origin Accept Content-Type X-Requested-With X-CSRF-Token}.join(",")
head(:ok) if request.request_method == "OPTIONS"
# or, render text: ''
# if that's more your style
end
@arnab
arnab / dynamic-fonts.el
Created September 24, 2012 04:08
Dynamically adjust fonts in emacs based on screen resolution (Retina vs. Thunderbolt)
;; Gist-ed from in https://github.com/arnab/emacs-starter-kit
(defun fontify-frame (frame)
(interactive)
(if window-system
(progn
(if (> (x-display-pixel-width) 2000)
(set-frame-parameter frame 'font "Inconsolata 19") ;; Cinema Display
(set-frame-parameter frame 'font "Inconsolata 16")))))
@arnab
arnab / octopress_migration.sh
Last active December 11, 2015 10:08
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 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
require 'benchmark'
require 'logger'
class LoggerBenchmark
def initialize
@logger = Logger.new("/dev/null")
end
def benchmark
n = 10000
the_clone = p.clone
the_dup = p.dup
@arnab
arnab / example_controller_test.rb
Last active December 12, 2015 04:18
Figure out which tests are causing weird warnings.
class ExampleControllerTest < Test::Unit
# setup etc.
test "something should do something" do
get :new
# assert something
end
# more tests
end