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
def paginate(collection, options = {}) | |
start = options[:start] || 0 | |
limit = options[:limit] || 0 | |
order = options[:order] | |
rest = collection.size > (start + limit) | |
page = collection.sort(order: order, start: start, limit: limit) | |
[rest, page] | |
end |
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 "cuba" | |
# Here you can add helpers, models, filters, services, etc. | |
Dir["./routes/**/*.rb"].each { |rb| require rb } | |
Cuba.use Rack::MethodOverride | |
Cuba.use Rack::Session::Cookie, | |
key: "_app_name_", | |
secret: "_app_secret_" |
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 rc | |
if (! ~ $#* 1) { | |
echo 'Usage: sc <pattern>' | |
} else { | |
grep $1: $0 | |
} | |
# 100: Continue | |
# 101: Switching Protocols |
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
#!/bin/sh | |
hi=$(expr $(tput lines) - 1) | |
cp $1 $1.ts | |
ed -s $1.ts <<-EOS | |
1i | |
.pl ${hi}v | |
. |
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 "benchmark" | |
require "cuba" | |
require "syro" | |
class HelloWorld | |
def call(env) | |
if env['REQUEST_METHOD'] == 'GET' && env['PATH_INFO'] == '/foo/bar' | |
[200, {"Content-Type" => "text/html"}, ["hello world"]] | |
elsif env['REQUEST_METHOD'] == 'GET' && env['PATH_INFO'] == '/admin' |
OlderNewer