Skip to content

Instantly share code, notes, and snippets.

James Harton jimsynz

Block or report user

Report or block jimsynz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jimsynz / mr_darcy.rb
Last active Aug 29, 2015
So, after our dopodcast episode about DCI ( I've been thinking a lot about the intersection of DCI and Promises/A+ in Ruby, and here's an example of what I've been thinking.
View mr_darcy.rb
class MrDarcy
class Context
class << self
def role role_name, &block
role_name = role_name.to_sym
roles[role_name] =
View segfault.txt
This file has been truncated, but you can view the full file.
..../Users/jnh/.rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.5/lib/rspec/core/memoized_helpers.rb:199: [BUG] Segmentation fault at 0x007fff51ad3fd8
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
View api_controller.rb
# app/controllers/api_controller.rb
class ApiController < ApplicationController
skip_before_action :verify_authenticity_token
respond_to :json
rescue_from UserAuthenticationService::NotAuthorized, with: :not_authorized
rescue_from ActiveRecord::RecordNotFound, with: :not_found
before_filter :api_session_token_authenticate!
jimsynz /
Last active Aug 29, 2015
Discussion about API for mapping endpoints in EPF, similar in concept to the Ember router.
# For example:
App.Adapter = Ep.RestAdapter.extend
namespace: '/api/v1/'
# some magic DSL.
jimsynz /
Last active Aug 29, 2015
Proposed purposes of Ruby NZ:
  1. Foster and support the Ruby programming language, it's users, community and ecosystem in New Zealand.
  2. Advocate for Open Source in general, and the Ruby programming language in particular.
  3. Provide organisational, financial and legal support for Ruby community events.
  4. Provide for the safety and welcome inclusion of all people within the Ruby community and Ruby community events regardless of; gender, gender expression, sexuality, marital status, religious belief, ethical belief, colour, race, ethnic or national origin, disability, age, political opinion, employment or family status.
jimsynz / jruby-1.7.11.rb
Last active Aug 29, 2015
Monkey patching singleton methods...
View jruby-1.7.11.rb
m = { def a; :a; end }
# => #<Module:0x3cbea6af>
method = m.instance_method :a
# => #<UnboundMethod: #<Module:0x3cbea6af>#a>
o =
# => #<Object:0x590bcaf1>
o.define_singleton_method :a, method
# TypeError: bind argument must be an instance of #<Module:0x3cbea6af>
# from org/jruby/ `define_method'
# from org/jruby/ `define_singleton_method'
View Gemfile
source ''
jem <<EOF
` ` `
`````````` ` ` ` `
,:::::::::::,,,:;, +,,,,,,,,.#@.`'::,,,,,,,,,,,+'+,,,,,;;:;,....`````````..... ':' `.,` '..,,``` :,,,,,,...,.,,,,,,,,.``...,,,,,,,....,,,,,,,,
:::::::::::,,,,' ;,,,,,,,,,;#'`::,,,,,,,,.,:: ':,; ;.````````.......` . `.,: ` #,,`';.``, :,.,,,,,,,,,,,,,,,,,....,,,,,,,,,...,,,,,,,,,
:::::::::::::+` .;.,,,,,,,,.;@. '::,,,,,,,,+ ;;`' `,,`,`,; `,``````..........`...' :.,,#.,:.`, ,,,,,,,,,,,,,,,,,,,.,,,,,,,,,,,,...,,,,,,,,,
:::::::::::;, +.,,,,,,.....`#@ :,,,,,,,,:+ .: ` #+ ' `.````. .````.............,: `,,,;+..'...` ',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...,,,,,,,,,
::::::::::+ ;,.,,,.........`:@, ',,:,,,,; .```.``'# ` ....````` .```.....
jimsynz / 00_original.js
Last active Aug 29, 2015
An exercise in refactoring horrible procedural JavaScript. Please don't be this person.
View 00_original.js
* This is a JS file from a library that our client wanted us to use. It included a dependency on a JS lib called `classie` which is
* used for adding and removing HTML classes to elements. The project already includes jQuery.
(function() {
$(document).ready(function() {
jimsynz / 01_turnstile.rb
Last active Aug 29, 2015
Source code for our No More Mr State Machine talk.
View 01_turnstile.rb
# Our simple example of a Turnstile state machine.
class Turnstile
def initialize
@state = "Locked"
def push!
@state = "Locked" if unlocked?
View Gemfile
source ''
gem 'oedipus_lex'
gem 'rake'
gem 'rspec-core'
gem 'rspec-mocks'
gem 'rspec-expectations'
You can’t perform that action at this time.