Code from CSSFlow and then some Javascript
A Pen by Dinesh Vasudevan on CodePen.
var getEByClass = function (_) { | |
var regExp = new RegExp("\\b" + _ + "\\b", ""), | |
elements = []; | |
var clazz = function (e) { | |
return e.className || ""; | |
}; | |
var getAll = function (context) { | |
var c = clazz(context); |
Code from CSSFlow and then some Javascript
A Pen by Dinesh Vasudevan on CodePen.
Show public gists
A Pen by Dinesh Vasudevan on CodePen.
# The aim of this class is to take a number of ordered enumerators and then | |
# emit their values in ascending order. | |
# | |
# Some assumptions: | |
# * The enumerators passed in emit their values in ascending order. | |
# * The enumerators emit values which are Comparable[1] with each other. | |
# * The enumerators can be finite *or* infinite. | |
# | |
# This requires Ruby 1.9. The Enumerator[2] documentation might be useful. | |
# |
I tried doing a bundle install with rails and had immediate problems like | |
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. | |
/Users/dineshvasudevan/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb | |
checking for random()... *** extconf.rb failed *** | |
Could not create Makefile due to some reason, probably lack of | |
necessary libraries and/or headers. Check the mkmf.log file for more | |
details. You may need configuration options. | |
.. |
# encoding: utf-8 | |
class Person | |
code = proc { puts self } | |
code2 = proc { |greet| puts "#{greet} #{self}" } | |
define_method :name do | |
self.class.instance_eval &code |
class Hash | |
def except(*blacklist) | |
reject {|key, value| blacklist.include?(key) } | |
end | |
def only(*whitelist) | |
reject {|key, value| !whitelist.include?(key) } | |
end | |
end |
# From http://techtime.getharvest.com/blog/harvest-is-now-on-ruby-1-dot-9-3 | |
class ActiveRecord::Base | |
def unserialize_attribute_with_utf8(attr_name) | |
traverse = lambda do |object, block| | |
if object.kind_of?(Hash) | |
object.each_value { |o| traverse.call(o, block) } | |
elsif object.kind_of?(Array) | |
object.each { |o| traverse.call(o, block) } | |
else | |
block.call(object) |
SSH_COMPLETE=( $(cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq) ) | |
complete -o default -W "${SSH_COMPLETE[*]}" ssh |
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) | |
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(File.join(ENV['OPENSHIFT_RUBY_LOG_DIR'], "production-#{Time.now.strftime('%Y%m%d')}.log"))) |