Skip to content

Instantly share code, notes, and snippets.

@galdosd
galdosd / es.java
Last active August 27, 2018 05:15
es
public interface State<T_state extends State> {
void load(History<T_state> history, int lastTransaction);
}
public abstract class BaseState<T_state extends State> implements State<T_state> {
private int lastTransaction = -1;
@Override public void load(History<T_state> history, int lastTransaction) {
}
}
import XMonad
import XMonad.Hooks.SetWMName
main = xmonad defaultConfig
{ modMask = mod4Mask -- Use WinKey instead of Alt
, startupHook = setWMName "LG3D" -- required so java apps like IntelliJ work (otherwise will get grey screen)
}
@game_predicate
def emergency(world):
# forgive the nasty
if world.alarm return True
if world.on_fire return True
if some other shit return True
return False
// property slots.... get the extensibility of getters/setters along with the conciseness of the common case where they trivially wrap a field
class Slot<X> {
private X x;
public Slot(){this.x=null;}
private Slot(X x) { this.x=x; }
static <X> Slot<X> slot(X x){ return new Slot<>(x); }
static <X> Slot<X> slot(){ return new Slot<X>(null); }
public class EZMap<T> {
public static void main(String[] args) {
Map<String,Object> m = hashMap(
bob -> 5,
TheGimp -> 8,
incredibleKoolAid -> "James Taylor",
heyArnold -> new Date()
);
System.out.println(m);
}
@galdosd
galdosd / gist:2394221
Created April 15, 2012 18:18
compilor
{ var lastid=1; function mkid(){return 'r'+lastid++; }
function arrayP(x){ return typeof x === 'object' && Object.prototype.hasOwnProperty.apply(x,['length']);
}
function cat(){ var res=[],
args=Array.prototype.slice.apply(arguments);
while(args.length){ var snip = args.shift();
console.log(snip);
if ( snip && arrayP(snip[0]) ) {
while(snip.length){ res.push(snip.shift()); }
} else {
{
function id(x){ return x; }
function cf(x){ return function(y) { return x; }; }
}
start
= sp V:fn { return (V(null))(2); }
sum
= L:term "+" sp R:sum { return function(x){ return L(x)+R(x); }; }