Skip to content

Instantly share code, notes, and snippets.

View maryrosecook's full-sized avatar

Mary Rose Cook maryrosecook

View GitHub Profile
VOWELS = ["a", "e", "i", "o", "u"]
def self.indefinite_article(str)
article = ""
VOWELS.include?(str.to_s[0..0].downcase) && !str.to_s[1..1].match(/[A-Z]/) ? article = "An" : article = "A" if str
return article
end
VAGARIES = {4 => "thousand", 7 => "million", 10 => "billion", 13 => "trillion"}
def self.vagarise(num)
num = num.to_s
vaguest = num
for vagary in VAGARIES.keys().sort { |x,y| x <=> y }
if num.length >= vagary
unit = num[0..2].to_f / (10 ** (2 - (num.length - vagary)))
vaguest = unit.round().to_s + " " + VAGARIES[vagary]
end
document.onkeyup = keyCheck;
function keyCheck(e)
{
var keyId = (window.event) ? event.keyCode : e.keyCode; // get identifier of key pressed
switch(keyId)
{
// space bar
case 32:
(defn request-url [url]
(http/http-agent url :handler #(duck-streams/slurp* (http/stream %))))
(defn crawl-batch-of-urls [urls-to-crawl]
(def url-crawl-agents (map #(request-url %) urls-to-crawl))
(apply await-for 10000 url-crawl-agents) ; wait for the bastard agents to finish their crawling
url-crawl-agents)
var getMap = {};
fu.get = function (path, handler) {
getMap[path] = handler;
};
var server = createServer(function (req, res) {
if (req.method === "GET" || req.method === "HEAD") {
var handler = getMap[url.parse(req.url).pathname] || notFound;
// Make a structure to hold all the grid squares
For each grid square
Make a grid square container
// Put all the objects in the right grid square container
For each object in the world
Get the object's x and y coordinates
Determine which grid square the coordinate falls into
Add the object to that grid square container
// Make a structure to hold all the grid squares
For each grid square
Make a grid square container
// Put all the objects in the right grid square container
For each object in the world
Get the object's x and y coordinates
Determine which grid square the coordinate falls into
Add the object to that grid square container
For each tick of the clock
For every object in the game
Get all the other objects in the same grid square
For each other object in the same grid square
If object still wants to hear about square sharers in this tick
Tell the object there is a potential collision
If the object's bounding box overlaps the other's
Object reacts
Object indicates if it wants to hear about more square sharers
If dustbin is colliding with a girl
If she is moving through the left side of the dustbin
Move the dustbin horizontally so its left side is touching the girl's right
If she is moving through the right side of the dustbin
Move the dustbin horizontally so its right side is touching the girl's left
Checking for program gcc or cc : /usr/bin/gcc
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for program g++ or c++ : /usr/bin/g++
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr/local