Skip to content

Instantly share code, notes, and snippets.

Arnold deVos arnolddevos

Block or report user

Report or block arnolddevos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@arnolddevos
arnolddevos / implicex.scala
Last active Nov 11, 2017
Implicit Functions Example in plain scala 2.12
View implicex.scala
import scala.collection.mutable.ListBuffer
object implicex {
trait ImplicitFunction1[-A, +B] {
def apply()(implicit a: A): B
}
def fn[A, B](f: A => B): ImplicitFunction1[A, B] = new ImplicitFunction1[A, B] {
def apply()(implicit a: A): B = f(a)
}
View KeyFunctionDemo.scala
package test
import scala.scalajs.js
import org.singlespaced.d3js.d3
import org.singlespaced.d3js.selection.Update
object KeyFunctionDemo extends js.JSApp {
def main() = {
for(i <- 1 to 3) {
@arnolddevos
arnolddevos / DT.scala
Created Feb 5, 2016
Dependent Types Example
View DT.scala
// Example from Odersky et al http://infoscience.epfl.ch/record/215280/files/paper.pdf
object DT {
trait Key { type Value }
class Setting(val str: String) extends Key
val sort = new Setting("sort") { type Value = String }
val width = new Setting("width") { type Value = Int }
val params = HMap.empty.add(width)(120).add(sort)("time")
@arnolddevos
arnolddevos / git-log-consolidate.sh
Created Nov 4, 2014
Scan git repos and produce a time-sorted, consolidated log. (Hint: edit the variables in this.)
View git-log-consolidate.sh
#! /bin/bash
# git-log-consolidate
set -e
SINCE="Aug 25"
UNTIL="Sep 19"
LOG=~/git-log-consolidated.log
TMP=$LOG.tmp
@arnolddevos
arnolddevos / thing.scala
Last active Aug 29, 2015
some sort of monad defined in terms of a sort of fold
View thing.scala
package thing
import scala.language.higherKinds
trait Thing[+T, Context[_]] { parent =>
def foldish[S](s0: S)(f: (S, T) => Context[S]): Context[S]
def map[U](g: T => U) = new Thing[U, Context] {
def foldish[S](s0: S)(f: (S, U) => Context[S]) =
parent.foldish(s0)((s, t) => f(s, g(t)))
@arnolddevos
arnolddevos / bash
Created Nov 4, 2012
understand shell quoting
View bash
decorate() {
for f in "$@"
do
echo -n "[$f] "
done
echo
}
@arnolddevos
arnolddevos / CharSeqView.scala
Created Jun 12, 2012
A view of a CharSequence that implements subSequence() without copying the whole contents.
View CharSeqView.scala
package au.com.langdale
package util
class CharSeqView( base: CharSequence, offset: Int, val length: Int) extends CharSequence {
def this(base: CharSequence) = this(base, 0, base.length)
def charAt(index: Int): Char = {
if( 0 <= index && index < length)
base.charAt(index + offset)
else
View examples.scala
import Pattern._
import Family._
def pattern[B](pf: PartialFunction[Name,B]) = new Extractor(pf.lift)
val Parents = new Extractor(parents.get)
val Children = new Extractor(children.get)
"Julie" match {
case Parents(p) => "Julies parents are: " + p
@arnolddevos
arnolddevos / gist:574873
Created Sep 11, 2010
Idea for generator and suspendable wrapper
View gist:574873
import scala.util.continuations._
class Generator[A] extends Iterator[A] with (A => Unit @ suspendable) {
private var a: Option[A] = None
private var k: Option[Unit => Unit] = None
def next = {
val a0 = a.get
val k0 = k.get
a = None
@arnolddevos
arnolddevos / Joins.scala
Created Nov 15, 2009
Idea for polyphonic scala actors
View Joins.scala
package au.com.langdale.actors
import scala.actors.Actor.self
import scala.actors.OutputChannel
import scala.collection.immutable.Set
/**
* Augments the actors library with a form of join pattern similar in function
* to C omega chords or Haller and Van Cutsem scala join patterns but with a
* different notation.
*
You can’t perform that action at this time.