View rails-3-0-marshal-stream.rb
1 2 3 4 5 6 7 8 9 10
[:hash,
0,
2,
[:instance_variables,
[:string, 1, "session_id"],
1,
[:symbol, 0, "E"],
:true],
[:instance_variables,
[:string, 2, "f8e1b8152ba7609c28bbb17ec9263ba7"],
View locking.md

Let's examine locking in mysql.

Creating a lock timeout in mysql console:

$ mysql -e 'create database lock_test'
Query OK, 1 row affected (0.00 sec)

$ mysql lock_test -e 'create table lockables (id int primary key auto_increment)'
Query OK, 0 rows affected (0.01 sec)
View mdns.rb
1 2 3 4 5 6 7 8 9 10
require "ipaddr"
require "resolv"
require "socket"
 
class MDNS
IP = "224.0.0.251"
PORT = 5353
TTL = 255
 
def initialize(hosts=[])
View user.rb
1 2 3 4 5 6 7 8 9 10
# CREATE TABLE users (id INT NOT NULL AUTO_INCREMENT, age INT UNSIGNED, PRIMARY KEY id)
 
class User < ActiveRecord::Base
# column gives us age / age=
validates :age, presence: true, may_serve_alcohol: true
end
 
class MayServeAlcoholValidator < ActiveModel::EachValidator
def validate_each(model, attribute, value)
if model[attribute].present? && model[attribute] < 18
View lenient_csv.rb
1 2 3 4 5 6 7 8 9 10
require "strscan"
 
class LenientCSV
def initialize(source)
@scanner = StringScanner.new(source)
end
 
def each
until @scanner.eos?
yield scan_row
View action_dispatch_routing_mapper_resources_resource_param.rb
1 2 3 4 5 6 7 8 9 10
# From https://stackoverflow.com/questions/6592038/change-the-name-of-the-id-parameter-in-routing-resources-for-rails3/13427336#13427336
#
# Unfortuantely, in Rails 3, the :key option for resources was
# removed, so you can no longer easily change the name for routes
# created in this way by just passing in an extra option.
#
# All is not lost, however; it seems in Rails 4, the :param option
# has been added, which seems to do exactly what you're looking for.
# You can take a look at the Rails 3 code compared to the Rails 4
# code.
View README.md

@simpsora: any suggestions for a good way to parse multi-line messages in ruby? have command output which consists of blocks of 3 lines each, need to process each block together @sj26: maybe using scan and multiline regex?

$ ruby multiline.rb multiline.txt
["thing", "whatsit"]
["thang", "poppy"]
["thung", "scooby doo"]
["thong", "shaggy"]
View elasticsearch.yml
1 2 3 4 5 6 7 8 9 10
##################### Elasticsearch Configuration Example #####################
 
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>.
#
# Elasticsearch comes with reasonable defaults for most settings,
View virtus-multiparameter_attributes.rb
1 2 3 4 5 6 7 8 9 10
# Rails datetime_select and similar use multiparameter attributes which are
# these dawful things from the bowels of activerecord and actionpack. This
# module extends virtus models to coerce multiparameter attributes back together
# before assigning attributes.
#
# Here's the implementation for ActiveRecord:
#
# https://github.com/rails/rails/blob/11fd052aa815ae0255ea5b2463e88138fb3fec61/activerecord/lib/active_record/attribute_assignment.rb#L113-L218
#
# and DataMapper:
View using-brew-versions.sh
1 2 3 4 5 6 7 8 9 10
~$ cd $(brew --prefix)
 
/usr/local$ brew versions openssl
Warning: brew-versions is unsupported and may be removed soon.
Please use the homebrew-versions tap instead:
https://github.com/Homebrew/homebrew-versions
1.0.1h git checkout 7541601 Library/Formula/openssl.rb
1.0.1g git checkout db3123d Library/Formula/openssl.rb
1.0.1f git checkout 0b515fb Library/Formula/openssl.rb
1.0.1e git checkout 3c62281 Library/Formula/openssl.rb
Something went wrong with that request. Please try again.