Skip to content

Instantly share code, notes, and snippets.

View radavis's full-sized avatar

Richard Davis radavis

View GitHub Profile
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicitly require it in any files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, make a
# separate helper file that requires this one and then use it only in the specs
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
require_relative 'helper'
# example call:
# breweries = BeerMappingProject.new.city_search("Boston")
# breweries is an array of Brewery objects
class BeerMappingProject
include HTTParty
base_uri 'http://beermapping.com/webservice'
require 'ruby-progressbar'
progress = ProgressBar.create(format: '%a %bᗧ%i %p%% %t',
progress_mark: ' ',
remainder_mark: '・',
starting_at: 1)
99.times do
sleep(0.1)
progress.increment

Task Galaxy

ER Diagram

 +----------+            +------------+
 |users     |            |tasks       |
 +----------+            +------------+
 |*email    |           /|*name       |
 |first_name+------------+description |
@radavis
radavis / GongHitter.ino
Created September 27, 2014 21:09
Arduino code to control a servo
// GongHitter
// by Vikram and Richard
#include <Servo.h>
int STEP = 5;
int DELAY = 500;
unsigned long TIME_BETWEEN_HITS = 3600000; // one hour
//1000 * 60 * 60 * 24;
@radavis
radavis / gist:b2825396f48d80477129
Created October 16, 2014 18:51
Multiple model search
# routes.rb
get 'search' => 'search#index'
# search_controller.rb
class SearchController < ApplicationController
def index
@kitchens = Kitchen.where("city ilike ?", "%#{params[:q]}%")
@meals = Meal.where("name ilike ?", "%#{params[:q]}%")
end
require 'httparty'
require 'cgi'
require 'dotenv'
require_relative 'brewery'
Dotenv.load
# example call:
# breweries = BeerMappingProject.new.city_search("Boston")
# breweries is an array of Brewery objects
# gem install rack
# gem install thin
require 'rack'
require 'rack/lobster'
# Rack::Builder allows us to glue together various Rack middlewares
# together to form a single application
# The webapp proc, which responds to the #call method, must return