Skip to content

Instantly share code, notes, and snippets.

Erik Berlin sferik

Block or report user

Report or block sferik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 2.4-bench.rb
require 'benchmark/ips'
def class_integer
0.class == Integer
end
def version_gte
RUBY_VERSION >= '2.4'
end
View caddy.dot
digraph G {
label="Caddy Architecture"
labelloc="top"
fontsize=20
fontname="Helvetica Neue"
node [shape="ellipse", style="filled", fontname="Helvetica Neue"]
edge [fontname="Helvetica Neue"]
peripheries=0
rankdir="LR"
subgraph clusterClient {
View first_to_finish.rb
module Enumerable
def first_to_finish
threads = collect { |args| Thread.new { yield(args) } }
loop until done = threads.detect { |t| !t.alive? }
threads.each(&:kill)
done.value
end
end
puts [5, 3, 1, 2, 4].first_to_finish { |x| sleep x }
View system_ruby_version.markdown

What is the system Ruby?

What version of Ruby shipped by default on Mac OS X?

* Refers to the fully patched version (e.g. 10.5.8, not 10.5.0). Earlier versions may have shipped with different Ruby patchlevels but the RUBY_VERSION has never changed within major Mac OS X releases.
Mac OS X version* Mac OS X release date Default Ruby version
View struct_bench.rb
require 'benchmark/ips'
require 'ostruct'
N = 100
ATTRS = (:aa..:zz).take(N)
HASH = Hash[ATTRS.map { |x| [x, x] }]
CStruct = Struct.new(*ATTRS)
def struct
View 1_class_refactored_solution.rb
def valid?(card_number)
digits = card_number
.split("")
.map { |number| number.to_i }
numbers = []
digits.each_with_index do |digit, index|
if index.even?
numbers << digit * 2
else
View stratus-customization.html
<script type="text/javascript">
$(document).ready(function(){
$.stratus({
auto_play: true,
download: false,
key: "Enter your Client ID here",
links: 'http://soundcloud.com/qotsa',
random: true
});
});
View stratus-installation.html
<script type="text/javascript">
$(document).ready(function(){
$.stratus({
key: "Enter your Client ID here",
links: "https://soundcloud.com/zedsdead/sets/somewhere-else-ep"
});
});
</script>
View exposable.rb
require 'set'
module Lotus
module Action
module Exposable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
View twitter-friends.rb
require 'csv'
require 'twitter'
def twitter_client
@twitter_client ||= Twitter::REST::Client.new do |config|
config.consumer_key = 'XXXXXX'
config.consumer_secret = 'XXXXXX'
config.access_token = 'XXXXXX'
config.access_token_secret = 'XXXXXX'
end
You can’t perform that action at this time.