Skip to content

Instantly share code, notes, and snippets.

View wjklos's full-sized avatar

William Klos wjklos

  • industrypundit, llc
  • Columbus, OH, US
  • 17:03 (UTC -04:00)
View GitHub Profile
@wjklos
wjklos / docker_rm_images_exited.txt
Last active September 3, 2015 21:13
Remove all exited Docker images that have a status of 'exited'.
# Run from command line.
docker rm $(docker ps -q -f status=exited)
@wjklos
wjklos / SinatraAPISample.rb
Created January 31, 2013 00:04
Sample of a Ruby/Sinatra basic API with rudimentary versioning and content return type selection.
require 'active_support/core_ext/hash/conversions'
require 'sinatra'
require 'json'
CONTENT_TYPES={'xml' => 'text/xml','json' => 'application/json'}
get '/api/v1/patients/?' do
{:errid => 'R1',:errdesc => 'Patient List Retrieved.',:payload => ['A','B','C','D','E','F']}.to_json
end
@wjklos
wjklos / WebAPIExample.cs
Last active December 11, 2015 23:38
Sample Web API shell for a client.
public class PatientsController : ApiController {
// GET api/patients
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/patients/5
@wjklos
wjklos / SinatraRedisPubSubStream.rb
Created May 14, 2012 20:39
A block to open a stream in Sinatra, subscribe to a Redis channel, get a value, then close.
# This all works as long as the connection stays up. I can have multiple clients all getting the same value from the published channel
# simultaneously. However, as soon as any client disconnects or times out, then the stream is marked as "closed" and everything comes
# falling down.
require 'bundler/setup'
require 'sinatra/base'
require 'sinatra/streaming'
require 'sinatra/synchrony'
require 'em-hiredis'