This file contains 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
# command line usage | |
local$ ssh -gR 8022:localhost:22 remote | |
remote$ scp -P 8022 file.tgz localhost: | |
# local ~/.ssh/config | |
Host remote | |
HostName remote.example.com | |
RemoteForward 8022 localhost:22 | |
# remote ~/.ssh/config |
This file contains 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
desc "Tell app to use local gems and tweak bundler to not break with gems coming from git" | |
task :enable_local_gems_and_bundler do | |
run %(perl -pi -e 'print "ENV[\\"GEM_HOME\\"] = \\"/home/#{user}/.gems\\"\\nGem.clear_paths\\n" if $. == 1' #{release_path}/config/application.rb) | |
run "echo 'BUNDLE_PATH: /home/#{user}/.gems/bundler' >> #{release_path}/.bundle/config" | |
end |
This file contains 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/perl | |
use strict; | |
use warnings; | |
use File::Find; | |
File::Find::find( | |
sub { | |
return unless -f; |
This file contains 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 _vnc_setup | |
d = '22' # vnc desktop number | |
ENV['DISPLAY'] = "localhost:#{d}" | |
hostname = `hostname`.chomp | |
vnc_pid_file = File.join(ENV['HOME'], ".vnc", "#{hostname}:#{d}.pid") | |
if File.exist?(vnc_pid_file) | |
pid = File.open(vnc_pid_file).read.chomp | |
log "Xvnc appears to be already running with pid #{pid}" | |
if `/bin/ps -p #{pid}`.split.last =~ /Xvnc/ | |
return |
This file contains 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
#code.rb | |
class Resource | |
end | |
module SomeModule | |
class Consumer | |
def singleton_resource | |
@@sr ||= Resource.new | |
end |
This file contains 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
run Proc.new {|env| [200, {"Content-Type" => "text/html"}, "Hello Rack!"]} |
This file contains 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
RSpec::Matchers.define :validate_inclusion_of do |field, list| | |
match do |actual| | |
list.each do |i| | |
actual.should allow_value(i).for(field) | |
end | |
end | |
end |
This file contains 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 Sinatra | |
class Base | |
class << self | |
def run!(options={}) | |
set options | |
handler = detect_rack_handler | |
handler_name = handler.name.gsub(/.*::/, '') | |
# handler specific options use the lower case handler name as hash key, if present | |
handler_opts = begin | |
send(handler_name.downcase) |
This file contains 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
# Somewhere in you env.rb /spec_helper.rb or the like | |
require_relative "rest-assured-server" | |
at_exit do | |
RestAssuredServer.stop | |
end | |
RestAssuredServer.start |
This file contains 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 'socket' | |
server = TCPServer.new('127.0.0.1', 0) | |
free_port = server.addr[1] | |
server.close | |
OlderNewer