This file contains hidden or 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
error_handler = lambda do | |
"An error occured!" | |
end | |
not_found(&error_handler) | |
error(&error_handler) |
This file contains hidden or 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
class MyMiddleware | |
def self.call(env) | |
new({:a => 'b'}).call(env) | |
end | |
def initialize(config) | |
@config = config | |
end | |
def call(env) |
This file contains hidden or 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
(defn euler5 [] | |
(+ 1 | |
(last | |
(take-while (fn [w] (not | |
(every? #(zero? (rem w %)) (range 1 20) ))) | |
(range 1 1000000000000 1))))) | |
;; Takes about 5 mins on my machine | |
(defn euler5b [] | |
(first (drop-while |
This file contains hidden or 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
require 'my_app' | |
MyApp.set :logger, MyFancyLogger.new | |
run MyApp |
This file contains hidden or 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 | |
# | |
# Released under MIT License | |
# Copyright (c) 2009 Markus Prinz | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or 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
my_handler = lambda do | |
# stuff | |
end | |
get '/foo', &my_handler | |
post '/bar', &my_handler |
This file contains hidden or 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
eschaton :: ~/Projects » cat scratch.rb | |
# encoding: utf-8 | |
str = "This is ä strïng with ümläuts in it" | |
regex = / (\p{Alpha}) / | |
puts __ENCODING__ | |
puts str.encoding | |
puts regex.encoding |
This file contains hidden or 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
class MyAwesomeMiddleware | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
return_value = @app.call(env) | |
do_awesome_post_request_processing |
This file contains hidden or 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
--- | |
layout: nil | |
--- | |
<?xml version="1.0" encoding="utf-8"?> | |
<feed xmlns="http://www.w3.org/2005/Atom"> | |
<title>The Nuclear Squid</title> | |
<link href="http://nuclearsquid.com/feed.xml" rel="self"/> | |
<link href="http://nuclearsquid.com/"/> | |
<updated>{{ site.time | date_to_xmlschema }}</updated> |
This file contains hidden or 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
Rubinius Crash Report #rbxcrashreport | |
[[Exception]] | |
A toplevel exception occurred | |
undefined local variable or method `this_does_not_exist' on an instance of Object. (NameError) | |
Backtrace: | |
Kernel(Object)#this_does_not_exist (method_missing) at kernel/delta | |
/kernel.rb:79 | |
{ } in Object#__script__ at -e:1 |