Skip to content

Instantly share code, notes, and snippets.

View supertopher's full-sized avatar

Topher Lubaway supertopher

  • Minneapolis, MN
View GitHub Profile
@supertopher
supertopher / posts_controller.rb
Created April 1, 2013 20:25
Quick look at really basic cache
class PostsController < ApplicationController
caches_page :index, :show
def index
#if nothing happens that should affect the cache leave it alone
end
def edit
#in any class that has potentional to change cache
@supertopher
supertopher / large_fibonacci.rb
Last active December 16, 2015 01:49
Large fibonacci check
def is_fibonacci?(i)
require "bigdecimal"
require "bigdecimal/math"
include BigMath
plusfour = 5 * i**2 + 4
minusfour = 5 * i**2 - 4
#second argument is number of decimels for all big num arguments
plusfour = BigDecimal.new(plusfour, 5)
@supertopher
supertopher / boggle.rb
Created June 6, 2013 22:53
Call a boggle grid of any size with random dice movement.
class BoggleBoard
# because we wanted to
def initialize (board_size = 4)
@board_size = board_size
shake!
end
def shake!
possible_dice = [
"AAEEGN",
@supertopher
supertopher / vehicle.rb
Last active December 18, 2015 09:19 — forked from aespaldi/vehicle.rb
class Vehicle
@wheels = 4
def initialize args
@color = args[:color]
end
def drive
@status = :driving
end
@supertopher
supertopher / index.html
Last active December 19, 2015 05:29 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@supertopher
supertopher / rspec.md
Last active July 27, 2018 21:58
rspec best practices

Automated Testing.

Testing is helpful for ensuring that your code runs (driver code). This is to make sure that current features work, old features still work, and future work will be easily tested. By default, every Rails application has three environments: development, test, and production.

Rails offers three kinds of testing:

  • Unit tests: 
In the context of Rails, unit tests are meant primarily to cover the domain logic in your models, which include things like validations, calculations, search methods, and any other interesting functionality that your models implement.
  • Functional tests: These provide a way to verify that the actions for a single controller are working as expected, and allow you to do things such as post data to a specific action and verify the correct response is returned
  • Integration tests: Any given session with a Rails application will span across several models and controllers. Integration tests provide a way to test those kinds of interactions. Essentia

Congratulations on making the cut for Dev Bootcamp!

This tutorial is going to help you start off on the right foot by teaching you a few things that aren't Ruby. These things are, however, important to undestand for your future in the industry. If you are running MacOS or any flavor of Linux you are going to be very comfortable fitting into a Ruby workflow. Windows users will find that since so much of Ruby workflow is based on shell tools (and Windows has no real linux shell support) life is going to be a bit more interesting.

Furthermore all staff (and and an overwhelming majority of Rubyists) use OSX. If you are on windows either get dirty and start solving these problems for yourself or check out Rails Installer

OSX Users you could of course also use Rails Installer, however, as is true or so many things pre-packaged for you: this quick boost will be a net drag in the long-term. We would prefer that you build your environment yourself s

@supertopher
supertopher / studentspec.md
Last active December 28, 2015 19:19
Topher's Suggested Student Laptop Specs

Topher's Recommended Laptops

Macbook Air 11"

Specs:

  • 1.7 Ghz Dual Core i7
  • 8GB RAM
  • 128 GB hard drive
  • Upgradable to 256GB
@supertopher
supertopher / FIREBASE.rb
Created February 6, 2014 23:14
Databases!!!!!
# 1. Require the gem sqlite3. You must `gem install sqlite3` if you get an error
# stating `cannot load such file -- sqlite3`
# This will add the gem to your local gemset
require 'firebase'
require 'faker'
# 2. Sign up for a firebase account and set the uri here
base_uri="https://luminous-fire-2162.firebaseio.com/"
# 3. Set up a connection to the database you have created