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
require "benchmark" | |
module HTTP | |
def self.default_status_message_for(status_code : Int) : String | |
case status_code | |
when 100 then "Continue" | |
when 101 then "Switching Protocols" | |
when 102 then "Processing" | |
when 200 then "OK" | |
when 201 then "Created" |
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
# tested on guard-2.14.0, ruby 2.3.1, Debian 8 | |
# bugs: sometimes rb-inotify crashes on exiting guard CLI | |
module ::Guard | |
class CrystalKemal < Plugin | |
def initialize(options = {}) | |
@path = options.fetch(:path, '.') | |
@file = options.fetch(:file, 'app.cr') | |
super | |
@app_path = File.join(@path, @file) | |
@app_name = File.basename(@file, '.*') |
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
upstream swift { | |
server unix:/home/ujif/swift/tmp/puma.sock; | |
} | |
server { | |
server_name s.ujif.name; | |
root /home/ujif/swift/public; | |
location / { | |
try_files $uri @swift; | |
} |
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
require 'cgi' | |
class String | |
def extract( token ) | |
self.scan( /#{token}:(.*)/ ).flatten.first | |
end | |
end | |
puts "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n<smses>\n" |
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 | |
require 'benchmark' | |
PREFIX = %W(TiB GiB MiB KiB B).freeze | |
UNITS = %W(B KiB MiB GiB TiB).freeze | |
def as_size1( s ) | |
s = s.to_f | |
i = PREFIX.length - 1 |
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
class Swift < Padrino::Application | |
register Padrino::Rendering | |
register Padrino::Helpers | |
enable :sessions | |
get '/' do | |
EM.add_timer(1) do | |
$check ||= 0 | |
$check += 1 |