Skip to content

Instantly share code, notes, and snippets.

View distributedlife's full-sized avatar

Ryan Boucher distributedlife

View GitHub Profile
@distributedlife
distributedlife / puzzle-block-1.java
Last active December 17, 2015 23:49
P2 Magazine - Issue 1 - Puzzle Gists
public int deliverBusinessValue() {
int value = 10;
try {
value = 20;
throw new NotEnoughValueDeliveredException();
} catch (Exception e) {
value = 30;
return value;
} finally {
@distributedlife
distributedlife / demo.feature
Created June 2, 2013 01:58
A simple gist for testing embedding.
And Live Sale is updated to start now
And auctioneer enters into the Live Sale
And seller enters into the Live Sale
And Following buyers have registered for the Live Sale
| role |
| buyer_1 |
| buyer_2 |
When auctioneer starts the Live Sale
@distributedlife
distributedlife / setup_app.sh
Last active December 16, 2015 11:08
What I'm using to spin up the EC2 instance for book generation
#rvm
curl -L https://get.rvm.io | bash -s stable --autolibs=enabled
source /home/ubuntu/.rvm/scripts/rvm
rvm install 1.9.3-p194
#app
cd ~/
git clone https://github.com/distributedlife/makebook.git
cd makebook
bundle install
@distributedlife
distributedlife / find_double_words.rb
Last active December 15, 2015 13:39
repeated words in my writing.
Dir["*.tex"].each do|filename|
File.open(filename).each do |line|
puts "#{filename} - #{r.match(line)} - #{line}" unless r.match(line).nil?
end
end
define(['cricket/server_player', 'lib/event_emitter'], function(ServerPlayer, EventEmitter) {
"use strict";
return function(fielding_ai, bowling_ai, batting_ai) {
var _this = new ServerPlayer();
_this.init = function() {
_this.typename = "ai";
EventEmitter.call(_this);
@distributedlife
distributedlife / usage.coffee
Last active December 14, 2015 19:59
The problem is the usage.coffee class needs to call "set_momentum" on both batter and bowler and then wait for both of them to respond that they have completed. This has to be async because neither, one or both batter and bowler could be a human player on the wire
return (batter, bowler, scorer, field) ->
_this = this
_this.init = function() {
_this.steps["set_momentum"] = new WaitForAll([batter, bowler], '/public/over/set_momentum/complete', _this.draw_hand);
_this.steps["draw_hand"] = new WaitForAll([batter, bowler], '/public/over/draw_hand/complete', _this.play_each_ball);
}
_this.set_momentum = () ->
_this.steps["set_momentum"].start("set_momentum", field)
@distributedlife
distributedlife / 1. source.java
Last active December 14, 2015 16:09
Can calling finally change the value of what is returned by a catch?
public class MyClass {
public static int test_my_return() {
int value = 10;
System.out.println("value = " + value);
try {
value = 20;
System.out.println("value = " + value);
throw new Exception();
TextureManager::Atlas::Node* TextureManager::Atlas::Node::insert( const TextureWithIDT& textureToInsert ) {
if (children.first && children.second) {
// branch node, try children
Node* newNode = children.first->insert( textureToInsert );
if (newNode) {
return newNode;
}
return children.second->insert( textureToInsert );
@distributedlife
distributedlife / parse.rb
Created January 9, 2013 06:32
threw together some code to parse heroku downtime json to determine relevance to app
require 'rubygems'
require 'json'
require 'date'
ignore = ["Shared Database Server Offline", "Elevated Error Rates Around Bamboo", "Emergency Maintenance Window on Bamboo and Aspen HTTP stacks", "Emergency Maintenance Window for Aspen/Bamboo Deploys", "Intermittent Git Errors", "Emergency Maintenance on a Shared Database Server", "Emergency Maintenance on Logging Infrastructure ", "Errors Launching Terminal Attached Processes"]
records = ""
File.open("issues.json") do |file|
file.readlines.each do |line|
records += line
@distributedlife
distributedlife / after.rb
Created November 2, 2012 08:29
composite scopes
def self.duplicates_sets
duplicate_sql = <<-SQL
SELECT form, language_id, idiom_id, pronunciation, count(*)
FROM translations
GROUP BY form, language_id, idiom_id, pronunciation
HAVING count(*) > 1
SQL
ActiveRecord::Base.connection.execute(duplicate_sql)
end