Skip to content

Instantly share code, notes, and snippets.

View workmad3's full-sized avatar

David Workman workmad3

View GitHub Profile
@workmad3
workmad3 / adder
Last active August 29, 2015 14:26
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
require 'ostruct'
require 'benchmark'
COUNT = 10_000_000
NAME = "Test Name"
EMAIL = "test@example.org"
class SimpleOstruct
def initialize(attrs = {})
@attrs = attrs
require 'ostruct'
require 'benchmark'
COUNT = 10_000_000
NAME = "Test Name"
EMAIL = "test@example.org"
class Person
attr_accessor :name, :email
end
rationalise-dot() {
if [[ $LBUFFER = *.. ]]; then
LBUFFER+=/..
else
LBUFFER+=.
fi
}
zle -N rationalise-dot
bindkey . rationalise-dot
class Tag
HASH_TAG = /#[a-z]\w*/
USER_TAG = /@\w+/
TAG_REGEXP = /(#{HASH_TAG}|#{USER_TAG})/
end
class Person
attr_reader :factory
attr_reader :name
def initialize(factory, name)
@factory = factory
@name = name
end
def coworkers
<!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]-->
# My theme - ash.moran@patchspace.co.uk
# 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
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 should be in config/initializers/bower_rails.rb
BowerRails.configure do |bower_rails|
bower_rails.install_before_precompile = true
end