Skip to content

Instantly share code, notes, and snippets.

View natemurthy's full-sized avatar

Nathan Murthy natemurthy

View GitHub Profile
public class Point {
private int x;
private int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
# author: [email protected]
#
# Make sure your gevent version is >= 1.0
import gevent
from gevent.wsgi import WSGIServer
from gevent.queue import Queue
from flask import Flask, Response
import time
"""
Each 'import' statement demarcates a separate file
"""
# map.py
import time
start = time.time()
print("\n(Map) multiplying 60 million elements by 2")
dbls=map(lambda n: 2*n, range(60000000))
print("(Reduce) sum: %d" % sum(dbls))
// map.scala
object `map` {
def main (args: Array[String]) {
val start = System.nanoTime
println("\n(Map) multiplying 60 million elements by 2")
val dbls = (1L to 60000000L).toArray.map(_*2)
println("(Reduce) sum: %d".format(dbls.sum))
val end = System.nanoTime
println("Total MapReduce time: %f".format((end-start)/1.0e9))
}
# seq.py
import time
def countdown(n):
while n > 0:
n -= 1
COUNT = 50000000
start = time.time()
countdown(COUNT)
inputFile = open('names_emails.txt')
names_emails = inputFile.read(); inputFile.close()
nameEmailArray = names_emails.split(",")
nameEmailDict = {}; emailOnly = []
for name_email in nameEmailArray:
token = name_email.split(' <')
if len(token) == 1:
emailOnly.append(token[0].replace('>',''))
elif len(token) == 2:
class Point(object):
def __init__(self, _x, _y):
self._x = _x; self._y = _y
@property
def x(self):
return self._x
@x.setter