Skip to content

Instantly share code, notes, and snippets.

@abrahamsangha
abrahamsangha / array_mode.rb
Created June 7, 2013 20:03
Write a method mode which takes an Array of numbers as its input and returns an Array of the most frequent values. If there's only one most-frequent value, it returns a single-element Array.
def mode(array)
hash = Hash.new(0)
array.each { |elem| hash[elem] += 1 }
hash.keep_if { |k, v| v == hash.values.max }.keys
end
class Vehicle
def initialize(args)
@color = args[:color]
@wheels = args[:wheels]
@gas_mileage = [true,false]
end
def drive
@status = :driving
end
def brake

Instructions:

  1. Download this application skeleton.
  2. Convert the app to use AJAX.
  3. Add any files you changed to your gist and submit your code.
@abrahamsangha
abrahamsangha / index.html
Last active December 20, 2015 05:39 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@abrahamsangha
abrahamsangha / zoo.js
Last active December 20, 2015 05:49 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
function Animal(kind,legs) {
this.kind = kind;
this.legs = legs;
};
var Zoo = {
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
@abrahamsangha
abrahamsangha / gist:6134215
Created August 1, 2013 19:03
Git from CL
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/1neway/quotations.git
git push -u origin master
Push an existing repository from the command line
function Cookie(type, bakeTime) {
this.type = type,
this.bakeTime = bakeTime,
this.timeBaked = 0,
this.status = "Raw"
};
Cookie.prototype = {
updateStatus: function(){
<html>
<head></head>
<body>
<pre style="word-wrap: break-word; white-space: pre-wrap;">
[{"id":1,"name":"John","created_at":"2013-08-14T20:55:47Z","updated_at":"2013-08-14T20:55:47Z"},{"id":2,"name":"Samantha","created_at":"2013-08-14T20:56:40Z","updated_at":"2013-08-14T20:56:40Z"}]
</pre>
</body>
</html>
@abrahamsangha
abrahamsangha / gist:6241947
Last active December 21, 2015 03:28
Notes on API Design

From http://pages.apigee.com/rs/apigee/images/api-design-ebook-2012-03.pdf

Routes

  • 2 base urls per resource ("/dogs" and "/dogs/1234")
  • Keep verbs out of base URLs -HTTP verbs to operate on collections and elements -Shouldn't need URL deeper than /resource/identifier/resource -Sweep parameters under HTTP ? ("GET /dogs?color=red&state=running&location=park")