Write a file named two-threads.rb.
t1 = Thread.new{ while true; end }
t2 = Thread.new{ while true; end }
t1.join
t2.join
module MyMethods | |
def my_public_method | |
puts "Public" | |
end | |
protected | |
def my_protected_method | |
puts "Protected" | |
end |
## | |
# Note from Ruby Pocket Reference | |
# | |
# Since constants refer to objects, the contents of the object | |
# to which the constant refers may change without Ruby generating | |
# a warning. Thus, Ruby constants are called *mutable*, because, | |
# although the constant is only expected to refer to a single | |
# object throughout the program, what's contained in that object | |
# may vary. |
require 'rubygems' | |
require 'madeleine' | |
class Employee | |
attr_accessor :name, :number, :address | |
def initialize(name, number, address) | |
@name = name | |
@number = number | |
@address = address |
require 'benchmark' | |
require 'faraday' | |
require 'faraday_middleware' | |
class Wendi | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
puts 'wendi requesting...' |
class Foo | |
def i_method | |
@foo = '' | |
end | |
@bar = '' | |
class << self | |
@baz = '' |
Write a file named two-threads.rb.
t1 = Thread.new{ while true; end }
t2 = Thread.new{ while true; end }
t1.join
t2.join
[34] pry(main)> edit -h | |
Usage: edit [--no-reload|--reload|--patch] [--line LINE] [--temp|--ex|FILE[:LINE]|OBJECT|--in N] | |
Open a text editor. When no FILE is given, edits the pry input buffer. | |
When a method/module/command is given, the code is opened in an editor. | |
Ensure `Pry.config.editor` is set to your editor of choice. | |
edit sample.rb edit -p MyClass#my_method | |
edit sample.rb --line 105 edit MyClass | |
edit MyClass#my_method edit --ex |
Now $git show-branch master server client
shows like this:
<-- commit0 <-- commit1 <-- commit2 master
\
\-- commit3 <-- commit4 server
\
\-- commit5 <-- commit6 client
File.open("stats/stats_#{Time.now.to_i}.tsv","w") do |of| | |
lines = `git log --format=format:"%an\t%ae\t%ce"`.split("\n").uniq | |
stats = lines.reduce({}) do |ret, line| | |
author, a_email, c_email = line.strip.split("\t") | |
ret[author] ||= {} | |
ret[author][:a_email] ||= [] | |
ret[author][:c_email] ||= [] | |
ret[author][:a_email] << a_email unless ret[author][:a_email].include? a_email | |
ret[author][:c_email] << c_email unless ret[author][:c_email].include? c_email | |
ret |
require 'digest/sha1' | |
require 'zlib' | |
require 'fileutils' | |
# put_raw_object("what is up, doc?", 'blob') | |
def put_raw_object(content, type) | |
# Generate SHA-1 | |
header = "#{type} #{content.length}\0" # => "blob 16\000" | |
store = header + content # => "blob 16\000what is up, doc?" | |
sha1 = Digest::SHA1.hexdigest(store) # => "bd9dbf5aae1a3862dd1526723246b20206e5fc37" |