A proof of concept of having Sinatra like routes inside your controllers.
Since the router is gone, feel free to remove config/routes.rb
.
Then add the file below to lib/action_controller/inline_routes.rb
inside your app.
framework 'Cocoa' | |
class NSColor | |
def toCGColor | |
color_RGB = colorUsingColorSpaceName(NSCalibratedRGBColorSpace) | |
## approach #1 | |
# components = Array.new(4){Pointer.new(:double)} | |
# color_RGB.getRed(components[0], | |
# green: components[1], | |
# blue: components[2], |
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
require 'minitest/autorun' | |
### | |
# Test to demonstrate TCO in Ruby. Tested in 1.9.2+ | |
class TestTCO < MiniTest::Unit::TestCase | |
code = <<-eocode | |
class Facts | |
def fact_helper(n, res) | |
if n == 1 | |
res |
This script installs a patched version of ruby 1.9.3-p194 with DTrace probes, boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.
Many thanks to funny-falcon for the performance patches and to Aaron Patterson for the DTrace instrumentation.
find ~ -name '*.log' -print0 | xargs -0 -L1 stat -f'%z %N' | sort -rn | tee fat-logfiles.txt | head | |
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt |
The reason why you might get certificate errors in Ruby 2.0 when talking HTTPS is because there isn't a default certificate bundle that OpenSSL (which was used when building Ruby) trusts.
Update: this problem is solved in edge versions of rbenv and RVM.
$ ruby -rnet/https -e "Net::HTTP.get URI('https://github.com')"
net/http.rb:917:in `connect': SSL_connect returned=1 errno=0 state=SSLv3
read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
You can work around the issue by installing a certificate bundle that you trust. I trust Mozilla and curl.
require "raindrops" | |
class UnicornConnectionMonitor | |
def initialize(app, options = {}) | |
@app = app | |
@statsd = options.fetch(:statsd) | |
end | |
def call(env) | |
if linux? && unicorn? |
=> Booting WEBrick | |
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000 | |
=> Call with -d to detach | |
=> Ctrl-C to shutdown server | |
[2013-03-06 01:02:27] INFO WEBrick 1.3.1 | |
[2013-03-06 01:02:27] INFO ruby 2.0.0 (2013-02-24) [x86_64-darwin11.4.2] | |
--- 1 | |
/monkeys/index |