This file contains hidden or 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 'open3' | |
begin | |
stdout, status = Open3.capture2("git status -uno --porcelain") | |
rescue Errno::ENOENT | |
abort "Cannot run `git status -uno --porcelain`." | |
end |
This file contains hidden or 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
(0..9999).map{|x|"%.4i"%x}.each_slice(10){|x|puts x.join("\t")} |
This file contains hidden or 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
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' |
This file contains hidden or 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 '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 |
This file contains hidden or 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
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 |