Skip to content

Instantly share code, notes, and snippets.

View hamnis's full-sized avatar

Erlend Hamnaberg hamnis

View GitHub Profile
import java.awt.{Color, Graphics2D}
import java.awt.image.BufferedImage
import javax.imageio.ImageIO
public class Main {
//Does not deal with double buffering, and writing on servers which are headless.
public BufferedImage createBlackImage(int width, int height) {
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = (Graphics2D) image.getGraphics();
<project>
<parent>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rpm</artifactId>
<packaging>jar</packaging>
<name>Project :: RPM</name>
diff --git a/spec/ems_spec.rb b/spec/ems_spec.rb
index 9620341..93732ed 100755
--- a/spec/ems_spec.rb
+++ b/spec/ems_spec.rb
@@ -117,14 +117,14 @@ describe 'EMS' do
collection['href'].should eql collection_url
end
- %w(format body state audience slug title lang summary level).each do |field|
+ %w(format body state title lang summary level).each do |field|
{
"templates": [
{
"data": [
{"name": "synth-id", "value": "urn:uuid:536c2060-c9ea-4781-97d9-12d6f717a88c"},
{"name": "foo", "value": "bar"}
]
},
{
"data": [
import net.hamnaberg.funclite.*;
public class Collect {
public static <A, B> Option<B> collect(A value, Predicate<A> p, Function<A, B> f) {
if (p.apply(value)) {
return Option.fromNullable(f.apply(value));
}
return Option.none();
}
@hamnis
hamnis / 0_reuse_code.js
Created June 2, 2014 06:38
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
package unfilteredx.logging
import unfiltered.request._
import unfiltered.response._
import unfiltered.Cycle
import com.typesafe.scalalogging.Logger
import org.slf4j.LoggerFactory
object TraceLogging {
def apply[A, B](intent: Cycle.Intent[A, B])(implicit tl: TraceLogger[A, B]) =
package emsnav
import dispatch._, Defaults._
import java.net.URI
import net.hamnaberg.json.collection._
import concurrent.Await
import concurrent.duration._
object Main extends App {
val MediaType = "application/vnd.collection+json"
#!/bin/bash
jq "{template: .collection.template}"
def string[T](req: HttpRequest[T])(implicit codec: Codec = Codec.UTF8) = {
loan(new InputStreamReader(req.inputStream, codec.charSet)) { reader =>
val writer = new java.io.StringWriter
val ca = new Array[Char](4096)
@scala.annotation.tailrec def read() {
val len = reader.read(ca)
if (len > 0) writer.write(ca, 0, len)
if (len >= 0) read
}
read()