Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcin Kulik sickill

View GitHub Profile
View rack-tidy-output.txt
lenny ~/workspace/rack-tidy % ruby app.rb
== Sinatra/0.9.1.1 has taken the stage on 4567 for development with backup from Mongrel
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 1 column 60 - Warning: discarding unexpected </div>
Info: Document content looks like HTML 3.2
2 warnings, 0 errors were found!
127.0.0.1 - - [08/May/2009 20:58:07] "GET / HTTP/1.1" 200 79 0.0054
View rack-tidy.rb
require 'rubygems'
require 'tidy'
require 'sinatra'
module Rack
class Tidy
def initialize(app)
@app = app
::Tidy.path = "/usr/lib/libtidy-0.99.so.0" # or "/usr/lib/libtidy.A.dylib" on Mac
end
View quicksort.rb
class Array
def qsort
return self if empty?
select { |x| x < first }.qsort + [first] + select { |x| x > first }.qsort
end
end
View gist:131538
require 'ruby2ruby'
$q = []
def queue_code(args={}, &blk)
(c = Class.new).class_eval { define_method :proc, blk }
$q << { :code => Ruby2Ruby.translate(c, :proc), :args => args }
end
def run_all_queued
View gist:144375
# $Id: PKGBUILD,v 1.36 2009/06/22 13:09:26 sergej Exp $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Miroslaw Szot <mss@czlug.icis.pcz.pl>
_doc_root=/srv/http/nginx
_server_root=/etc/nginx
_conf_path=${_server_root}/conf
_tmp_path=/var/spool/nginx
_log_path=/var/log/nginx
_user=http
View gist:144376
# $Id: PKGBUILD,v 1.36 2009/06/22 13:09:26 sergej Exp $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Miroslaw Szot <mss@czlug.icis.pcz.pl>
_doc_root=/srv/http/nginx
_server_root=/etc/nginx
_conf_path=${_server_root}/conf
_tmp_path=/var/spool/nginx
_log_path=/var/log/nginx
_user=http
View rack-revision-info.rb
# Copyright 2009 Marcin Kulik (sickill)
require 'nokogiri'
module Rack
class RevisionInfo
INJECT_ACTIONS = [:after, :before, :append, :prepend, :swap, :inner_html]
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S %Z"
def initialize(app, opts={})
View gist:221445
require 'sinatra'
require 'dm-core'
require 'dm-types'
APP_ROOT = File.dirname(__FILE__)
DB_PATH = File.expand_path(File.join(APP_ROOT, 'db.sqlite3'))
DataMapper.setup(:default, "sqlite3://#{DB_PATH}")
class Media
include DataMapper::Resource
View config.ru
require 'rubygems'
require 'sinatra'
run Sinatra::Application
View spec_extensions.rb
$_groups = []
class Spec::Runner::Configuration
def before_spec
before(:all) do
top_level_group = self.class.to_s[/Merb::Test::ExampleGroup::([^:]+)/, 1]
unless $_groups.any? { |g| top_level_group == g }
$_groups << top_level_group
yield
end