Skip to content

Instantly share code, notes, and snippets.

View RPC v.s. REST
RPC - non uniform API for creating an entity
Long createGreeting(Greeting greeting)
Long newFortune(Fortune fortune)
REST - uniform entity creation
POST /greetings {“message”: “Hello”}
POST /fortunes {“fortune”: “This is a fortune”}
karanparikh / gist:2c12c637d71e3f5265f5
Last active Aug 29, 2015
Key for the /foo resource
View gist:2c12c637d71e3f5265f5
"key": {
"x": [
"y": 123,
"key.with.dots": "val"
karanparikh / gist:134d90ce6d4045eeb3c9
Last active Aug 29, 2015 1.0 URL v.s. 2.0 URL for GET requests
View gist:134d90ce6d4045eeb3c9 1.0 URL: /foo/key.x%5B0%5D=a1&key.x%5B1%5D=a2&key.y=123&key~2Ewith~2Edots=val 2.0 URL: /foo/(key:(x:List(a1,a2)),y:123,key.with.dots:val)
View gist:1059794
# this does not work!
from import Car
karanparikh / gist:1059713
Created Jul 2, 2011
Python simple import
View gist:1059713
# import a specific module
from vehicle.four_wheels import car
my_car = car.Car(transmission="automatic")
# import a specific class within a module
from import Car
my_car = Car(transmission="automatic")
# import everything from a module into the current namespace
from vehicle.four_wheels import *
View gist:1059735
# global scope these variables so that
# we can use them throughout our code
Car = None
Bus = None
# exciting stuff happening here
# now, based on the variable vehicle
View gist:1059797
# this works!
_Car = __import__("vehicles.four-wheels-car", globals(), locals(), ["Car"])
Car = _Car.Car
View gist:1062395
karanparikh@ubuntu:~$ node -v
karanparikh /
Created Oct 1, 2015
Script to analyze blog posts I wrote
from sys import argv
from os import listdir
from re import split
from collections import Counter
class Post(object):
def __init__(self, title, content):
self.title = title
self.content = map(lambda w: w.lower(), content)
env.roledefs = {
"service_A": ["hostA1", "hostA2", ...],
"service_B": ["hostB1", "hostB2", ...],
"service_C": ["hostC1", "hostC2", ...],