Installation
chmod +x git-clog
cp git-clog /usr/local/bin # Or whereever that's in your path
# Simple Rack Middleware to kill Unicorns after X requests. | |
# | |
# Use as follows in e.g. your rackup File: | |
# | |
# Rack::Harakiri.after = 50 | |
# use Rack::Harakiri | |
# | |
module Rack | |
class Harakiri | |
def make_pony_eyes_pink | |
before, Pony.eye_color = Pony.eye_color, :pink | |
yield | |
ensure | |
Pony.eye_color = before | |
end |
~/dev/parslet$ rvm use 1.8.7-p302 | |
Using /Users/ncr/.rvm/gems/ruby-1.8.7-p302 | |
~/dev/parslet$ bundle exec rspec spec/parslet/mem_stress_spec.rb | |
23.030000 1.290000 24.320000 ( 24.331595) | |
. | |
Finished in 24.33 seconds | |
1 example, 0 failures | |
~/dev/parslet$ rvm use 1.9.2 | |
Using /Users/ncr/.rvm/gems/ruby-1.9.2-p180 |
This week, we'll have some fun with MacRuby. James is a “Voice commanded servant for OSX” you can write dialogs for. Here's a lightning talk by Florian Hanke, James' creator.
For example, you could set up a time dialog to ask James what time it is:
<< James, what time is it?
>> It is currently 10:15.
Of course, that's a pretty simple example. This week's challenge is to write the most useful or fun dialog for James. You can do about anything, like asking James to do API requests, reboot your machine, run your tests, or whatever you can think of. A simple dialog is enough, but please remember to keep the code nice and understandable.
Haven't used MacRuby before? Just really easy to install using the binary installer. Be sure to check out James' README and have a look through its [example directory]
# Version 1: Fails, since this file is not reloaded. | |
# | |
module Loader | |
def self.reload | |
puts "Loading application." | |
load File.expand_path "../worker.rb", __FILE__ # Change this to new_worker | |
load File.expand_path "../signal.rb", __FILE__ | |
end | |
# We repeatedly fill a hash. | |
# We use the same keyspace each time after the first time. | |
# | |
# My expectation was that the total memory used would not increase significantly after the first iteration. | |
# | |
h = {} | |
10.times do |i| | |
100000.times do |i| | |
h[i.to_s] = [1,2,3] | |
end |
// When you are in the diff page of a GitHub PR | |
// And want to hide all the Pods/* files in that diff page, use this: | |
// Paste that in your Web Inspector's console | |
var nodes = document.evaluate("//div[@class='file-header' and starts-with(@data-path,'Pods/')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null ); | |
for(i=0; i<nodes.snapshotLength; ++i) { | |
nodes.snapshotItem(i).parentNode.hidden = true | |
} | |
// Or even better, create a bookmark with this code for easy quick access: |
So I'm always forgetting how to do this! I guess I'm only ever updating Ruby versions every now and then.
$ chruby
will display your installed rubies and show you the version you're currently using in your shell.
ruby-2.1.2
ruby-2.2.1
ruby-2.3.1