Skip to content

Instantly share code, notes, and snippets.

View colemanfoley's full-sized avatar

Coleman Foley colemanfoley

View GitHub Profile
@colemanfoley
colemanfoley / .block
Created July 15, 2018 19:29 — forked from mbostock/.block
Tidy Tree
license: gpl-3.0
border: no
height: 2000
@colemanfoley
colemanfoley / findElements.js
Last active December 16, 2015 13:19
Solutions to a couple of interview questions.
/*
The main function for finding elements by CSS selector. It checks which type
of selector is being passed in, then either finds the elements right there or
calls a helper function to find the elements.
*/
var findElements = function (selector) {
if (selector[0] === ".") {
return document.getElementsByClassName(selector.slice(1));
}
else if (selector[0] === "#") {
@colemanfoley
colemanfoley / histogram.js
Created April 11, 2013 20:42
Histogram drawer
var testArray = [[0,3], [2,2], [1,1], [1,1]];
//This is the main function, which calls the helper functions.
var drawHistogram = function(array){
//These two steps prepare the inputs for the block that actually draws the histogram.
var combinedHeightsArray = combineHeights(array);
var orderedArray = orderAndFlattenArray(combinedHeightsArray);
//Drawing the histogram. The max height determines how many times drawLine is called.
//It draws the lines from the top down.
@colemanfoley
colemanfoley / README.md
Created March 27, 2013 23:03
The updated readme (from superbackup branch)

puckhead

###puckhead.nodejitsu.com

A two-player air hockey game where you move your mallet with your head!

###How to use:

  • Allow webcam usage in browser
@colemanfoley
colemanfoley / gist:5218525
Created March 22, 2013 02:34
jitsu deploy error output
info: Welcome to Nodejitsu coleman
info: jitsu v0.12.8, node v0.8.21
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing application dependencies in node server.js
warn: Local package version appears to be old
warn: The package.json version will be incremented automatically
warn: About to write /Users/colemanfoley/code/playlist-me/public/playlist-me-helper/package.json
data:
data: {
@colemanfoley
colemanfoley / gist:4029325
Created November 7, 2012 02:55
Weather app
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
raw = open('http://api.wunderground.com/api/59431618fd2e7dae/geolookup/conditions/q/CA/Yuba_City.json').read
processed = JSON.parse(raw)
yuba_city = processed['current_observation']
puts "Yuba City is " + yuba_city['feelslike_string']
@colemanfoley
colemanfoley / gist:3856313
Created October 9, 2012 02:57
Shape classes
class Shape
def get_color
return color
end
def set_color(color)
@color = color
end
def can_fit?(shape)
@colemanfoley
colemanfoley / gist:3836436
Created October 4, 2012 21:02
Print grid method
def print_grid(x = 5, y =5)
row_0 = "00000"
row_1 = "00000"
row_2 = "00000"
row_3 = "00000"
row_4 = "00000"
if y == 0
row_0[x] = "X"
@colemanfoley
colemanfoley / gist:3783235
Created September 25, 2012 17:17
Numbers into Words recursively
module InWords
#The method for turning integers 1-19 into the appropriate strings.
def under20
array_under20 = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
return array_under20[self]
end
#The method for turning integers 20-99 into the appropriate strings.
def under100
@colemanfoley
colemanfoley / Book class.rb
Created September 20, 2012 22:09
Book class
class Book
attr_accessor :title
def initialize
@title = ""
end
def title=(new_title)
fixed_title = ""
title_array = new_title.split
title_array.each do |word|