This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.fencepost | |
import scala.collection.mutable._ | |
import org.scalatest.Suite | |
import java.util.concurrent._ | |
class SAMTest extends Suite { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.fencepost.forkjoin | |
import scala.collection.mutable.LinkedList | |
import jsr166y._ | |
import org.scalatest.Suite | |
class ForkJoinTest extends Suite { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Euler10 | |
include Enumerable | |
def initialize() | |
@primearr = [2] | |
@nat = 3 | |
end | |
def each | |
yield 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.fencepost.cassandra | |
import scala.collection.JavaConversions | |
import org.apache.thrift.protocol.TBinaryProtocol | |
import org.apache.thrift.transport._ | |
import org.apache.cassandra.service._ | |
import org.apache.cassandra.thrift._ | |
object ThriftCassandraClient { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
def generate_random_name(len) | |
1.upto(len).map { (65 + (rand 26)).chr }.join() | |
end | |
NUM_AUTHORS=10000 | |
AUTHOR_NAME_LENGTH=24 | |
POSTS_PER_AUTHOR=100 | |
MAX_PAGE_VIEWS_PER_POST=2000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
antitails x = reverse (foldr f1 [] x) ++ [""] | |
where f1 newchar acc = [[newchar]] ++ (map (newchar:) acc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Populate data for a set of random users to a Cassandra instance. | |
; | |
; Users consist of the following set of data: | |
; - a username [String] | |
; - a user ID [integer] | |
; - a flag indicating whether the user is "active" [boolean] | |
; - a list of location IDs for each user [list of integer] | |
; | |
; User records are keyed by username rather than user IDs, mainly because at the moment | |
; we only support strings for key values. The Cassandra API exposes keys as byte arrays |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
require 'akka-actor-1.2-RC6.jar' | |
require 'scala-library.jar' | |
java_import 'akka.actor.UntypedActor' | |
java_import 'akka.actor.Actors' | |
# Start with something simple. Implement the actor as a distinct | |
# class and start it up within the Akka runtime. |
OlderNewer