Skip to content

Instantly share code, notes, and snippets.

@brycelambert
brycelambert / gist:6728861
Created September 27, 2013 13:49
bankacct
class BankAccount
attr_accessor :balance
def initialize(balance)
@balance = balance
log
end
def deposit(amount)
@balance += amount
assert_equal [:peanut], array[0,1]
assert_equal [:peanut, :butter], array[0,2]
assert_equal [:and, :jelly], array[2,2]
assert_equal [:and, :jelly], array[2,20]
assert_equal [], array[4,0]
assert_equal [], array[4,100]
assert_equal nil, array[5,0]
end
@brycelambert
brycelambert / gist:6795156
Created October 2, 2013 15:02
twitter streaming
def live_stream(client)
client = Twitter::Streaming::Client.new do |config|
config.consumer_key = ENV["CONSUMER_KEY"]
config.consumer_secret = ENV["CONSUMER_SECRET"]
config.access_token = ENV["ACCESS_TOKEN"]
config.access_token_secret = ENV["ACCESS_SECRET"]
end
topics = ["bieber"]
client.filter(:track => topics.join(",")) { |tweet| puts tweet.text }
end
@brycelambert
brycelambert / geom_spec.rb
Created October 3, 2013 19:01
circle spec
require 'spec_helper'
require_relative '../geom'
describe '#circumfrence' do
it 'should have a method called perimeter' do
expect(method(:circumfrence))
end
it 'should have an argument called radius' do
params = method(:circumfrence).parameters
@brycelambert
brycelambert / Happi_spec.rb
Created October 4, 2013 03:56
HappiTails Spec
require 'spec_helper'
require_relative '../Lab/animal'
require_relative '../Lab/person'
require_relative '../Lab/main'
require_relative '../Lab/shelter'
describe Shelter do
it "should have a method called new_client" do
should respond_to :new_client
end
@brycelambert
brycelambert / person_spec.rb
Created October 4, 2013 14:33
code person_spec
require 'spec_helper'
require_relative '../Lab/animal'
require_relative '../Lab/person'
describe Person do
let(:animal) { Animal.new('Tassy', 3, 'male', 'Dog')}
subject { Person.new('tom', 42, 2) }
it 'should be able to adopt a pet' do
subject.adopt(animal).should eq animal
@brycelambert
brycelambert / gist:7252506
Created October 31, 2013 16:17
javascript course app
var CourseApp = {
students: [],
courses: [],
teachers: [],
render_item: function(item, type) {
var html = this.render_html(item, type);
document.getElementById(type + "-list").innerHTML += html;
},
render_items: function(items_name) {
var items = this[items_name];
@brycelambert
brycelambert / gist:7267965
Created November 1, 2013 16:29
record label javascript
<!DOCTYPE html>
<html>
<head>
<title>Merge Records</title>
</head>
<body>
<script type="text/javascript">
function showdiv(a_name) {
var div_name = a_name + '_desc'
var div_array = document.getElementsByTagName('div');
var Page = {
main: document.getElementById('main'),
selector1: document.getElementById('selector1'),
selector2: document.getElementById('selector2'),
selector3: document.getElementById('selector3'),
setSelectorEvent: function() {
Page.selector1.addEventListener('click', Page.selector1Response);
Page.selector2.addEventListener('click', Page.selector2Response);
Page.selector3.addEventListener('click', Page.selector3Response);
@brycelambert
brycelambert / gist:7296036
Created November 3, 2013 23:32
album drop down
listArtists: function() {
var i = 0, list = document.getElementById('artists-list'), artistsArray = RCApp.labels[0].artists;
list.innerHTML = "";
for (; i < artistsArray.length;) {
var string = "<li><a href=\'#\' onclick=\'RCApp.displayArtistBio(\'" + artistsArray[i].name + "\')\'>" + artistsArray[i].name + "</a></li>" + RCApp.dropDownAlbums();
list.innerHTML += string;
i += 1;
};
list.style.display = 'block';
},