Skip to content

Instantly share code, notes, and snippets.

View blast-hardcheese's full-sized avatar

Devon Stewart blast-hardcheese

View GitHub Profile
// Given this definition,
def buildWrites[U, T <: DataTyped[U]](baseWrites: Writes[T])(implicit typeToJs: U => Json.JsValueWrapper): Writes[T]
// Works!
val someWrites: Writes[SomeDataTyped_v1] = DataTyped.buildWrites[FeedEntryTypes.Value, SomeDataTyped_v1](Json.writes[SomeDataTyped_v1])
// Fails.
val someWrites: Writes[SomeDataTyped_v1] = DataTyped.buildWrites(Json.writes[SomeDataTyped_v1])
[error] .../DataSpec.scala:65: type mismatch;
#!/bin/sh
DOWNLOAD_DIR="$HOME/Downloads/weather"
REGION=txgulf
die() {
ec=$1
shift
echo $@ >&2
exit $ec
package models
import scala.util.matching.Regex
// Deps
object Types {
type Tag = String
}
import Types._
def parse(data: Any): Try[JsonNode] = data match {
case data:java.net.URL => Try(mapper.readTree(data))
case data:java.io.File => Try(mapper.readTree(data))
case data:Array[Byte] => Try(mapper.readTree(data))
case data:String => Try(mapper.readTree(data))
case data:java.io.Reader => Try(mapper.readTree(data))
case data:java.io.InputStream => Try(mapper.readTree(data))
case data:org.codehaus.jackson.JsonParser => Try(mapper.readTree(data))
case _ => Failure(new Exception("Unknown data type"))
}
recurse_image_resize() {
for f in "$@"; do
if [ ! -d "$f" ]; then
echo "recurse_image_resize: '$f' is not a directory"
fi
for ff in "$f"/*.png; do
echo "resizing $ff to half size"
convert "$ff" -resize 50% "$ff";
done
@blast-hardcheese
blast-hardcheese / gist:6724216
Created September 27, 2013 04:40
adjust_size convenience function
adjust_size() {
size=$1
shift
if [ "x" = "x$size" -o -f "$size" ]; then
echo "Usage: adjust_size size_spec file [file2 [file3...]]"
return 1
fi
for P in "$@"; do
class Email:
name = None
email = None
def __init__(self, name, email):
self.name = name
self.email = email
def __str__(self):
return "%s <%s>" % (self.name, self.email)
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#define MNAMES 4
#define FNAMES 4
Sources:
- http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/
- http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=22975
- http://www.thomaskho.com/blog/2006/02/qemu-and-the-network-bridge/
- http://toast.djw.org.uk/qemu.html
- http://wiki.debian.org/QEMU#Host_and_guests_on_same_network
Files needed:
- http://downloads.raspberrypi.org/images/raspbian/2013-02-09-wheezy-raspbian/2013-02-09-wheezy-raspbian.zip.torrent
- http://xecdesign.com/downloads/linux-qemu/kernel-qemu
@blast-hardcheese
blast-hardcheese / gist:5315797
Created April 5, 2013 00:58
Writing lists to avoid multi-line changes in Git
diff --git a/project/Build.scala b/project/Build.scala
index eb28dac..cf9cb1a 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -10,6 +10,7 @@ object ApplicationBuild extends Build {
val appDependencies = Seq(
// Add your project dependencies here,
"org.xerial" % "sqlite-jdbc" % "3.7.2"
+ , "org.scalaquery" % "scalaquery_2.9.0-1" % "0.9.5"
)