Skip to content

Instantly share code, notes, and snippets.

View wires's full-sized avatar
🕳️

Jelle Herold wires

🕳️
View GitHub Profile
@wires
wires / dabblet.css
Created June 11, 2014 03:20
nigga wut
/** nigga wut */
background: #366;
background: linear-gradient(25deg, #346, rgba(100,0,100,0.1));
min-height: 100%;
font-family: monospace;
font-size: 48pt;
@wires
wires / spin.js
Created May 28, 2014 21:00
Spin failing promise
var Q = require('kew');
function retryPromise(n, mkPromise) {
if(n > 0)
return mkPromise()
.fail(function(){
console.log('failed promise, retrying maximum ' + n + ' more times');
return retryPromise(n - 1, mkPromise);
});
@wires
wires / implicits.scala
Created August 17, 2013 12:05
Some examples of using implicits in scala
implicit classs FancyString(s : String) {
def awesomeStuff = string.reverse.toUpperCase
}
"awesomeStuff".awesomeStuff
def cool(implicit thing: Int) = thing * 3
implicit val something = 21
@wires
wires / build.sbt
Created August 16, 2013 10:56 — forked from agemooij/build.sbt
import com.typesafe.sbt.SbtStartScript
seq(SbtStartScript.startScriptForClassesSettings: _*)
seq(Revolver.settings: _*)
name := "demo"
organization := "com.scalapenos"
@wires
wires / Hello.java
Last active December 14, 2015 08:28
minimal maven + guice + log4j + sli4j test/example
import com.google.inject.*;
import org.nnsoft.guice.sli4j.core.InjectLogger;
import org.nnsoft.guice.sli4j.slf4j.Slf4jLoggingModule;
import org.slf4j.Logger;
class Stuff {
public int randomNumber() {
return (int)(Math.random() * Integer.MAX_VALUE);
}
}
@wires
wires / StringShape.java
Created October 21, 2012 01:21
StringShape for android
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.shapes.Shape;
/**
* Centered string shape
*/
class StringShape extends Shape
{
@wires
wires / Math.java
Created October 21, 2012 00:01
(trivial) Java integer math
import static java.lang.Math.max;
import static java.lang.Math.min;
public class Math
{
// clamp(n) = n such that min <= final <= max
public static final int clamp(final int min, final int value, final int max)
{
return max(min, min(value, max));
}
@wires
wires / crash_node.sh
Created October 19, 2012 12:10
nodejs explodes while streamparsing a json
#! /bin/sh
# I first create the large file, so we are sure this has nothing to do with stream piping
node create_large_file.js > large.json
# on my machine this crashes on 133949
cat large.json | node nothing.js
#....
#133949
#FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory
@wires
wires / es_highlight_weirdness.sh
Created October 16, 2012 15:23
Elastic search strange highlighting behaviour
export ES='http://localhost:9200'
# avoid colorizing when using less
if [ -t 1 ]; then
alias pp='python -mjson.tool | pygmentize -l javascript'
else
alias pp='python -mjson.tool'
fi
(*
(** Simple streams created by iteration of one operator *)
Section monoid_iter.
Context `{Monoid M} (m:M).
(** The infinite stream s, m & s, m & m & s, ... *)
CoFixpoint inf_iter (start:M) : ∞M :=
start ::: inf_iter (m & start).