Skip to content

Instantly share code, notes, and snippets.

View rachelmyers's full-sized avatar

Rachel Myers rachelmyers

View GitHub Profile
@rachelmyers
rachelmyers / strip
Created February 14, 2011 07:19
My first state machine! Hooray!
STATE_CHOPPING_FRONT = 0
#STATE_ITERATING_END = 1
STATE_CHOPPING_END = 2
STATE_FINISHED = 3
def strip(array)
state = STATE_CHOPPING_FRONT
loop do
if state == STATE_CHOPPING_FRONT then
if array[0].white_space?
@rachelmyers
rachelmyers / bubblegum.html
Created February 3, 2011 03:23
Week 4 homework example for JS class
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Bubble Gum Game</TITLE>
<SCRIPT type="text/javascript">
//<![CDATA
function bubble()
{
var answer = Math.floor(Math.random()*21);
var guess = parseInt(prompt("How many blows before this bubble bursts?"));
@rachelmyers
rachelmyers / jqueryhw.html
Created January 19, 2011 23:10
Week 2 HW Answer for BC's LP:JS class
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>JQuery Homework</TITLE>
<SCRIPT type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></SCRIPT>
<SCRIPT type="text/javascript">
var x = parseFloat(prompt("Please give me a number."))
var y = parseFloat(prompt("Please give me a number."))
var z = parseFloat(prompt("Please give me a number."))
@rachelmyers
rachelmyers / math.html
Created January 12, 2011 22:20
Answer for javascript homework class
<!--
Write a program that accepts three numbers from the user
and alerts back the the user: the sum of the numbers,
the total of the numbers multiplied together, the average
of the numbers, and, for extra credit, figure out how to
find the largest number and smallest number.
-->
<!DOCTYPE HTML>
<HTML>
@rachelmyers
rachelmyers / String JS Koans, more like Ruby Koans
Created January 4, 2011 22:15
Jasmine tests for using javascript strings, meant as a introduction to test-first js development.
// Written by Rachel Myers as a introduction to test-first javascript development.
// Inspired by and very nearly lifted from Jim Weirich's Ruby Koans, which are awesome.
// Replace the nulls to make the specs pass and reach javascript enlightenment.
describe('Strings', function () {
// Creating Strings
it('should create a new string with either single or double quotes', function() {
@rachelmyers
rachelmyers / string js koans
Created January 4, 2011 07:51
Beginnings of an introduction to test-first javascript development inspired by Jim Weirich's Ruby Koans.
// Written by Rachel Myers as a introduction to test-first javascript development.
// Inspired by and very nearly lifted from Jim Weirich's Ruby Koans, which are awesome.
describe("Strings", function() {
describe("Creating Strings", function() {
var double_quote_string;
var single_quote_string;
var talking_string;
var apostrophe_string;
@rachelmyers
rachelmyers / strstr
Created December 6, 2010 07:18
white. boards. suck.
def substring(haystack, needle)
i = 0
while i <= haystack.length
if haystack[i,(needle.length)] == needle
return i
else
i += 1
end
if i == haystack.length
return nil