Skip to content

Instantly share code, notes, and snippets.

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) {
@dcsobral
dcsobral / runcached
Created July 18, 2019 15:28 — forked from akorn/runcached
Run speficied (presumably expensive) command with specified arguments and cache result. If cache is fresh enough, don't run command again but return cached output.
#!/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}
<!-- 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" />
<!-- 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"/>
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)
@dcsobral
dcsobral / gist:3767946
Created September 22, 2012 21:50 — forked from xeno-by/gist:2559714
Mixing in a trait dynamically
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.
@dcsobral
dcsobral / ListZipper.scala
Created August 30, 2012 23:18 — forked from tonymorris/ListZipper.scala
List Zipper
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")
// 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"
@dcsobral
dcsobral / SBT.sublime-build
Created February 23, 2012 18:31 — forked from jboner/SBT.sublime-build
Sublime Editor SBT build setup
{
"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"
}
@dcsobral
dcsobral / hashmap-bench.scala
Created January 8, 2012 01:15 — forked from erikrozendaal/hashmap-bench.scala
Scala TreeMap benchmarks
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