Skip to content

Instantly share code, notes, and snippets.

View prayagupa's full-sized avatar
💭
Neta

Prayag prayagupa

💭
Neta
View GitHub Profile
import spark.SparkContext
import SparkContext._
/**
* A port of [[http://blog.echen.me/2012/02/09/movie-recommendations-and-more-via-mapreduce-and-scalding/]]
* to Spark.
* Uses movie ratings data from MovieLens 100k dataset found at [[http://www.grouplens.org/node/73]]
*/
object MovieSimilarities {
@prayagupa
prayagupa / FinagleHttpServer.scala
Last active February 14, 2017 17:58 — forked from vastdevblog/ExampleServer.scala
Example of a Finagle server
package com.vast.example
import java.net.InetSocketAddress
import java.util.UUID
import java.util.concurrent.{Executors, TimeUnit}
import com.google.common.base.Splitter
import com.twitter.finagle.http.Http
import com.twitter.finagle.builder.{Server, ServerBuilder}
import com.twitter.finagle.service.TimeoutFilter
import com.twitter.finagle.{Service, SimpleFilter, GlobalRequestTimeoutException}
@prayagupa
prayagupa / Remove Duplicates from Sorted Array.scala
Last active September 9, 2015 05:32 — forked from guolinaileen/Remove Duplicates from Sorted Array.java
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.For example,Given input array A = [1,1,2],Your function should return length = 2, and A is now [1,2].
object Solution {
def removeDuplicates(A : Array[Int]) : Array[Int] = {
val length=A.length
if(length==0 || length==1) A
var index=1
for(compareIndex <- 1 to length) {
if(A(compareIndex)!=A(compareIndex-1)) {
A(index)=A(compareIndex)
index=index+1
}
@prayagupa
prayagupa / e-commerce.md
Created October 8, 2015 03:49 — forked from hjr3/e-commerce.md
Examples of RESTful API calls for E-commerce platforms

Examples of RESTful API calls for E-commerce platforms

These examples are type 3 RESTful API requests and responses. The JSON-HAL specification is used to implement HATEOAS.

Some of the examples are based on my work as architect of the RESTful API at http://www.hautelook.com. All proprietary information has been removed.

Relevant links

@prayagupa
prayagupa / introrx.md
Created October 10, 2015 03:35 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@prayagupa
prayagupa / mass_insert_mongo.js
Created December 1, 2015 06:22 — forked from jimeh/mass_insert_mongo.js
Simple MySQL vs. MongoDB Insert benchmark.
for (var i=0; i < 100000; i++) {
db.mass_insert.save({
"first_name": "James",
"middle_name": "Richard",
"last_name": "Windsgate",
"email": "jamesrichardwindsgate@email.com"
});
};
@prayagupa
prayagupa / latency.markdown
Created December 4, 2015 01:47 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

import akka.actor._
import com.eventstream.PackageArrivedEvent
import com.eventstream.publisher.PackageArrivedPublisher
import com.eventstream.subscriber.PackageArrivedSubscriber
object EventStreamApplication extends App {
implicit val system = ActorSystem("event-stream")
@prayagupa
prayagupa / README.md
Created April 2, 2016 18:27 — forked from elben/README.md
Using core.async for Producer-consumer Systems

Using core.async for Producer-consumer Systems

# Set up input file
repeat 10000 echo "." >> input

# Run inline
time lein run inline < input > output

# Run async
@prayagupa
prayagupa / 2.Example.md
Last active July 22, 2016 16:15 — forked from varemenos/1.README.md
Git log in JSON format

Here is an example in Javascript based on a package I'm working on for Atom:

var format = '{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},';

var commits = [];

new BufferedProcess({
    command: 'git',
 args: [