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 java.util.HashMap; | |
class Scratch { | |
public static void main(String[] args) { | |
String s = "444 2 6 444 66 33 888 444 8 2 22 555 33"; | |
HashMap<String, String> numToLetters = new HashMap<>(); | |
numToLetters.put("2", "abc"); | |
numToLetters.put("3", "def"); |
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
From camelcase to db column name | |
find | |
/([a-z_]*)([A-Z])(.*?$)/ | |
replace with | |
/\1_\l\2\3/ | |
repeatedly |
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
println("messing with strings") | |
implicit class Screamer(s:String) { | |
def ! = s.toUpperCase | |
def !(o:String) = s.toUpperCase + o.toLowerCase | |
def unary_! = s.toLowerCase | |
} | |
println("ciao"!) |
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 RepeatTest { | |
class RepeatHelper(cmd: => Unit) { | |
def until(cond: => Boolean): Unit = if (cond) repeat(cmd) | |
} | |
def repeat(cmd: => Unit): RepeatHelper = { | |
cmd | |
new RepeatHelper(cmd) | |
} |