Skip to content

Instantly share code, notes, and snippets.

View semmons99's full-sized avatar

Shane Emmons semmons99

View GitHub Profile

Keybase proof

I hereby claim:

  • I am semmons99 on github.
  • I am semmons99 (https://keybase.io/semmons99) on keybase.
  • I have a public key whose fingerprint is F489 C7FF 2C23 BA66 6A50 6F39 2F47 18CF EC2C 3C28

To claim this, I am signing this object:

require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "contracts"
end
include Contracts
Contract Num => 0
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "contracts"
end
include Contracts
Contract 0 => 0
defmodule Num do
defstruct [:val]
defimpl String.Chars do
def to_string(element), do: "#{element.val}"
end
end
defmodule Add do
defstruct [:left, :right]
@semmons99
semmons99 / gist:989f08fc8c7b6ef1536e
Created February 23, 2015 16:07
retry failed Resque jobs, clear failure queue
(0...Resque::Failure.count).each { |i| Resque::Failure.requeue(i); Resque::Failure.remove(i) }

Collection+JSON Extensions

1.0 Command Templates

Clients that support the Collection+JSON media type MAY be able to recognize and parse command templates found within responses. Command templates MAY consist of a data array associated with an href property. The commands arrary supports command templates.

For command templates, the name/value pairs of the data array set are sent as JSON in the body ({"id": 1, "members_to_notify": "all"}) or multipart/form-data, both via an HTTP POST.

2.0 commands

{
first_name: "Shane",
last_name: "Emmons",
_links: {
"self": {"href": "/users/1"},
"disable": {"href": "/users/1/disable"}
}
}
C:\Users\semmons99\scratch>jruby -S bundle exec rake hello
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
RaiseException.java:101:in `<init>': java.lang.NullPointerException
from Ruby.java:3529:in `newRaiseException'
from Ruby.java:3298:in `newErrnoFromLastPOSIXErrno'
from RubyKernel.java:1720:in `execCommon'
from RubyKernel.java:1660:in `_exec_internal'
from RubyKernel$INVOKER$s$1$0$_exec_internal.gen:-1:in `call'
from CachingCallSite.java:282:in `cacheAndCall'
@semmons99
semmons99 / Gemfile
Created July 8, 2012 23:44
JRuby + Bundler + Windows: "bundle exec" issue
source :rubygems
gem "rake"
@semmons99
semmons99 / recipe.rb
Created February 29, 2012 18:18
minecraft crafting data modeling exercise part 2
require "matrix"
require "forwardable"
class RecipeMatrix
extend Forwardable
def_delegators :@matrix, :to_a
def initialize(recipe)
@matrix = Matrix[*recipe]
end