This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A B C D | |
00 00 00 0 | |
00 01 01 0 | |
00 10 10 0 | |
00 11 11 0 | |
01 00 01 0 | |
01 01 10 0 | |
01 10 11 0 | |
01 11 00 1 | |
10 00 10 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ostruct' | |
require 'benchmark' | |
COUNT = 10_000_000 | |
NAME = "Test Name" | |
EMAIL = "[email protected]" | |
class SimpleOstruct | |
def initialize(attrs = {}) | |
@attrs = attrs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ostruct' | |
require 'benchmark' | |
COUNT = 10_000_000 | |
NAME = "Test Name" | |
EMAIL = "[email protected]" | |
class Person | |
attr_accessor :name, :email | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rationalise-dot() { | |
if [[ $LBUFFER = *.. ]]; then | |
LBUFFER+=/.. | |
else | |
LBUFFER+=. | |
fi | |
} | |
zle -N rationalise-dot | |
bindkey . rationalise-dot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tag | |
HASH_TAG = /#[a-z]\w*/ | |
USER_TAG = /@\w+/ | |
TAG_REGEXP = /(#{HASH_TAG}|#{USER_TAG})/ | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
attr_reader :factory | |
attr_reader :name | |
def initialize(factory, name) | |
@factory = factory | |
@name = name | |
end | |
def coworkers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> | |
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> | |
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> | |
<!--[if gt IE 8]><!--> | |
<html class="no-js" lang="en"> <!--<![endif]--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My theme - [email protected] | |
# Based on Fino theme with bits from dallas and robbyrussell | |
# Fino notes: | |
# Use with a dark background and 256-color terminal! | |
# Meant for people with RVM and git. Tested only on OS X 10.7. | |
# You can set your computer name in the ~/.box-name file if you want. | |
# Borrowing shamelessly from these oh-my-zsh themes: | |
# bira |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
ary = Array.new(1000) {rand(100)} | |
p Benchmark.measure { 1000.times { ary.each_with_object(Hash.new{ |x,k| x[k] = 0 }){ |x,s| s[x] += 1 }.max_by{ |k,v| v }[0] } } | |
p Benchmark.measure { 1000.times { ary.group_by{|e| e}.values.max_by(&:size).first } } | |
p Benchmark.measure { 1000.times { h = Hash.new(0); max_val = nil; max_count = 0; ary.each{ |x| count = h[x] + 1; h[x] = count; if count > max_count; max_count = count; max_val = x; end }; } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This should be in config/initializers/bower_rails.rb | |
BowerRails.configure do |bower_rails| | |
bower_rails.install_before_precompile = true | |
end |