Skip to content

Instantly share code, notes, and snippets.

View raorao's full-sized avatar

Srinivas Rao-Mouw raorao

  • San Francisco, CA
View GitHub Profile
//JavaScript Promises! They are the next big thing in JavaScript, the coolest thing
//you've never heard about in the coolest language out there. And as of last year,
//They are supported by new builds of Chrome. It's only a matter of time until
//they're supported everywhere. So...what are they?
//Well, in essence, a Promise represents an asynchronous task. While the task is
//being completed, it is represented by a Promise object, and once completed it
//returns the value you expected. They are a tool to handle asynchronous functionality
//in JavaScript, as well as make your code more readable, extendable, and better at
//handling errors. So what do they look like? Well before we can do that, we need to
#HTTParty isn't broken! it deals with 304 errors as per RFC 2616,
#returning a response with headers but no body.
require 'httparty'
response = HTTParty.get("https://api.github.com/users/octocat", {
:headers => {"User-Agent" => "HTTParty"},
})
etag = response.headers["etag"]

Sampler

The challenge is to implement a program called "sample" that outputs a sorted list of random numbers to the console. Your program should be run like this:

ruby sample MEMBERS LIMIT

MEMBERS is the number of results you want the program to output, and LIMIT is the upper limit for the sample range. All results should be greater than or equal to 0 and less than LIMIT. Some examples:

BalanceValidator

The challenge is to write a function that evaluates whether an ordered list of edge characters — parentheses, brackets, or curly braces — is correctly balanced according to the following rules:

  1. Each opening character must be eventually followed by its corresponding closing character. (e.g. an opening parenthesis must be followed by a closing parenthesis, but not necessarily immediately.)

  2. The characters must be nested correctly, so that each pair of characters maintains a valid scope. (e.g. an opening bracket cannot be immediately followed by a closing curly brace.)

This challenge must be written in JavaScript. For ease of use, I suggest using node.

PacMan!

Given a map, your program should find the shortest path between PacMan and Food.

The map is defined as a two-dimensional array, with the following key:

  • 'o' = open space
  • 'w' = wall
  • 'F' = food
  • 'P' = PacMan
@raorao
raorao / witty_gem_name.rb
Created December 4, 2014 18:32
Google Docs ORM spec
# all permissions/setup are handled through the google docs interface. basically, this isn’t a DSL for google docs. figure that shit out yourself.
# all querying logic happens in ruby. find is provided for simplicity.
# no optimizing for speed. this is a google doc db after all.
# connections only occur when necessary. no preloading. avoid unncessary connections after first.
# configuration must be simple. and preferably self-contained within file.
#not tied to language. would be cool to do this as a front-end JS library too.
class User < APIModel
def self.configure
@SPREADSHEET_URL = ‘someurl’
/ invalid
%div
%span
%span
%span{ |
"foo" => "bar", |
"baz" => 'quz' }
/ valid
%div
Query = {}
Query.new = function() {
var queryAttributes = {
filters: [],
beginDate: null,
endDate: null,
attribute: null
}
@raorao
raorao / foo.md
Last active August 29, 2015 14:18

bar foo

Keybase proof

I hereby claim:

  • I am raorao on github.
  • I am raorao (https://keybase.io/raorao) on keybase.
  • I have a public key whose fingerprint is 2B05 C1E8 A751 C8FF DE93 20B6 CC2B F1A1 2EC2 F87E

To claim this, I am signing this object: