Skip to content

Instantly share code, notes, and snippets.

View ahimmelstoss's full-sized avatar

Amanda Himmelstoss ahimmelstoss

View GitHub Profile
Working with the cloud CLI:
`spark cloud login`
Positive end (shorter end) of the LED pin needs to be curcuit
Negative end (longer end) of LED pin needs to be on the resister
Negative Goes to Ground
Resister connects to the Input, and one below the Input point, connect the Cable; one end of Cable goes to the Ground (GND)
Motor:
Red positive
@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
@ahimmelstoss
ahimmelstoss / index.json.jbuilder
Created July 29, 2014 20:03
jbuilder for listings index
json.array!(@listings) do |listing|
json.extract! listing, :id, :address, :listing_type, :title, :description, :price, :neighborhood_id, :host_id
end
@ahimmelstoss
ahimmelstoss / listings_controller.rb
Created July 29, 2014 19:55
Listings Controller
class ListingsController < ApplicationController
before_action :set_listing, only: [:show, :update, :destroy]
# GET /listings
def index
if listing_type = params[:listing_type]
@listings = Listing.where(listing_type: listing_type)
elsif price = params[:price]
@listings = Listing.where(price: price)
else
@ahimmelstoss
ahimmelstoss / factories.rb
Created May 14, 2014 20:51
factory girl for blog lab
FactoryGirl.define do
# tags
factory :happy_tag, class: Tag do |t|
t.name "happy"
end
factory :funny_tag, class: Tag do |t|
t.name "funny"
end
factory :fluffy_tag, class: Tag do |t|
t.name "fluffy"
host_user = User.new
host_user.name = "Host User"
host_user.save
guest_user = User.create(:name => "Guest User")
not_attending_user = User.create(:name => "Not Attending User")
attending_user = User.create(:name => "Attending User")
birthday = Event.create(:name => "Birthday", :host => host_user)
holiday_party = host_user.hosted_events.create(:name => "Holiday Party")
# Configuring Our Prompt
# ======================
# This function is called in your prompt to output your active git branch.
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# This function builds your prompt. It is called below
function prompt {
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