Skip to content

Instantly share code, notes, and snippets.

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
@jacaetevha
jacaetevha / .gitconfig
Created January 4, 2012 22:40
a script to output txt from the word/document.xml portion of a .docx file
[diff "word"]
binary = true
textconv = docx-to-txt.rb -t
source 'http://rubygems.org'
gem 'sinatra'
module MyNamespace
class MyApp < Sinatra::Base
...
after do
$APP_LOG.info "do some logging here"
...
end
error do
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)
@jacaetevha
jacaetevha / create_uk_expatriates.rb
Created September 30, 2011 18:35
usage of random_data gem
# 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
@jacaetevha
jacaetevha / highcharts_without_markers.html
Created September 22, 2011 14:06
Highcharts without markers
<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({
@jacaetevha
jacaetevha / create_sequel_migration.sh
Created June 15, 2011 13:31
Creates a skeleton migration file for Sequel in a timestamp format
#!/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)'
@jacaetevha
jacaetevha / better-prince-invocation-from-java.rb
Created March 11, 2011 03:05
A Better Invocation of Prince from Java, using JRuby and Net::SSH
# 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
@jacaetevha
jacaetevha / proxeze_example.rb
Created February 2, 2011 19:24
Using proxeze
require 'rubygems'
require 'proxeze'
class A
attr_accessor :foo
def initialize; @foo = 1; end
end
Proxeze.proxeze A
a = A.new