Skip to content

Instantly share code, notes, and snippets.

View thinkerbot's full-sized avatar

Simon Chiang thinkerbot

View GitHub Profile
@thinkerbot
thinkerbot / pkg.sql
Created September 16, 2011 20:54
PL/SQL example
-- sqlplus -s @ pkg.sql
set serverout on
create or replace package example
is
procedure hello (thing in varchar2);
end example;
/
create or replace package body example
@thinkerbot
thinkerbot / agent.rb
Created September 8, 2011 02:10
Proposed shell test syntax with PTY
class Agent
attr_reader :stdin
attr_reader :stdout
def initialize(stdin, stdout)
@stdin = stdin
@stdout = stdout
end
def run(inputs, max_run_time=nil)
@thinkerbot
thinkerbot / pty_test.rb
Created August 31, 2011 20:54
PTY exit status test
require 'pty'
require 'test/unit'
# See also:
# * http://stackoverflow.com/questions/3874604/pty-spawn-child-exit-code/7263243#7263243
# * http://redmine.ruby-lang.org/issues/5253
class PTYTest < Test::Unit::TestCase
def setup
system "true"
assert_equal 0, $?.exitstatus
@thinkerbot
thinkerbot / shellout.rb
Created August 28, 2011 04:24
Example of a pseudo-terminal shell via PTY
require 'pty'
require 'expect'
def shellout(shell, *lines)
prompt = /^(?:#{Regexp.escape(ENV['PS1'])}|#{Regexp.escape(ENV['PS2'])})/
lines << 'exit'
PTY.spawn(shell) do |stdin,stdout,pid|
begin
lines.each do |line|
@thinkerbot
thinkerbot / example_test.rb
Created August 25, 2011 14:38
An example in favor of -w.
require 'test/unit'
# Without warnings:
#
# $ ruby example_test.rb
# Loaded suite example_test
# Started
# .
# Finished in 0.000437 seconds.
#
@thinkerbot
thinkerbot / output.txt
Created August 13, 2011 02:26
Times to run rbenv tests on two ubuntu VMs using VirtualBox
chiangs:~/Documents/Gems/rbenv>time rake start
$ VBoxManage -q controlvm abox poweroff
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ VBoxManage -q controlvm bbox poweroff
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ VBoxManage -q snapshot abox restore CURRENT
Restoring snapshot 80fc03ef-de05-4ecb-a437-bb2bd92964ad
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ VBoxManage -q startvm abox --type headless
Waiting for the VM to power on...
@thinkerbot
thinkerbot / README.md
Created August 5, 2011 18:13
Shell test prototype

Description

This is a prototype for doing shell tests. To run:

$ ./test/suite.sh

To add another test suite, make a script in the test directory that ends with

@thinkerbot
thinkerbot / run.bat
Created August 2, 2011 20:21
Execute a powershell script via ssh
# Notes:
# 1) The input format must be specified to prevent ssh from hanging
# 2) The full path to the script is required
# 3) An SSH server must be running on the Windows box, naturally. WinSSHD
# is free for personal, non-commercial use and worked for this example.
# See http://www.bitvise.com/winsshd
#
# You have to set the execution policy for scripts so that powershell has
# permissions to run the script. To do so, search for 'Powershell' under
# the Start menu. Then right-click and 'Run as administrator' so that you
@thinkerbot
thinkerbot / snow_example.sh
Created July 28, 2011 17:56
Example usage of snow
#!/bin/sh
######################################################################
# Example usage of SNOW (Steganographic Nature Of Whitespace)
# http://www.darkside.com.au/snow/
#
# See also: http://www.cabinetmagazine.org/issues/40/sherman.php
######################################################################
if ! [ -d snow_example ]
@thinkerbot
thinkerbot / README.rdoc
Created July 21, 2011 14:32
Linking to a file with RDoc

Here is a link to the file.