Skip to content

Instantly share code, notes, and snippets.

View jtigger's full-sized avatar
💭
☸️

John Ryan jtigger

💭
☸️
View GitHub Profile
Manually cleared again.

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@jtigger
jtigger / add-not-ready.sh
Last active April 11, 2016 13:59
Adding NotReady to all tests.
sed 's/@Test/@Test\'$'\n @Category(NotReady.class)/' ./accumulate/src/test/java/AccumulateTest.java | sed '0,/Category/s/Category/x/'
@jtigger
jtigger / Non Final Method In Constructor.java
Last active March 3, 2016 15:24
Illustration of how bad things can happen when you violate the Open-Closed Principle.
package com.example;
class BaseClass {
public BaseClass() {
System.out.println("BaseClass constructor.");
someNonFinalMethod();
}
public void someNonFinalMethod() {
System.out.println("BaseClass::someNonFinalMethod");
#! /usr/bin/env/ruby
require 'json'
RESPONSIVENESS_GOAL = 0.5 # "You have a 50/50 chance of getting a meaningful review."
def fetch_stats_for(track)
canvas_element = `curl --silent http://exercism.io/stats/#{track} | grep canvas`
stats_attr = /data-stats='(.*)'/.match canvas_element
stats_json = stats_attr[1]
@jtigger
jtigger / gradle-debug-hello-world.output.txt
Created January 3, 2016 21:31
Output from `gradle -d test`
13:30:50.538 [DEBUG] [org.gradle.internal.resource.transport.http.JavaSystemPropertiesProxySettings] Found java system property 'http.nonProxyHosts': local|*.local|169.254/16|*.169.254/16. Will ignore proxy settings for these hosts.
13:30:50.634 [INFO] [org.gradle.BuildLogger] Starting Build
13:30:50.637 [DEBUG] [org.gradle.BuildLogger] Gradle user home: /Users/jtigger/.gradle
13:30:50.638 [DEBUG] [org.gradle.BuildLogger] Current dir: /Users/jtigger/workspace/exercism/exercises/java/hello-world
13:30:50.638 [DEBUG] [org.gradle.BuildLogger] Settings file: null
13:30:50.638 [DEBUG] [org.gradle.BuildLogger] Build file: null
13:30:50.645 [DEBUG] [org.gradle.initialization.buildsrc.BuildSourceBuilder] Starting to build the build sources.
13:30:50.646 [DEBUG] [org.gradle.initialization.buildsrc.BuildSourceBuilder] Gradle source dir does not exist. We leave.
13:30:50.649 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found env project properties: []
13:30:50.649 [DEBUG] [org.gradle.initialization.
@jtigger
jtigger / Adding New Problem to a Track.md
Last active September 6, 2015 13:51
Workflows in Exercism Development

Setup the workspace

Stand-up the x-api, locally

cd ~
mkdir -p workspace/exercism && cd workspace/exercism
git clone https://github.com/exercism/x-api
cd x-api
bundle install
git submodule init
@jtigger
jtigger / person.rb
Created September 11, 2014 02:45
attr_accessor example
class Person
attr_accessor :name
attr_reader :birthdate
def initialize
@birthdate = nil
@name = "Who?!"
@phonenumber = "800-123-4567"
end
@jtigger
jtigger / attribute_logger.rb
Last active December 24, 2015 20:09
Injecting an a logging aspect on an attribute
module AttributeLogger
def self.included(target_class)
target_class.extend(ClassMethods)
end
module ClassMethods
def log_attr(attribute)
AttributeLogger.raise_cannot_install_error_on attribute if !method_defined? "#{attribute}"
old_attr_reader = instance_method("#{attribute}")
define_method("#{attribute}") do
@jtigger
jtigger / clean_method_override.rb
Last active December 23, 2015 16:09
Idiom: Clean method overwriting
# Idiom: Clean method overwriting
# Source: Jörg W Mittag -- http://stackoverflow.com/questions/4470108/when-monkey-patching-a-method-can-you-call-the-overridden-method-from-the-new-i/4471202#4471202
# Problem: you want to overwrite an existing method and be able to invoke the old method in the new one,
# but you don't want to pollute the namespace with a method alias.
# Solution: capture the existing method in a local variable, define the new method using the define_method() method, capturing
# the local variable in the closure.
# Consequences:
# - be aware of what local variables are defined. Because they are captured in the closure, they are not candidates for
# garbage collection.