Skip to content

Instantly share code, notes, and snippets.

View dsabanin's full-sized avatar
💭
It's Complicated

Dmitry Sabanin dsabanin

💭
It's Complicated
View GitHub Profile
root: "/Users/railsmonk/xfiles"
server_ip: "*"
apache2_configs_directory: "/sw/etc/apache2/alpha.d"
hooks_path: "#{root}/application/script/x"
storage_path: "#{root}/storage"
server_restart_marker: "/tmp/restart-server-please.flag.%d"
## Send emails about exceptions to
exception_recipients:
- sdmitry@gmail.com
#!/bin/sh
rake spec
@dsabanin
dsabanin / pre-commit.sh
Created September 8, 2008 08:51
Save this file as .git/hooks/pre-commit. No broken tests in repo
#!/bin/sh
# Save this file as .git/hooks/pre-commit
rake spec
"<p>blah".tidy # => "<p>blah</p>"
"blah".tidy # => "blah"
"blah<p>".tidy # => "blah"
"blah".tidy(:show_body_only => false) # =>
# Renders:
# "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
# \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
# Mocks a request to OpenID server with given response status.
# If you give it a hash of args as a third argument, it will act
# like information about user transmitted from OpenID server.
class ActiveSupport::TestCase
# Example:
# mock_openid_response("http://identity.url", OpenID::Consumer::SUCCESS,
# 'fullname' => 'Joe Black',
# 'email' => 'joe.black@gmail.com',
# 'nickname' => 'joeeeey')
@dsabanin
dsabanin / install-magma-1.1.st
Created April 26, 2011 01:38
Install Magma 1.1r in Pharo 1.2
Deprecation raiseWarning: false.
Gofer new
squeaksource: 'MetacelloRepository';
package: 'ConfigurationOfMagma';
load.
((Smalltalk at: #ConfigurationOfMagma) project version: #stable) load: 'Tester'.
@dsabanin
dsabanin / array_permutation_ext.rb
Created January 6, 2012 09:33
Array#each_permutation
# Taken here http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/247669. Reformatted.
# based on the C++ standard library's implementation by Ken Bloom
class Array
def next_permutation!
return self if length<2
i = length-1
while true
ii = i
i -= 1
@dsabanin
dsabanin / gist:2146349
Created March 21, 2012 11:39
Midge example
(fact "configuration"
server-port => number?
server-url => string?
server-static-path => string?)
(fact "on-connect handler"
(on-connect --connection--) => anything)
(fact "on-disconnect handler"
(on-disconnect --connection--) => anything)
@dsabanin
dsabanin / gist:4118737
Created November 20, 2012 15:51
Idea for ruby test framework
class User < ActiveRecord::Base
test_context(:inherit => [:account_context]) do
@password = "123456"
@user = User.create(:login => "dima",
:first_name => "Dima",
:last_name => "Pupkin",
:password => @password,
:password_confirmation => @password,
:account => @account)
def benchmark(name, &blk)
t1 = Time.now
ret = blk.call
time = Time.now - t1
$STATSD.timing(name, time)
[ret, time]
end
retvalue, time = benchmark("svn-commit-time") do
`svn command blah`