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
/** | |
* Scala hex / decimal binary calculator | |
* (c) Mark Lister 2012 | |
* Licence Apache 2. | |
*/ | |
class BaseN(b: BigInt, val baseN: Int) extends BigInt(b.underlying) { | |
def n(x: Int) = new BaseN(b, x) | |
/** |
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 | |
currentAlphaLine=`grep "version.*alpha" build.gradle` | |
currentAlphaVersion=`echo $currentAlphaLine | cut -d \' -f 2` | |
newAlphaVersion=${currentAlphaVersion%-*}-$((${currentAlphaVersion##*-} + 1)) | |
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then | |
echo "Repository is dirty, please commit first" | |
exit -1 | |
fi |
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
object PlayFair { | |
type Cipher = Map[(Int, Int), Char] | |
def buildCipher(p: String) : Cipher = (for (x <- 0 to 4; y <- 0 to 4) yield (x,y)).zip(chars(p)).toMap | |
def makeCompatible(s: String) = s toUpperCase() replace('J', 'I') filter(_.isLetter) | |
def chars(a: String) = { | |
val p = makeCompatible(a) filter { var s = Set[Char](); x => val b = s(x); s += x; !b } | |
p ++ ('A' to 'Z' filter (c => c != 'J' && !(p contains c))) | |
} |
NewerOlder