Skip to content

Instantly share code, notes, and snippets.

View rzwitserloot's full-sized avatar

Reinier Zwitserloot rzwitserloot

View GitHub Profile
@rzwitserloot
rzwitserloot / radio
Created October 15, 2009 03:28
This script will play radio and should work on macs and linux computers if you have VLC installed. Better than iTunes, in that it works with more stations, and doesn't clutter your media list.
#!/bin/bash
# author: Reinier Zwitserloot
# this script is in the public domain. I relinquish all rights.
# source: http://gist.github.com/210643
# Plays various radio channels, using VLC. Run me from a terminal to see radio station options.
# If your radio skips a lot, you need to suid 'renice'. If you don't know what that means, don't try it yourself; it has serious security implications.
# For this to work, you need VLC. On debian / ubuntu: apt-get install vnc
#!/bin/bash
#Sets mouse tracking speed on Mac OS X; capable of faster speeds than the selection dialog.
#Unfortunately, you will have to log out and back in again for changes to propagate.
#My tracking speed is at 4.8.
if [ "$1" == "" ]; then
echo Sets the tracking speed of the mouse. "3.0" is the fastest setting in the mouse settings pane.
echo Your current tracking speed is: `defaults read -g com.apple.mouse.scaling`
exit 0
fi
package lombok.parboiled;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;
import org.parboiled.BaseActions;
(Total guess based on eating a parsnip oven dish at a restaurant and chatting with the chef about what's in it).
Enough as a primi dish for 4 persons.
- 300g Parsnips (in dutch: Pastinaak)
- truffle aroma (real truffles, or truffle oil, or truffle cream)
- creme fraiche (100g)
- aged cheese, rasped or cut to slivers.
- chicken broth (concentrated, 125ml)
- 50g diced onion (or leek)
@rzwitserloot
rzwitserloot / gitc
Last active September 25, 2015 18:28
grb-like git frontend that does all grb does and more (specifically: all-work-in-branches model)
#!/bin/bash
#
# Copyright © 2009-2013 Reinier Zwitserloot and Roel Spilker.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
public int nextInt(int n) {
if (n <= 0)
throw new IllegalArgumentException("n must be positive");
if ((n & -n) == n) // i.e., n is a power of 2
return (int)((n * (long)next(31)) >> 31);
int bits, val;
do {
bits = next(31);
List<Kiwi> listOfKiwis = new ArrayList<Kiwi>();
list.add(new Kiwi());
List<Fruit> listofFruits = listOfKiwis; // This line would actually fail to compile.
listOfFruits.add(new Apple());
for (Kiwi kiwi : listOfKiwis) {
// ... this will blow up, there's an apple in my kiwis.
}
@rzwitserloot
rzwitserloot / BuilderSingletonGuavaMaps.java
Last active August 29, 2015 14:13
'proper' way to implement builders with singular support for java.util.Map; this will be in project lombok soon.
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableSortedMap;
class BuilderSingletonGuavaMaps<K, V> {
private ImmutableMap<K, V> battleaxes;
private ImmutableSortedMap<Integer, ? extends V> vertices;
private ImmutableBiMap rawMap;
@java.lang.SuppressWarnings("all")
BuilderSingletonGuavaMaps(final ImmutableMap<K, V> battleaxes, final ImmutableSortedMap<Integer, ? extends V> vertices, final ImmutableBiMap rawMap) {
this.battleaxes = battleaxes;
public class Test<C extends Test<C>> {
void foo() {
Test<?> t = bar();
}
public static <V extends Test<V>> Test<V> bar() {
return null;
}
}
Don't do this:
switch (foo) {
case 5:
x = "Hello";
break;
case 10:
x = "Hi";
break;
}