Skip to content

Instantly share code, notes, and snippets.

View djanowski's full-sized avatar

Damian Janowski djanowski

View GitHub Profile
require "open3"
commands = <<-EOS
echo 'foo'
cd /tmp
ls -1
EOS
require "open3"
class SSH
def initialize(server)
@server = server
end
def start
Open3.popen3("ssh -T #{@server}") do |stdin, stdout, stderr|
threads = []
require "sinatra/base"
require "haml"
class Foo
include Sinatra::Templates
def self.views; end
def self.caller_locations; [["Foo", 1]]; end
def bar
require "sinatra/base"
require "haml"
class Foo
include Sinatra::Templates
def self.views; end
def self.caller_locations; [["Foo", 1]]; end
def bar
#! /bin/bash
if [ -z "$1" ]; then
cat /dev/stdin > /tmp/pbcopy
pbcopy /tmp/pbcopy
cat /dev/null > /tmp/pbcopy
else
arch -i386 osascript -e 'tell application "System Events"' -e "set the clipboard to (read posix file \"$1\" as text)" -e 'end tell';
fi
require "sinatra"
get("/") { "Hello world" }
if $0 == __FILE__
require "rack/test"
require "webrat"
require "test/unit"
Webrat.configure do |config|
require "open3"
module Sh
def sh(cmd)
out, err, status = nil
Open3.popen3(cmd) do |_in, _out, _err, _wait_thr|
out = _out.read.sub(/\n$/, "")
err = _err.read.sub(/\n$/, "")
status = _wait_thr.value.exitstatus
module Test
module Sessions
%w{get post put delete head}.each do |verb|
eval <<-EOS
def #{verb}(uri, params = {}, env = {}, &block)
inject_session(env)
super(uri, params, env, &block)
end
EOS
end
require "monitor"
require "bench"
@monitor = Monitor.new
@mutex = Mutex.new
block = lambda { 1 + 1 }
def just_call(&block)
yield
# How to migrate your Redis database to Ohm 0.1 RC1
require "ohm"
require "ohm/utils/upgrade"
Ohm.connect :port => 6380 # or load your application environment
# Provide the names of the models you need to upgrade.
Ohm::Utils::Upgrade.new([:User, :Post, :Comment]).run