This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Usage: ./brew-rehash.sh formula-file.rb | |
if [[ $1 == *".rb" ]]; then | |
formula=$1 | |
else | |
formula="$1.rb" | |
fi | |
echo "Rehashing $1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
vim="vim $@" | |
osascript -e "tell app \"Terminal\" | |
activate | |
do script \"$vim\" | |
end tell" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ifp :: (a -> Bool) -> a -> a -> a | |
ifp p x y | |
| p x = x | |
| otherwise = y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// implementation | |
<T> void let(T value, Consumer<T> consumer) { | |
consumer.accept( value ); | |
} | |
// example usage | |
let(userService.findUser(), user -> { | |
// do something to the user | |
if (!user.isValid()) { | |
userService.removeUser(user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import org.junit.Test; | |
import java.io.UnsupportedEncodingException; | |
import java.util.Arrays; | |
import static org.junit.Assert.assertNotEquals; | |
public class EncodingTest { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
-- Transform cells into next iteration | |
nextTurn :: (Integral a) => [(a,a)] -> [(a,a)] | |
nextTurn space = [(x, y) | (x,y,_) <- [head xs | xs <- cells space, length xs == 3 || (length xs == 4 && True `elem` ([x | (_,_,x) <- xs]))]] | |
-- Cells grouped by their coordinates | |
cells :: (Integral a) => [(a,a)] -> [[(a,a,Bool)]] | |
cells space = groupBy (\(x1,y1,_) (x2,y2,_) -> x1 == x2 && y1 == y2) (sort (neighbourhood space)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.util.Collection; | |
import java.util.Collections; | |
import static java.util.Arrays.asList; | |
import static java.util.Collections.unmodifiableCollection; | |
public enum State { | |
STATE1 { |
NewerOlder