Skip to content

Instantly share code, notes, and snippets.

View ahimmelstoss's full-sized avatar

Amanda Himmelstoss ahimmelstoss

View GitHub Profile
@ahimmelstoss
ahimmelstoss / listings_controller_spec.rb
Last active April 6, 2017 21:03
spec for listings controller
require 'rails_helper'
RSpec.describe ListingsController, :type => :controller do
render_views
let(:json) { JSON.parse(response.body) }
describe "GET /listings.json" do
before do
get :index, format: :json
class Hello
def call(env)
[200, {'Content-Type' => 'text/html'}, ["Hello Rack!"]]
end
end
run Hello.new
RSpec.configure do |config|
# Use color in STDOUT
config.color_enabled = true
# Use color not only in STDOUT but also in pagers and files
config.tty = true
# Use the specified formatter
config.formatter = :progress # :progress, :html, :textmate
end
# # Roman Numerals
# The Romans were a clever bunch. They conquered most of Europe and ruled it for hundreds of years. They invented concrete and straight roads and even bikinis. One thing they never discovered though was the number zero. This made writing and dating extensive histories of their exploits slightly more challenging, but the system of numbers they came up with is still in use today. For example the BBC uses Roman numerals to date their programmes.
# The Romans wrote numbers using letters - I, V, X, L, C, D, M. (notice these letters have lots of straight lines and are hence easy to hack into stone tablets).
# Write a function to convert from normal numbers to Roman Numerals: e.g.
# ```
# 1 => I
pigeon_data = {
:color => {
:purple => ["Theo", "Peter Jr.", "Lucky"],
:grey => ["Theo", "Peter Jr.", "Ms .K"],
:white => ["Queenie", "Andrew", "Ms .K", "Alex"],
:brown => ["Queenie", "Alex"]
},
:gender => {
:male => ["Alex", "Theo", "Peter Jr.", "Andrew", "Lucky"],
:female => ["Queenie", "Ms .K"]
# # Binary Secret Handshake
# > There are 10 types of people in the world: Those who understand binary, and those who don't.
# You and your fellow flatirons are of those in the "know" when it comes to binary decide to come up with a secret "handshake".
# ```
# 1 = wink
# 10 = double blink
# 100 = close your eyes
# Download this file:
# https://gist.github.com/scottcreynolds/ac1b5c8d96de0c91bf7c/download
# Run it from your terminal with:
# ruby ruby_phone_format.rb
# (Just make sure you are in the right directory)
# ======================================
# Ignore All This Code
# ======================================
def prime?(number)
tries = 0 #keep track for efficiency
prime = !(2...number).any? do |i|
tries += 1
number % i == 0
end
#is prime if it is NOT divisible by any number evenly from 2 through the number
prime_in_words = prime ? "prime" : "not prime" #if true, else false
@ahimmelstoss
ahimmelstoss / hasketball.rb
Created October 11, 2013 18:45
hasketball
game =
{
:team1 =>
{
:name => "New York Necks",
:colors => ["yellow", "brown"],
:players =>
{
"Giraffe 1" =>
{
require 'json'
require 'open-uri'
html_tag =
'<html>
<head>
</head>
<body>
<ul>
LI TAGS