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
// git clone git@github.com:nafg/reactive.git | |
// git checkout v0.4.0 | |
// sbt routing/console | |
import reactive.routing._ | |
implicit object IntArg extends Stringable[Int] { def format = _.toString; def parse = s => util.Try(s.toInt).toOption } | |
implicit object StringArg extends Stringable[String] { def format = identity; def parse = Option(_) } | |
val a = arg[Int] >> { i => i.toString } | |
val b = arg[String] >> { s => s } |
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
<!DOCTYPE html> | |
<html><body> | |
<h1>Show Mint transactions within date range</h1> | |
<form action="https://wwws.mint.com/transaction.event" target="_blank" method="get"> | |
<input type="date" id="s" onchange="document.getElementById('sd').value=this.value.replace(/(\d+)-(\d+)-(\d+)/,'$2/$3/$1')"/> | |
to | |
<input type="date" id="e" onchange="document.getElementById('ed').value=this.value.replace(/(\d+)-(\d+)-(\d+)/,'$2/$3/$1')"/> | |
<input type="hidden" name="startDate" id="sd"/><input type="hidden" name="endDate" id="ed"/> | |
<input type="submit"/> | |
</form> |
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
trait ApType { | |
import scala.language.higherKinds | |
type FS[+Z] | |
} | |
trait ApTypeOne[A] extends ApType { | |
type FS[+Z] = A => Z | |
} | |
trait ApTypeMore[A, N <: ApType] extends ApType { | |
type FS[+Z] = A => N#FS[Z] | |
} |
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 java.util.concurrent.atomic.AtomicInteger | |
import scala.collection.mutable.{ArrayBuffer, SynchronizedBuffer} | |
import scala.concurrent.{ExecutionContext, Future} | |
import scala.xml.Elem | |
import reactive.{Observing, Subscription} | |
import reactive.Applicative.ApType | |
import reactive.web.Page |
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
function dev --argument q | |
find ~/dev -name '.git' | xargs dirname | begin | |
peco --query=$q | |
or return | |
end | read d | |
cd $d | |
end |
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 java.nio.file._ | |
import java.nio.file.attribute.BasicFileAttributes | |
import scala.collection.convert.decorateAsJava._ | |
val ideaFile = "/home/naftoli/.local/share/applications/jetbrains-idea-ce.desktop" | |
val file = io.Source.fromFile(ideaFile) | |
case class Section(head: Option[String], entries: Seq[Either[String, (String, String)]]) { |
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
trait Produce { self => | |
type F[R] | |
def runWith(f: =>F[Unit]): CssSel | |
protected[lrbcol] def combineFunc[R](f: F[R]): (R => Unit) => CssSel | |
def combine[R](f: F[R]) = new ProduceOne(new Binding(combineFunc(f))) | |
} | |
class Binding[A, T](val func: (A => Unit) => T) { | |
var realHandler: () => A => Unit = null | |
private val closure: A => Unit = a => realHandler()(a) | |
val result = func(closure) |
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 lrbcol.misc | |
import scala.xml._ | |
import scala.concurrent._ | |
import net.liftweb.http._ | |
import net.liftweb.util.{ A => _, _ } | |
import net.liftweb.util.Helpers._ |
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
implicit class MultiMap[K, V](map: Map[K, Set[V]]) { | |
def addBinding(k: K, v: V) = addBindings(k, Set(v)) | |
def addBindings(k: K, vs: Set[V]) = map.get(k) match { | |
case None => map + (k -> vs) | |
case Some(xs) => map + (k -> (vs ++ xs)) | |
} | |
def removeBinding(k: K, v: V) = map.get(k) match { | |
case None => map |
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
public class Thing : IThing | |
{ | |
public Thing(IDependency dependency) { } | |
public void Do(string arg) { } | |
} |
OlderNewer