Skip to content

Instantly share code, notes, and snippets.

@samklr
samklr / GameOL.rb
Created December 8, 2012 15:23
Code Retreat
require "test/unit"
class World
def initialize
@cells = [[false, false, true],
[false, true, false],
[false, false, false],
]
end
public void insert(E value)
{
SkipNode<E> x = header;
SkipNode<E>[] update = new SkipNode[MAX_LEVEL + 1];
for (int i = level; i >= 0; i--) {
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 {
package com.mansur.scalding
import com.twitter.scalding._
import org.apache.lucene.search.spell._
import org.apache.mahout.common.distance.TanimotoDistanceMeasure
import org.apache.mahout.math.DenseVector
import org.apache.commons.math.util.MathUtils
/**
women jeans Levi's 512 512 Perfectly Slimming Bootcut, Midnight Star Wash jeans 54.00 39.00
women jeans Tommy Hilfiger Jeans Hope Boot Cut, Caroline Original Wash jeans 69.50 54.00
women jeans Lauren Jeans Co. Jeans Slimming Bootcut, Rinse Wash jeans 80.00 65.00
women jeans INC International Concepts Jeans Curvy-Fit Skinny Ankle-Length jeans 69.00 48.99
women jeans MICHAEL Michael Kors Jeans Skinny Colored Denim jeans 89.50 69.99
women tops Karen Scott Top Short-Sleeve Boat-Neck top 29.00 12.99
women tops Cable & Gauge Top Three-Quarter-Sleeve Solid Twist Front top 24.98 19.99
women tops Style&co. Top Long-Sleeve Striped Button-Down Shirt top 39.98 29.99
women tops Style&co. Top Bell-Sleeve Printed Tunic top 49.98 35.99
women tops INC International Concepts Top Short-Sleeve Ruched Tee top 29.50 24.99
@samklr
samklr / FastCode.java
Created April 13, 2013 16:26
DevKings FastCode .....
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class Challenge2 {
List <Arret> arretList = new ArrayList<Arret>();
@samklr
samklr / FastCode.txt
Created April 13, 2013 16:27
Fast Code Challenge 2
s maximum pour trouver une solution : 240:00
La région Loire-Atlantique a décidé d'ouvrir une grande quantité de données publiques.
Parmi celles-ci, la liste des arrêts, horaires et circuits TAN (Transports de l'Agglomération Nantaise). La région veut mettre à disposition des utilisateurs TAN un outil permettant de calculer le chemin le plus court entre deux arrêts en utilisant le réseau TAN.
En entrée de votre programme sont fournies les données dont vous avez besoin, au format ASCII :​
# Skip lists are relatively new comers to the data structures scene (invented in the 90s).
# They differ from most data structures by being probabilistic rather than deterministic.
#
# Search, insertion and deletion times are expected to be O(log n) with a very high probability.
#
# Skip lists are normal linked lists with additional layers that enable queries to *skip*
# elements. They are much simpler than other O(log n) structures like Red Black Trees
#
# The skip list supports inserting multiple values for the same key. Values will be stored
# in a list attached to that key. Even a single value will be stored in a list
public synchronized int read() throws IOException {
int result = in.read();
if (result != -1) {
pos++;
}
return result;
}
@samklr
samklr / EMR log
Created April 30, 2013 21:37 — forked from ceteri/EMR log
bash-3.2$ elastic-mapreduce --create --name "Sample Recommender" \
> --jar s3n://temp.cascading.org/sample/recommender.jar \
> --arg s3n://temp.cascading.org/sample/en.stop \
> --arg s3n://temp.cascading.org/sample/tweets/ \
> --arg s3n://temp.cascading.org/sample/out/token \
> --arg s3n://temp.cascading.org/sample/out/similarity
Created job flow j-2HA2BVCBJGMVX
bash-3.2$ elastic-mapreduce --list
j-2HA2BVCBJGMVX STARTING Sample Recommender
PENDING Example Jar Step