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
| load 'deploy' | |
| $stdout.sync = true | |
| set :domain, 'mydomain.example.com' | |
| set :use_sudo, true | |
| set :user, 'someuser' | |
| role :me, domain | |
| task :go, :role => [:me] do | |
| command = %Q{ruby -e "STDOUT.sync=true; 10.times { |i| puts i*3;sleep 0.5 }"} | |
| run command | |
| 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
| [diff "word"] | |
| binary = true | |
| textconv = docx-to-txt.rb -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
| source 'http://rubygems.org' | |
| gem 'sinatra' |
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 MyNamespace | |
| class MyApp < Sinatra::Base | |
| ... | |
| after do | |
| $APP_LOG.info "do some logging here" | |
| ... | |
| end | |
| error do |
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
| class FilteredLogger | |
| def initialize log, *filter_patterns | |
| @log = log | |
| @filter_patterns = filter_patterns.flatten | |
| end | |
| %w{trace debug info warn error fatal}.each do |level| | |
| class_eval %Q{ | |
| def #{level}(msg) | |
| @log.#{level}(msg) if allowed?(:#{level}, msg) |
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
| # In Ruby 1.9 the core object Random adds a | |
| # a #state method which is private. Therefore | |
| # the RandomData::Locations#state doesn't work | |
| # in 1.9.x. This wrapper class will allow us | |
| # to access the 2-letter state codes until this | |
| # is fixed. | |
| class States | |
| include RandomData::Locations | |
| end | |
| state_generator = States.new |
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
| <html> | |
| <head> | |
| <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'> | |
| </script> | |
| <script type="text/javascript" src="http://highcharts.com/js/highcharts.js"></script> | |
| <script type="text/javascript" src="http://highcharts.com/js/modules/exporting.js"></script> | |
| <script type='text/javascript'> | |
| var chart; | |
| $(document).ready(function() { | |
| chart = new Highcharts.Chart({ |
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
| #!/bin/sh | |
| if [[ "$@" =~ -(-)?h(elp)? ]] | |
| then | |
| echo '' | |
| echo 'This script will create a skeleton migration in a given directory for a given name.' | |
| echo 'It accepts up to two parameters.' | |
| echo '' | |
| echo ' 1. name of the migration (e.g. table name or description of table alteration)' | |
| echo ' 2. directory for migration (default: db/migrations)' |
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
| # Use Net::SSH to invoke prince from a Java application | |
| # http://net-ssh.github.com/ssh/v2/api/index.html | |
| class App | |
| def self.go server, user | |
| pdf = '' | |
| ssh_session( server, user ) do |ssh| | |
| ssh.open_channel do |channel| | |
| channel.exec("/usr/local/bin/prince --server --input=html - -o -") do |ch, success| | |
| abort "could not execute command" unless success |
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 'rubygems' | |
| require 'proxeze' | |
| class A | |
| attr_accessor :foo | |
| def initialize; @foo = 1; end | |
| end | |
| Proxeze.proxeze A | |
| a = A.new |