Skip to content

Instantly share code, notes, and snippets.

View skylar's full-sized avatar

Skylar Woodward skylar

  • New York, NY
  • 02:46 (UTC -04:00)
  • X @skylar
View GitHub Profile
@skylar
skylar / dm_string_enum.rb
Created July 24, 2014 03:06
A string-backed Enum type for DataMapper
require 'dm-types/support/flags'
module DataMapper
class Property
class StringEnum < String
min 1
include Flags
def initialize(model, name, options = {})
@skylar
skylar / api_output_marshal-mass_pay.rb
Last active August 29, 2015 14:20
account number - short circuit status
class ApiOutputMarshal::MassPay
attr_reader :mass_pay
def initalize(mass_pay)
@mass_pay = mass_pay
end
def status
last_two = mass_pay.bank_account.account_number[-2..-1].to_i
if (0..5).member?(last_two)
module.exports = function(defaults) {
var env = EmberApp.env(),
isProductionLikeBuild = ('production' === env) || ('staging' === env);
var app = new EmberApp(defaults, {
minifyCSS: { enabled: !!isProductionLikeBuild },
minifyJS: { enabled: !!isProductionLikeBuild },
fingerprint: {
enabled: !!isProductionLikeBuild,
generateRailsManifest: true,
exclude: ['manifest.json']
def calculate(s)
stack = []
num = 0
op = '+'
s.each_char.with_index do |char, i|
if char.between?('0', '9')
num = num * 10 + char.to_i
end
FIRST_OPERATORS = Set.new(['+', "-"])
SECOND_OPERATORS = Set.new(['*', '/'])
def is_digit?(char)
char[0].between?('0', '9')
end
def is_operator?(char)
op_order(char) > 0