Skip to content

Instantly share code, notes, and snippets.

View TravisSpangle's full-sized avatar

Travis Spangle TravisSpangle

View GitHub Profile
def solution(number)
(( (number%3).zero?? 'Fizz' : '') + ((number%5).zero?? 'Buzz' : '')).sub(/^$/, number.to_s)
end
raise unless solution(7) == "7"
raise unless solution(3) == "Fizz"
raise unless solution(5) == "Buzz"
raise unless solution(15) == "FizzBuzz"
puts "It works!"
# Please fill in the method definition below:
def Organizer 📚=📚.select{|📕|📕=~/\w{5,}/&&📕!='tomatoes'}
# Modify the solution above. Emojis are free.
# Code below will check correctness.
example_collection = [
'apples',
33,
nil,
'hat',
'tomatoes',
require 'pry'
# Build a baby names search engine.
#
# We collected baby names from various published lists and put them into a JSON object as follows:
#
# key: source list name (e.g. "2015-us-official-boys", "2015-baby-center-girls")
# value: a list of names in the order of popularity (e.g. [ "Sophia", "Emma", "Olivia", ... ])
# baby-names-data.json
# data is static
# as effecint as possible (preproccess data)
require 'rspec'
RSpec::Matchers.define :be_path do |expected|
match do |actual|
path(actual) == path(expected)
end
failure_message do |actual|
"expected that #{path(actual)} would point to #{path(expected)}"
end
@TravisSpangle
TravisSpangle / dlog
Last active November 22, 2017 20:10
Shell script to stream deis logs
#!/bin/bash
# mv dlog to ~/bin
# chmod +x ~/bin/dlog
# set default app on line 9
# use: dlog [app]
setup(){
# configure variables
app=${1:-default-deis-app}
log_dump="/tmp/.logs_dump_$app.txt"
@TravisSpangle
TravisSpangle / beer_song.rb
Created April 25, 2017 03:41
Shameless Green
class BeerSong
def song
verses(99,0)
end
def lyrics
verses 99, 0
end
def verses(starting, ending)
@TravisSpangle
TravisSpangle / home_spec.rb
Created December 17, 2016 18:20
Example of an integration test.
RSpec.describe "Home", type: :request do
before :all do
get home_path
end
describe "Index Page" do
it "works! (now write some real specs)" do
expect(response).to have_http_status(200)
end
class MrMeeseeks
attr_accessor :next, :job
def initialize(job = "find job")
@job = job
end
end
# A Mr Meeseeks Box is a queue
class MrMeeseeksBox
attr_accessor :head
@TravisSpangle
TravisSpangle / SVNNextRelease.sh
Created August 16, 2012 23:38
bash function to create new release tag
# svn directory ^/tags/release/
# 1/
# 2/
# 3/
# 4/
# usage: svnnextrelease fixes email formatting
# generated line: svn cp ^/trunk ^/tags/release/# -m'fixes email formatting'
function svnnextrelease(){
NextVersion=$(svn ls ^/tags/release | tail -n 1 | while read tag; do expr $(echo "${tag%?}") + 1; done)
@TravisSpangle
TravisSpangle / AppController.j
Created November 15, 2011 23:21
Table Delegate methods seem to fire with inconsistant events. Use the below AppController in Tests/Manual/TableTests/BorderTableTests to demonstrate the problem.
/*
* AppController.j
* TableCibTest
*
* Created by Francisco Tolmasky on July 5, 2009.
* Copyright 2009, 280 North, Inc. All rights reserved.
*/
@import <Foundation/CPObject.j>