Skip to content

Instantly share code, notes, and snippets.

View dinks's full-sized avatar

Dinesh Vasudevan dinks

View GitHub Profile
@dinks
dinks / Preferences.sublime-settings.json
Created September 18, 2012 09:19
Sublime Preferences
// While you can edit this file, it's best to put your changes in
// "User/Preferences.sublime-settings", which overrides the settings in here.
//
// Settings may also be placed in file type specific options files, for
// example, in Packages/Python/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overriden in the platform
@dinks
dinks / bootstrap_topbar_list.rb
Created November 23, 2012 09:52 — forked from tmaier/bootstrap_topbar_list.rb
BootstrapTopbarList for simple-navigation and Twitter Bootstrap integration
# Renders an ItemContainer as a <ul> element and its containing items as <li> elements.
# Prepared to use inside the topbar of Twitter Bootstrap http://twitter.github.com/bootstrap/#navigation
#
# Register the renderer and use following code in your view:
# render_navigation(level: 1..2, renderer: :bootstrap_topbar_list, expand_all: true)
class BootstrapTopbarList < SimpleNavigation::Renderer::Base
def render(item_container)
if options[:is_subnavigation]
ul_class = "dropdown-menu"
@dinks
dinks / configuring tire for bonsai.md
Created December 11, 2012 13:08 — forked from nz/configuring tire for bonsai.md
Configuring Tire to work with Bonsai

1. Configure Tire to use the Bonsai ElasticSearch Heroku add-on

gem 'tire'

config/initializers/bonsai.rb

ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
@dinks
dinks / test.css.scss.erb
Created January 17, 2013 16:52
Always do this if you dont want to have inconsistencies creeping up your assets
.blah {
<% I18n.available_locales.map(&:to_s).sort.each do |locale| %>
&.<%= locale %> {
background-url: asset-url('localized/test.<%= locale %>.png');
}
<% end %>
}
@dinks
dinks / healthy.rb
Created September 23, 2013 15:12
healthy ?
map('/pulse') { run -> _ { [200, {}, []] } }
@dinks
dinks / gist:6672078
Created September 23, 2013 15:21 — forked from nbibler/gist:5307941
if [ -f "$rvm_path/scripts/rvm" ]; then
source "$rvm_path/scripts/rvm"
if [ -f ".rvmrc" ]; then
source ".rvmrc"
fi
if [ -f ".ruby-version" ]; then
rvm use `cat .ruby-version`
fi
@dinks
dinks / ruby-vms.txt
Created September 24, 2013 19:01
Ruby Threads
You seem to be confusing two very different things here: the Ruby Programming Language and the specific threading model of one specific implementation of the Ruby Programming Language. There are currently around 11 different implementations of the Ruby Programming Language, with very different and unique threading models.
(Unfortunately, only two of those 11 implementations are actually ready for production use, but by the end of the year that number will probably go up to four or five.) (Update: it's now 5: MRI, JRuby, YARV (the interpreter for Ruby 1.9), Rubinius and IronRuby).
The first implementation doesn't actually have a name, which makes it quite awkward to refer to it and is really annoying and confusing. It is most often referred to as "Ruby", which is even more annoying and confusing than having no name, because it leads to endless confusion between the features of the Ruby Programming Language and a particular Ruby Implementation.
It is also sometimes called "MRI" (for "Matz's Ruby Implementati
@dinks
dinks / autoformatting_in_vim.txt
Created September 25, 2013 14:57
Autoformatting in VIM
gg=G
gg => go to start of file
= => apply autoformatting
G => ... to the end of file
@dinks
dinks / anagram.rb
Created September 26, 2013 10:12
Anagram
# A string is a palindrome if it has exactly the same sequence of characters when read left-to-right as it has when read right-to-left. For example, the following strings are palindromes:
# "kayak",
# "codilitytilidoc",
# "neveroddoreven".
# A string A is an anagram of a string B if A can be obtained from B by rearranging the characters. For example, in each of the following pairs one string is an anagram of the other:
#
def anagram(s)
@dinks
dinks / fib.js
Last active December 25, 2015 10:19
Fibanocci with the Golden Ratio
var phi = (1 + Math.sqrt(5)) / 2;
var fib_gr = function (n) {
return Math.floor((Math.pow(phi, n) / Math.sqrt(5)) + (1 / 2));
};
for (var i = 1; i < 20; ++i) {
console.log(i, '->', fib_gr(i));
}