Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am mguymon on github.
* I am mguymon (https://keybase.io/mguymon) on keybase.
* I have a public key ASBZXyG8fiannOhVWmBsBp7S1-SaclXT0AWcxopUxOdP_go
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am mguymon on github.
  • I am mguymon (https://keybase.io/mguymon) on keybase.
  • I have a public key whose fingerprint is F334 2954 A9FA FFEE E8C2 0324 1A8E DBCB C460 E960

To claim this, I am signing this object:

@mguymon
mguymon / path_loader.bash
Last active January 2, 2016 17:29
Load up the path with symlinked dirs from the home bin dir
# Load all symlinked directories in bin to the path
for file in ~/bin/*; do
if [[ -L "$file" && -d "$file" ]]
then
export PATH=$file:$PATH
fi
done
ByteArrayOutputStream stream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(stream);
printStream.print("initial text");
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(context);
encoder.setPattern("%d{HH:mm:ss} %-5level %logger{36} - %msg%n");
encoder.start();
@mguymon
mguymon / nobrainer_rspec.txt
Last active December 21, 2015 03:48
Error 'Cannot convert OBJECT to SEQUENCE' using Rethinkdb 1.8 with No Brainer
using https://github.com/mguymon/nobrainer/tree/latest_rethinkdb
rspec spec/integration/queries/count_spec.rb
..F.
Failures:
1) count when scoped returns the number of documents
Failure/Error: SimpleDocument.where(:field1 => 'ohai').count.should == 2
RethinkDB::RqlRuntimeError:
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.0.0'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
@mguymon
mguymon / factory_girl_helper.rb
Last active January 27, 2016 07:27
RSpec helper for adding find_or_create to FactoryGirl for Rails
module FactoryGirlHelper
def find_or_create(*args)
name = args.shift
clazz = nil
# convert from underscores String to camelcase Class
if name.is_a? Hash
name = name.first[0]
clazz = name.first[1].to_s.camelize.constantize
@mguymon
mguymon / websocket.conf
Created June 11, 2013 14:05
stunnel config for secure websockets (wss://)
key = /etc/certs/server.key
cert = /etc/certs/server.crt
CApath = /etc/ssl/certs
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
setuid = stunnel4
setgid = stunnel4
pid = /var/run/stunnel4/websocket.pid
@mguymon
mguymon / stomp_callback.js
Last active December 17, 2015 18:08
Example JS that will subscribe to a WebSocket and register a callback for messages
this.YourApp = {
stompSubscribe: function(queue, callback) {
var client;
client = Stomp.client("ws://localhost:8675/");
client.connect("", "", function(frame) {
client.subscribe(queue, function(msg) {
return callback(msg);
});
});
return client;
@mguymon
mguymon / demo_stomplet.rb
Created May 25, 2013 19:06
Demo Stomplet that shows how to use a session token for auth
require 'torquebox-stomp'
class DemoStomplet
def initialize()
super
@subscribers = []
# passthrough for local messages to skip auth
@passthrough_code = "e32f53ac7569ae3a1f692177"
end