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
def urlses(cl: ClassLoader): Array[java.net.URL] = cl match { | |
case null => Array() | |
case u: java.net.URLClassLoader => u.getURLs() ++ urlses(cl.getParent) | |
case _ => urlses(cl.getParent) | |
} | |
val urls = urlses(getClass.getClassLoader) | |
println(urls.mkString("\n")) |
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
private class CaseInsensitiveString(string: String) { | |
def =~(other: String): Boolean = | |
string equalsIgnoreCase other | |
def startsWithI(other: String) : Boolean = | |
string.toLowerCase startsWith other.toLowerCase | |
} | |
implicit def makeCaseInsensitiveString(string: String) = | |
new CaseInsensitiveString(string) |
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
class FormattableString(string: String) { | |
def %(args: Any*) = string.format(args:_*) | |
} | |
object FormattableString { | |
implicit def formattableString(string: String):FormattableString = new FormattableString(string) | |
} |
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 | |
trap 'exit 1' ERR | |
/usr/local/bin/sbt -Dsbt.log.noformat=true warn compile formatCheckStrict |
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 StringImplicits { | |
/** Maps weird unicode characters to ASCII equivalents | |
* This list comes from http://lexsrv3.nlm.nih.gov/LexSysGroup/Projects/lvg/current/docs/designDoc/UDF/unicode/DefaultTables/symbolTable.html */ | |
val unicodeCharMap = Map( | |
'\u00AB' -> "\"", | |
'\u00AD' -> "-", | |
'\u00B4' -> "'", | |
'\u00BB' -> "\"", | |
'\u00F7' -> "/", | |
'\u01C0' -> "|", |
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
// pattern matching on Int | |
object Int { | |
def unapply(s: String): Option[Int] = try { | |
Some(s.toInt) | |
} catch { | |
case _: java.lang.NumberFormatException => None | |
} | |
} |
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/python | |
import sys | |
import json | |
for f in sys.argv[1:]: | |
for line in open(f): | |
j = json.loads(line.strip()) | |
print json.dumps(j, sort_keys=True) |
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 re | |
import sys | |
import urllib | |
for line in sys.stdin: | |
m = re.search("""GET /search?\S*q=([^& ]*)""", line) | |
if m: | |
s = urllib.unquote_plus(m.groups(1)[0]) | |
try: | |
print s.decode('utf-8') |
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 | |
set -e | |
set -x | |
LOCKFILE=~/LOCK | |
if [ $1 -a $1 = "lockAcquired" ]; then | |
echo "I'm in." | |
sleep 10 |
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
perl -pe 'BEGIN{ $/="}{" } s/}{/}\n{/g' |
OlderNewer