Skip to content

Instantly share code, notes, and snippets.

View christopherhill's full-sized avatar

Christopher Hill christopherhill

View GitHub Profile
// calendar
class Appointment {
constructor(dateStamp, description, id) {
this.id = id;
this.date = dateStamp || new Date();
this.description = description || 'New Appointment';
}
@christopherhill
christopherhill / gist:ca8301d069a8fade953db27214a23e46
Created August 30, 2016 03:03
Reverse a string with recursion
// string reverse using recursion
var str = 'abcdefg';
function reverse(original, reversed) {
if (!reversed) {
return reverse(original, [original.charAt(original.length - 1)]);
} else {
var len = reversed.length;
reversed.push(original.charAt(original.length - len - 1));
// palindrome
var words = ['otto', 'hannah', 'schlumberger'];
var test = function(words) {
for (var i = 0; i < words.length; i++) {
var result = palindrome(words[i]);
console.log(result);
}
};
'use strict';
function justify(str, lineLength) {
if (str.length >= lineLength) {
throw 'Line length is equal to or exceeds justification length';
}
function genArrayOfSpaces(len) {
var arr = [];
@christopherhill
christopherhill / gist:da7e45c198cbad2d76e6
Last active August 29, 2015 14:06
Exercise (get second degree connections from graph data)
var graph = {
nodes:
[{
userId: 'chill',
city: 'Sonoma' },
{
userId: 'sjobs',
city: 'Mountain View' },
{
userId: 'bgates',
<!DOCTYPE html>
<html>
<head>
<title>MJ Test</title>
<style>
.passed { color: green; }
.failed { color: red; }
class Automata():
'Represents a cellular automata with configurable params:'
' - number of columns, defaults to 64'
' - number of iterations, defaults to 32'
' - true symbol, defaults to *'
' - false symbol, defaults to -'
entries = []
rows = 0
cur_row = 0
.container {
/* removed width here */
border: 1px solid black;
height:80px;
overflow-x:auto;
overflow-y:hidden; /* turns off y-scrollbar */
display:block;
}
.image-container {
background: blue;
h1, h2, h3, h4, h5, h6 {
font-weight: normal;
}
form, input, button {
border: none;
margin: 0;
padding: 0;
}