Skip to content

Instantly share code, notes, and snippets.

https://mypoi-hack.googlecode.com/svn/trunk/
Uq7qS2Uy7Ag5
@samklr
samklr / MixedTweets.md
Created August 5, 2012 18:57 — forked from loicdescotte/MixedTweets.md
How to push 2 mixed searches from twitter with Scala, Play2, Iteratee and Comet

##MixedTweets

We will see how to mix 2 twitter searches and push the results to the browser in real time.

First, checkout this mini project

To try it, you need to install Play 2.0

###Controller

@samklr
samklr / ExtremeStartup.scala
Created September 7, 2012 09:16 — forked from mikkelbd/ExtremeStartup.scala
BEKK kodekveld - Extreme Startup - refac
import util.matching.Regex
object ExtremeStartup {
def answer(q: String): Any = {
if (q.contains("what is your name"))
return "Mikkel"
if (q.contains("which city is the Eiffel tower in"))
return "Paris"
@samklr
samklr / RandomFun.scala
Created September 12, 2012 13:54
Random Stuff in Scala
def swap (x : Int; y : Int) = {
var a = x; var b =y;
a= a -b; b= b+a; a= b -a;
}
def fibonacci(n : Int) = recursiveFib(n, 1, 0)
def recursiveFib ( n : Int, next : Int, result : Int) : Int = {
n match {
@samklr
samklr / TontonMartin.scala
Created September 27, 2012 10:24
ScalaFistes
object FuncourseWithUncleMartin{
*/
object Setsss{
def contains(s: Set, elem: Int): Boolean = s(elem)
def singleton(elem: Int): Set = Set(elem)//(x :Int) => x == elem
def union(s: Set, t: Set): Set = (x : Int) => s(x) || t(x)
@samklr
samklr / extreme_st.rb
Created September 27, 2012 10:26
Extr Startup
require 'sinatra'
require 'logger'
log = Logger.new(STDOUT)
log.level = Logger::DEBUG
get '/' do
if params[:q]
log.debug(params[:q])
sz_q = params[:q].split(": ")[1]
@samklr
samklr / gol.rb
Created September 29, 2012 09:49
GOL
class GOL
def initialize
@cells = Array.new(10,Array.new(10))
for i in 0..9
for j in 0..9
@cells[i][j] = 0
end
@samklr
samklr / anagrams.ml
Created October 29, 2012 17:13
Anagrams
(*s {\bf Anagrams.} The following program finds all the anagrams of a given
set of characters among a dictionary. Such a dictionary can be built by
the following program given a list of files containing words (one per
line). *)
(*s The dictionary is implemented as a \emph{trie}. It is a multi-branching
tree, where branches are labelled with characters. Each node contains
a boolean which says if the word corresponding to the path from the root
belongs to the dictionary. The branches are implemented as maps from
characters to dictionaries. *)
@samklr
samklr / Huffm.scala
Created November 6, 2012 12:05
Huff
package patmat
import common._
import scala.collection.immutable._
/**
* Assignment 4: Huffman coding
*
*/
object Huffman {
@samklr
samklr / Cass.java
Created December 6, 2012 16:52
Cassandra stuff
// Instanciate cluster then connect
Cluster cluster =new Cluster.Builder()
.addContactPoints( addr1, addr2)
.build()
Session session = cluster.connect()
session.execute(query)