This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Point { | |
private int x; | |
private int y; | |
public Point(int x, int y) { | |
this.x = x; | |
this.y = y; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# seq.py | |
import time | |
def countdown(n): | |
while n > 0: | |
n -= 1 | |
COUNT = 50000000 | |
start = time.time() | |
countdown(COUNT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Point(object): | |
def __init__(self, _x, _y): | |
self._x = _x; self._y = _y | |
@property | |
def x(self): | |
return self._x | |
@x.setter |
NewerOlder