Skip to content

Instantly share code, notes, and snippets.

@asenchi
asenchi / python.pp
Created February 20, 2010 14:56
Puppet manifest for installing Python and modules using pip
# Copyright (c) 2010 Curt Micol <[email protected]>
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
import io.Source
import java.io.ByteArrayInputStream
import org.scalacheck.{Arbitrary, Gen, Prop}
import org.specs2.mutable.Specification
import org.specs2.ScalaCheck
class ParserSpec extends Specification with ScalaCheck {
val gameParameterGenerator = for {
loadTime <- Gen.oneOf(1 to 50000)
turnTime <- Gen.oneOf(1 to 50000)
@jboner
jboner / SBT.sublime-build
Created May 6, 2011 09:47
Sublime Editor SBT build setup
{
"cmd": ["sbt-no-color compile"],
"file_regex": "^\\[error\\] ([.a-zA-Z0-9/-]+[.]scala):([0-9]+):",
"selector": "source.scala",
"working_dir": "${project_path:${folder}}",
"shell": "true"
}
@akihiro4chawon
akihiro4chawon / parasort.scala
Created May 19, 2011 16:09
practical implementation of parallel sorting algorithm in Scala
import java.util.Arrays
abstract class Sorter {
def sorted(a: Array[Int]): Array[Int]
}
object SimpleSorter extends Sorter {
def sorted(a: Array[Int]) = {
Arrays.sort(a)
a
@oxbowlakes
oxbowlakes / ScalaSolarizedDark.xml
Created June 20, 2011 13:13
ScalaSolarizedDark.xml
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="OxbowSolarizedDark" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.2" />
<option name="EDITOR_FONT_SIZE" value="13" />
<option name="EDITOR_FONT_NAME" value="Consolas" />
<colors>
<option name="ADDED_LINES_COLOR" value="" />
<option name="ANNOTATIONS_COLOR" value="2b36" />
<option name="ANNOTATIONS_MERGED_COLOR" value="" />
<option name="CARET_COLOR" value="dc322f" />
@jskorpan
jskorpan / StringTokenizer.java
Created June 30, 2011 11:37 — forked from cgbystrom/StringTokenizer.java
Ultra fast Java string tokenizer
public class StringTokenizer {
private static ThreadLocal<String[]> tempArray = new ThreadLocal<String[]>();
public static String[] tokenize(String string, char delimiter)
{
String[] temp = tempArray.get();
int tempLength = (string.length() / 2) + 2;
if (temp == null || temp.length < tempLength)
{
@dholbrook
dholbrook / SleepingBarber.scala
Created October 12, 2011 03:03
Sleeping Barber Problem, Akka actor implementation
import java.lang.Thread
import scala.collection.mutable.Queue
import akka.actor.Uuid
import akka.actor.scala2ActorRef
import akka.actor.Actor
import akka.event.EventHandler
/*
* Sleeping Barber Code Club Problem
* See (http://en.wikipedia.org/wiki/Sleeping_barber_problem)
@retronym
retronym / log.txt
Created October 20, 2011 22:03
sbt-classifiers
>show update
[info] commons-io:commons-io:1.2:
[info] (Artifact(commons-io,jar,jar,None,ArraySeq(),None,Map()),project/.ivy/cache/commons-io/commons-io/jars/commons-io-1.2.jar)
[info] (Artifact(commons-io,src,jar,Some(sources),ArraySeq(),None,Map()),project/.ivy/cache/commons-io/commons-io/srcs/commons-io-1.2-sources.jar)
[info] (Artifact(commons-io,doc,jar,Some(javadoc),ArraySeq(),None,Map()),project/.ivy/cache/commons-io/commons-io/docs/commons-io-1.2-javadoc.jar)
> show update-sbt-classifiers
...
[info] commons-collections:commons-collections:3.2.1:
[info] (Artifact(commons-collections,src,jar,Some(sources),ArraySeq(),None,Map()),project/.ivy/cache/commons-collections/commons-collections/srcs/commons-collections-3.2.1-sources.jar)
@gclaramunt
gclaramunt / Circularbuffer.scala
Created November 23, 2011 17:33
circular buffer
package my.collections
class CirculrBufferIterator[T](buffer:Array[T], start:Int) extends Iterator[T]{
var idx=0
override def hasNext = idx<buffer.size
override def next()={
val i=idx
idx=idx+1
buffer(i)
}
@retronym
retronym / config.scala
Last active May 9, 2018 05:47
Styles of config propagation: Manual, Implicits, DynamicVariable, Reader
package scalaz.example
object Reader extends App {
/**
* Manual propagation of the environment (in the example, `contextRoot`.)
*/
object Config0 {
def fragment1(contextRoot: String) = <a href={contextRoot + "/foo"}>foo</a>