Skip to content

Instantly share code, notes, and snippets.

View hwatkins's full-sized avatar

Hugh Watkins hwatkins

View GitHub Profile
@hwatkins
hwatkins / pipetest.rb
Created December 8, 2010 18:31
Test case for Broken pipe in ruby libvirt
require "libvirt"
def nested
puts "nested"
h = Libvirt.connect
h.domains.each do |d|
puts "Domain: #{d.name}"
end
end
@hwatkins
hwatkins / amqp_client
Created October 8, 2010 17:48
A rake file to pull the correct amqp_client libraries
SOURCE_DIRS=%w[deps/rabbitmq-server/src deps/rabbitmq-erlang-client/src]
INCLUDE_DIRS=%w[deps/rabbitmq-server/include deps/rabbitmq-erlang-client/include]
FILES=%w[rabbit_writer.erl
rabbit_reader.erl
rabbit_framing_amqp_0_8.erl
rabbit_framing_amqp_0_9_1.erl
rabbit_framing_channel.erl
rabbit_basic.erl
rabbit_binary_generator.erl
rabbit_binary_parser.erl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% this module models a typical manager/worker pattern, where manager may spawn a large number of workers
%% required behaviour:
%%
%% 1) manager must log unexpected worker exits
%%
%% - manager must trap exits in init function -> 'process_flag(trap_exit, true)'
%% - workers must be spawned with spawn_link
%% - worker exit messages are handled by manager handle_info handler [where they can be logged etc]
-module(stopwatch).
-behaviour(gen_server).
%% Server API
-export([start_link/0, stop/0]).
%% Client API
-export([start_timer/0, stop_timer/0, read_timer/0]).
%% gen_server callbacks
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Hugh Watkins">
<!-- Date: 2010-06-25 -->
<script type="text/javascript"
#!/usr/bin/racc
# -*- encoding: utf-8 -*- Lapis Racc Parser Class
# Andy Brown <neorab@gmail.com> [April, 12, 2010]
/* This is a BNF style parser generator grammar for the
* Lapis Language to be used by racc. Racc is a tool
* much like Yacc or Bison implemented for Ruby.
*
* Racc will parse this file and create a lapis.tab.rb
* file that contains a Parser class with a do_parse
#!/usr/bin/env ruby
#
# Discover the contribution status of a user for all their watched repos: owner, collaborator, or watcher
# Returns JSON { "repo" => { ... }, "owner" => is project owner?, "collaborator" => has collaborator access? }
#
# Returns either Array of JSON above; or streams each JSON result as discovered (--stream flag)
#
# Usage:
#
# Save to file github_user_collaborations.rb
$:.unshift('~/rufus/rufus-tokyo/lib')
require 'benchmark'
require 'rubygems'
require 'faker'
require 'date'
#
# the data
#
%%
%% Load balancer
%%
%% Author: Krzysztof KliÅ› <krzysztof.klis@gmail.com>
%%
%% This program is free software: you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by
%% the Free Software Foundation, either version 3 of the License, or
%% (at your option) any later version.
%%
Where would the target audience becoming from? I assume primarily Java or .NET
I’m not qualified for .NET, but most the questions I get when you mention using Ruby (primarily Rails) instead of Java (J2EE) is they equate that to the View Layer, not the model and controller part.
So I would pick a sample application that would really show the entire stack. Here would be some ideas:
Large Retailer: System allows customers to be notified when product X is back in stock at their local store. The Ruby system must be able to talk back with Mainframe for order shipments and a J2EE application for pricing and customer records. In this case the only model is the “in stock request” the login information for the customer may or may not reside in the Ruby system
Airline: System to send SMS messages about Flight Delays based on Frequent Flyer information. Assume the airlines current Web interface will be where the customer enables this, so there is no user focused View layer instead it’s primarily a web interface