Skip to content

Instantly share code, notes, and snippets.

View coffeeaddict's full-sized avatar

Hartog C. de Mik coffeeaddict

View GitHub Profile
#!/usr/bin/env ruby
require 'open3'
begin
stdout, status = Open3.capture2("git status -uno --porcelain")
rescue Errno::ENOENT
abort "Cannot run `git status -uno --porcelain`."
end
@coffeeaddict
coffeeaddict / gist:3699848
Created September 11, 2012 17:02 — forked from JiriChara/gist:3697487
ALL CREDIT CARD PIN CODES IN THE WORLD / in 1 line :-p
(0..9999).map{|x|"%.4i"%x}.each_slice(10){|x|puts x.join("\t")}
def test_with_numbers
pdef = Ruote.define do
set 'commission' => 2.310000
set 'scommission' => '2.310000'
echo 'a', :if => '${f:commission} > 0'
echo '.'
echo 'b', :unless => '${f:commission} > 0'
require 'tmpdir'
require 'ruote'
#
# blah
#
# Note: using ruote 2.3.0 (master), not too difficult to port to 2.2.0.
#
class ConvertFilesParticipant
include Ruote::LocalParticipant
@coffeeaddict
coffeeaddict / http_authentication
Created April 16, 2012 18:09 — forked from ipoval/http_authentication
Http basic authentication for padrino
module HttpAuthentication
module Basic
def authenticate_or_request_with_http_basic(user, pass, realm = 'Application')
authenticate_with_http_basic(user, pass) || request_http_basic_authentication(realm)
end
def authenticate_with_http_basic(user, pass)
if auth_str = request.env['HTTP_AUTHORIZATION']
return ActiveSupport::Base64.decode64(auth_str.sub(/^Basic\s+/, '')) == [ user, pass ].join(":")
end