This file contains 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 slamdata | |
import sjsonnew.IsoString | |
import sjsonnew.shaded.scalajson.ast.unsafe.JValue | |
import sjsonnew.support.scalajson.unsafe.{Converter, Parser, PrettyPrinter} | |
import java.nio.file.Path | |
final class ManagedVersions private (path: Path) { |
This file contains 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
#!/bin/zsh | |
# | |
# Purpose: run speficied command with specified arguments and cache result. If cache is fresh enough, don't run command again but return cached output. | |
# Also cache exit status and stderr. | |
# License: GPLv3 | |
# Use silly long variable names to avoid clashing with whatever the invoked program might use | |
RUNCACHED_MAX_AGE=${RUNCACHED_MAX_AGE:-300} | |
RUNCACHED_IGNORE_ENV=${RUNCACHED_IGNORE_ENV:-0} | |
RUNCACHED_IGNORE_PWD=${RUNCACHED_IGNORE_PWD:-0} |
This file contains 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
<!-- Multiwall --> | |
<block id="1857" name="multiWall_Steel_9m"> | |
<property name="Class" value="PlantGrowing" /> | |
<property name="CustomIcon" value="steelBlock" /> | |
<property name="Material" value="Msteel" /> | |
<property name="Texture" value="355,355,355,355,355,355" /> | |
<property class="PlantGrowing"> | |
<property name="FertileLevel" value="0" /> | |
<property name="Next" value="steelBlock" /> |
This file contains 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
<!-- ADMIN ITEMS --> | |
<item id="3500" name="Admin_nailgun"> | |
<property name="IsDeveloper" value="true"/> | |
<property name="Meshfile" value="Items/Tools/nailgunPrefab"/> | |
<property name="CustomIcon" value="nailgun"/> | |
<property name="CustomIconTint" value="FF0000"/> | |
<property name="Material" value="metal"/> | |
<property name="HoldType" value="37"/> | |
<property name="Stacknumber" value="1"/> | |
<property name="RepairTools" value="repairKit"/> |
This file contains 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 com.youdevise.lofty | |
import org.specs2.mutable._ | |
import scala.language.dynamics | |
trait State[S, A] { | |
val runState: Function[S, (S, A)] | |
def flatMap[B](f: A => Function[S, (S, B)]):Function[S, (S, B)] = (state:S) => { | |
val (newState, value) = runState(state) | |
f(value)(newState) |
This file contains 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
Answers http://stackoverflow.com/questions/10373318/mixing-in-a-trait-dynamically. | |
Compile as follows: | |
scalac Common_1.scala Macros_2.scala | |
scalac Common_1.scala Test_3.scala -cp <path to the result of the previous compilation> | |
Tested in 2.10.0-M3, will most likely not compile by the time 2.10.0 final is released, because we're actively rehashing the API. | |
However the principles will remain the same in the final release, so the concept itself is okay. | |
upd. Code updated for 2.10.0-M7. |
This file contains 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
case class ListZipper[+A](lefts: List[A], x: A, rights: List[A]) { | |
def map[B](f: A => B): ListZipper[B] = | |
sys.error("todo") | |
// map with zipper context | |
def coFlatMap[B](f: ListZipper[A] => B): ListZipper[B] = | |
sys.error("todo") | |
def findRight(p: A => Boolean): Option[ListZipper[A]] = | |
sys.error("todo") |
This file contains 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
// a.scala | |
// Fri Jun 29 16:15:08 PDT 2012 | |
import scala.reflect.makro.Context | |
import collection.mutable.ListBuffer | |
import collection.mutable.Stack | |
import language.experimental.macros | |
object Macros { | |
val conversionChars = "%BbCcdEefGgHhinosuXx" |
This file contains 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
Show hidden characters
{ | |
"cmd": ["sbt-no-color test"], | |
"file_regex": "^\\[error\\] ([.a-z_A-Z0-9/-]+[.]scala):([0-9]+):", | |
"selector": "source.scala", | |
"working_dir": "${project_path:${folder}}", | |
"shell": "true" | |
} |
This file contains 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
import collection.mutable.ArrayBuffer | |
import collection.immutable.HashMap | |
object HashMapTest { | |
val random = new util.Random(1234) | |
def time(block: => Unit): Double = { | |
val start = System.nanoTime() | |
block |
NewerOlder