Skip to content

Instantly share code, notes, and snippets.

@heuristicfencepost
heuristicfencepost / PopulateCassandra.py
Created March 29, 2011 05:55
Python scripts used in an initial analysis of the Cassandra data model
from twitter.api import Twitter
import pycassa
from itertools import ifilterfalse
# Query to use when finding tweets.
searchquery = "#cassandra"
# Borrowed from the itertools docs
def unique_everseen(iterable, key=None):
@heuristicfencepost
heuristicfencepost / euler10.hs
Created March 7, 2011 07:10
A better Ruby implementation of Project Euler problem #10 and a horrible implementation in Haskell
module Main where
-- Definition of our candidate set
tens = map (*10) [1..]
urcandidate(x:xs) = map (+x) [1,3,7,9] ++ urcandidate(xs)
candidates = urcandidate(tens)
-- Define the logic to be used by our predicate and utilize currying to support partial application
urpred(candidate,prime) = prime > (truncate (sqrt (fromIntegral candidate))) || candidate `mod` prime == 0
pred = curry urpred
@heuristicfencepost
heuristicfencepost / Euler10.rb
Created March 4, 2011 05:15
Solution to Project Euler problem #10 in various languages
class Euler10
include Enumerable
def initialize()
@primearr = [2]
@nat = 3
end
def each
yield 2
@heuristicfencepost
heuristicfencepost / ForkJoinTest.scala
Created February 4, 2011 07:21
Implementation of various Scala tests to demonstrate integration with Java's fork/join framework
package org.fencepost.forkjoin
import scala.collection.mutable.LinkedList
import jsr166y._
import org.scalatest.Suite
class ForkJoinTest extends Suite {
@heuristicfencepost
heuristicfencepost / SAMTest.scala
Created January 7, 2011 05:58
Samples of SAM handling in JRuby and Scala
package org.fencepost
import scala.collection.mutable._
import org.scalatest.Suite
import java.util.concurrent._
class SAMTest extends Suite {