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
# Simple implementation of the productions for the MIU system | |
open INFILE,"<",$ARGV[0]; | |
while(<INFILE>) { | |
chomp; | |
next if $_ =~ /#.*/; | |
print "$1IU\n" if $_ =~ /^(.+?)I$/; | |
print "M$1$1\n" if $_ =~ /^M(.+)$/; | |
print "$1U$2\n" if $_ =~ /^(.*)III(.*)$/; | |
print "$1$2\n" if $_ =~ /^(.*)UU(.*)$/; |
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
# Load RVM into a shell session *as a function* | |
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then | |
# First try to load from a user install | |
source "$HOME/.rvm/scripts/rvm" | |
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then | |
# Then try to load from a root install | |
source "/usr/local/rvm/scripts/rvm" |
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 Controller < UntypedActor | |
def initialize | |
@models = 0.upto(3).map do |idx| | |
model = Actors.actorOf { SieveNonblocking::Model.new } | |
model.start | |
model | |
end | |
# Seed models with a few initial values... just to get things going |
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 'lib/akka-actor-1.2.jar' | |
require 'lib/scala-library.jar' | |
java_import 'akka.actor.Actors' | |
java_import 'akka.actor.UntypedActor' | |
java_import 'akka.actor.UntypedActorFactory' | |
module Sieve |
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
(defn euclidean [x y] (Math/sqrt (+ (Math/pow x 2) (Math/pow y 2)))) | |
(println (for [ | |
[x,y] | |
[[1,2],[2,3],[3,4]] | |
:when (> (euclidean x y) 3.0)] | |
[(euclidean x y),(Math/toDegrees (Math/atan (/ y x)))])) |
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. |
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
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
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
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 { |
NewerOlder