Skip to content

Instantly share code, notes, and snippets.

Avatar

TJ Stankus tjstankus

View GitHub Profile
@solnic
solnic / rom_mapper_and_anima.rb
Last active Aug 29, 2015
ROM mapper with anima model
View rom_mapper_and_anima.rb
require 'rom'
require 'anima'
class User
include Anima.new(:id, :name, :tasks)
end
class Task
include Anima.new(:title)
end
@jodosha
jodosha / Gemfile
Last active Dec 9, 2020
Full stack Lotus application example
View Gemfile
source 'https://rubygems.org'
gem 'rake'
gem 'lotus-router'
gem 'lotus-controller'
gem 'lotus-view'
group :test do
gem 'rspec'
gem 'capybara'
@IanWhitney
IanWhitney / links.md
Last active Aug 29, 2015
Reading material suggested during the Torquebox OOD class in Durham, 2014
View gtm_osx.bash
# Usage: gtm 111222333 or gtm 111-222-333
function gtm(){
number=`echo $1 | sed 's/-//g'`
open "gotomeeting://SALaunch?Action=Join&MeetingID=$number"
}
View output
using Ruby 1.9.3-p327-perf
$ ruby split_benchmark.rb
naive_regex
6.320000 0.130000 6.450000 ( 6.798818)
naive_squeeze
6.770000 0.070000 6.840000 ( 7.122865)
assigned_regex
5.710000 0.060000 5.770000 ( 5.869347)
assigned_squeeze
@avdi
avdi / life.rb
Created Sep 30, 2012
Game of Life, mildly functional version
View life.rb
#!/usr/bin/env ruby
# The game board, at one point in time
class BoardGeneration
# How an instance will build a copy with a new grid
def self.from_grid(grid)
allocate.tap do |bg|
bg.grid = grid
end
@tooky
tooky / card_creator.rb
Created Jul 6, 2012 — forked from gma/card_creator.rb
Moving response callbacks out of controller
View card_creator.rb
class CardCreator < Struct.new(:listener)
def create(iteration, attributes)
card = iteration.cards.build(attributes)
if card.save
listener.created(card)
else
listener.create_failed(card)
end
end
end
View markdown2evernote.rb
#!/usr/bin/env ruby -wKU
# Adapted from Brett Terpstra’s original “Markdown to Evernote” service (http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/)
# Martin Kopischke 2011 – License: Creative Commons Attribution Share-Alike (CC BY-SA) 3.0 Unported (http://creativecommons.org/licenses/by-sa/3.0/)
# Changes: – create only one Evernote note per (Multi)Markdown input passed (instead of one per line)
# – do not choke on shell escape characters (use Tempfile instead of shell pipe for osascript)
# – default to MultiMarkdown 3 executable (instead of MMD 2 Perl script)
# – make smart typography processing optional (set SMARTY to 'false' to bypass processing;
# note smart typography cannot be disabled in MMD 3.0 and 3.0.1
# – handle both smart typography processing scripts (ie. SmartyPants.pl)