Skip to content

Instantly share code, notes, and snippets.

View ujifgc's full-sized avatar
💤
What's happening?

Igor Bochkariov ujifgc

💤
What's happening?
  • Izhevsk, Russia
View GitHub Profile
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"
@ujifgc
ujifgc / Guardfile
Last active September 24, 2016 13:02
A buggy Ruby Guard script for running reloadable zero-downtime Crystal Kemal apps
# 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, '.*')
@ujifgc
ujifgc / nginx.conf
Last active December 20, 2015 23:18
Scripts to serve rack apps with puma
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;
}
@ujifgc
ujifgc / vmg2xml.rb
Last active February 22, 2024 13:14
This tiny script converts SMS text message backup from VMG to XML. Formats are tested on transferring Kies bada backup to Android SMS Backup & Restore.
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"
@ujifgc
ujifgc / bm-4.rb
Created February 20, 2012 10:22
A benchmark for printing bytes
#!/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
@ujifgc
ujifgc / app.rb
Created November 21, 2011 08:11
async example app
class Swift < Padrino::Application
register Padrino::Rendering
register Padrino::Helpers
enable :sessions
get '/' do
EM.add_timer(1) do
$check ||= 0
$check += 1