A module to automatically translate snake_case method calls into CamelCase method calls. For example:
class MyObject
include Snakeable
def FooBar
"baz"
end
end
A module to automatically translate snake_case method calls into CamelCase method calls. For example:
class MyObject
include Snakeable
def FooBar
"baz"
end
end
# I put this right after rubygems is loaded in my boot.rb file | |
def Gem.cache | |
cache = Object.new | |
def cache.search name, *requirements | |
Gem::Specification.find_all_by_name name, *requirements | |
end | |
def cache.find *args, &blk | |
Gem::Specification.all.find *args, &blk | |
end |
--- ext/openssl/ossl_pkey_ec.c | |
+++ ext/openssl/ossl_pkey_ec.c | |
@@ -761,8 +761,10 @@ static VALUE ossl_ec_group_initialize(in | |
method = EC_GFp_mont_method(); | |
} else if (id == s_GFp_nist) { | |
method = EC_GFp_nist_method(); | |
+#if !defined(OPENSSl_NO_EC2M) | |
} else if (id == s_GF2m_simple) { | |
method = EC_GF2m_simple_method(); | |
+#endif |
# https://gist.github.com/eric1234/13501faf7471a45d10be | |
class @EvenHeight | |
constructor: (@elements...) -> @apply() | |
apply: -> | |
# In case the page doesn't have the elements so we don't have to | |
# check when calling the constructor. | |
return if @elements.length == 0 |
--- ext/openssl/ossl_pkey_ec.c | |
+++ ext/openssl/ossl_pkey_ec.c | |
@@ -762,8 +762,10 @@ | |
method = EC_GFp_mont_method(); | |
} else if (id == s_GFp_nist) { | |
method = EC_GFp_nist_method(); | |
+#if !defined(OPENSSl_NO_EC2M) | |
} else if (id == s_GF2m_simple) { | |
method = EC_GF2m_simple_method(); | |
+#endif |
This script is conceptually based on s3nuke but with an entirely different implementation. The key differences are:
# Extends CSV::Reader to assume the first row is the headers to the data | |
# (i.e. fields names). Each non-header row in the data with then be | |
# passed a hash instead of the normal array so you can reference the | |
# data by field name. For example: | |
# | |
# CSV::Reader::WithHeader.parse(io) do |row| | |
# puts row['first_name'] + ' ' + row['last_name'] | |
# end | |
class CSV::Reader::WithHeader < CSV::Reader | |
def self.parse(str_or_readable, fs=',', &blk) |
# Most simply just returns the data. But can allow for adjusting of the | |
# data a bit more to ensure more normalized data or format conversions. | |
# | |
# * If data is blank? (as defined by ActiveSupport) then nil is | |
# returned. | |
# * If the block is given then that will be called and the return | |
# value will be passed back. If the value is blank? then the block | |
# will not be called and nil will be returned (to avoid checks | |
# in the blocks) | |
# |
# An example of verbose Ruby code to counter the argument that | |
# optional syntax should be used as expressed on the blog post | |
# http://robots.thoughtbot.com/post/185504560/to-self-or-not-to-self | |
# | |
# I.E. the logical conclusion of this sort of thinking. | |
class User < ActiveRecord::Base | |
self.before_save(:sanitize_names); | |
def display_name() | |
return self.email() if self.first_name().blank?(); |
#!/usr/bin/env ruby | |
# Will slurp all the media attached to a audio/video podcasts. USAGE: | |
# | |
# ruby -rrubygems podcast_slurp.rb http://feeds.feedburner.com/railscasts railscasts | |
$VERBOSE = true | |
require 'open-uri' | |
require 'nokogiri' |