(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
LD_PRELOAD=/usr/local/Cellar/jemalloc/3.6.0/lib/libjemalloc.dylib unicorn -c config/unicorn.rb -E production -p 3000
http://samsaffron.com/archive/2014/04/08/ruby-2-1-garbage-collection-ready-for-production
LD_PRELOAD=/home/sam/Source/jemalloc-3.5.0/lib/libjemalloc.so RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=0.9 ruby stress.rb
# MODEL | |
class Case < ActiveRecord::Base | |
include Eventable | |
has_many :tasks | |
concerning :Assignment do | |
def assign_to(new_owner:, details:) | |
transaction do |
/* | |
Copyright (c) 2015 Paul Jolly <paul@myitcv.org.uk) | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
You can break these rules if you can talk your pair into agreeing with you.
require "benchmark" | |
hash = {'key' => 1, :key => 2} | |
n = 5_000_000 | |
Benchmark.bm do |x| | |
x.report("strings") { n.times { hash['key'] } } | |
x.report("symbols") { n.times { hash[:key] } } | |
x.report("strings, set") { n.times { hash['key'] = 1 } } |
SQL_PARSER_REGEXP = /^(\w+)\s(\w+)\s\W*(\w+)/ | |
ActiveSupport::Notifications.subscribe "sql.active_record" do |name, start, finish, id, payload| | |
if payload[:name] == "SQL" | |
if Thread.current[:stats_context] # where I store the name of the request context | |
payload[:sql] =~ SQL_PARSER_REGEXP # $1 will be the query type, $3 the table | |
Statsd.timing("#{Thread.current[:stats_context]}.sql.#{$3}.#{$1}.query_time", | |
(finish - start) * 1000, 1) | |
end | |
end |
Inheritance is a key concept in most object-oriented languages, but applying it skillfully can be challenging in practice. Back in 1989, M. Sakkinen wrote a paper called Disciplined inheritance that addresses these problems and offers some useful criteria for working around them. Despite being more than two decades old, this paper is extremely relevant to the modern Ruby programmer.
Sakkinen's central point seems to be that most traditional uses of inheritance lead to poor encapsulation, bloated object contracts, and accidental namespace collisions. He provides two patterns for disciplined inheritance and suggests that by normalizing the way that we model things, we can apply these two patterns to a very wide range of scenarios. He goes on to show that code that conforms to these design rules can easily be modeled as ordinary object composition, exposing a solid alternative to tradi
require "rubygems" | |
require "yajl" | |
require "openssl" | |
require "socket" | |
device_token = '39cac56f 986a0e66 3c4fd4f4 68df5598 024d2ca3 8b9f307c 741c180e 9fc30c62' | |
device_token = device_token.gsub(" ", "") | |
the_byte_token = [device_token].pack("H*") | |
file = File.open("ruby_the_byte_token", "wb") |
# | |
# Cookbook Name:: jenkins | |
# Recipe:: default | |
# | |
# https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu | |
# This is super-simple, compared to the other Chef cookbook I found | |
# for Jenkins (https://github.com/fnichol/chef-jenkins). | |
# | |
# This doesn't include Chef libraries for adding Jenkin's jobs via |