This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> This is a Shortwave configuration file | |
> http://shortwaveapp.com/ | |
> | |
> Some triggers copied from benpickles (http://gist.github.com/43371) | |
> | |
> Urls may contain the following replacement tokens: | |
> | |
> %s → search terms | |
> %r → URL of current page | |
> %d → domain part of the current URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html | |
Hi everyone, I'm Chris Wanstrath. | |
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But | |
then I took a few moments and thought, Wait, why? Why me? What am I supposed | |
to say that's interesting? Something about Ruby, perhaps. Maybe the | |
future of it. The future of something, at least. That sounds | |
keynote-y. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
require "rubygems" | |
require "mysql" | |
require "benchmark" | |
# Given 10,000 records in `venues`, I want to fetch the last records, sorted by descending calculated `distance` from a given geographic location. | |
TIMES = 1_000 | |
connection = Mysql.real_connect("localhost", "username", "password", "database") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
require "rubygems" | |
require "mysql" | |
require "benchmark" | |
# Given 100,000 records in `venues`, I want to fetch the last thirty records, performing and ascending sort on indexed `name` column. | |
TIMES = 10 | |
connection = Mysql.real_connect("localhost", "username", "password", "database") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="javascript:%20(function(){%20var%20container=document.getElementById('container');%20if(container.className.match(/showgrid/)){%20container.className%20=%20container.className.replace('%20showgrid',%20'');%20}%20else%20{container.className%20+=%20'%20showgrid';}})()">Toggle BluePrint</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
require "benchmark" | |
TIMES = 100_000 | |
ARRAY = (1..1_000).to_a | |
Benchmark.bm(30) do |b| | |
b.report "each" do | |
TIMES.times do |i| | |
ARRAY.each do |element| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
require "benchmark" | |
TIMES = 10_000_000 | |
class Demo | |
def initialize | |
@ivar = nil | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bluepill.application("app_name") do |app| | |
app.process("app_name") do |process| | |
process.start_command = "cd /u/apps/app_name/current && /usr/local/bin/unicorn_rails -c /u/apps/app_name/current/config/unicorn.conf.rb -E production -D" | |
process.stop_command = "kill -QUIT `cat /u/apps/app_name/current/tmp/pids/unicorn.pid`" | |
process.restart = "kill -USR2 `cat /u/apps/app_name/current/tmp/pids/unicorn.pid`" | |
process.stdout = process.stderr = "/u/apps/app_name/current/log/unicorn.log" | |
process.pid_file = "/u/apps/app_name/current/tmp/pids/unicorn.pid" | |
process.checks :mem_usage, :every => 10.seconds, :below => 250.megabytes, :times => [3, 5] | |
process.uid = "app" | |
process.gid = "app" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
require "rubygems" | |
require "benchmark" | |
require "active_support" | |
TIMES = 10_000_000 | |
class Project | |
attr_reader :ivar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This module is intended for test usage, it helps to compare Time instances with millisecond precision. | |
# Ruby has a fine-grained internal representation of Time values, so if you try: | |
# Time.now == Time.now # => false | |
# By including this module the above comparison returns true. | |
module ComparableWithFixnum | |
def self.included(base) | |
base.class_eval do | |
alias :"original_==" :== | |
end |