Skip to content

Instantly share code, notes, and snippets.

View prayagupa's full-sized avatar
💭
Neta

Prayag prayagupa

💭
Neta
View GitHub Profile
@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 / 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 / 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 / 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}
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 {
sealed abstract class AVLTree[A <% Ordered[A]] {
def +(v:A):AVLTree[A]
def -(v:A):AVLTree[A]
def reconstruct:AVLTree[A]
def depth:Int
def contains(v:A):Boolean
def size:Int
def isEmpty:Boolean
def nonEmpty:Boolean
def toList:List[A]
@prayagupa
prayagupa / devops.sh
Last active August 29, 2015 14:06 — forked from edokeh/index.js
##usage ./devops.sh
createAscii(){
echo "
_oo0oo_
o8888888o
88' . '88
(| -_- |)
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
{
"Statement": [
{
"Action": [
"route53:ChangeResourceRecordSets",
"route53:GetHostedZone",
"route53:ListResourceRecordSets"
],
"Effect": "Allow",
"Resource": [
  1. Install VirtualBox on your machine
  2. Disable login credential: $ VBoxManage setproperty websrvauthlibrary null
  3. Download and uncompress the following image https://s3.amazonaws.com/vmfest-images/ubuntu-10-10-64bit-server.vdi.gz
  4. Clone the image to the directory where you want it to be permanently stored: $ VBoxManage clonehd /path/to/downloaded/ubuntu-10-10-64bit-server.vdi /path/to/permanent/location/ubuntu...-server.vdi
    • This should produce a uuid for your new image. Keep it around
  5. Start VirtualBox (the GUI) and:
    1. Create an new image Linux - Ubuntu (64bit)
  6. Select "Use existing hard disk" and if your newly cloned image doesn't appear in the drop-down list, click on the folder icon and find the image in your hard disk (the one you just cloned)