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 * as fg from "fast-glob"; | |
import * as fs from "fs"; | |
import { format } from "sql-formatter"; | |
/** | |
* We need to create our own sql formatter as prettier-plugin-sql is busted. | |
* Won't support passing of paramTypes to underlying sql-formatter. | |
*/ | |
// find files recursively if not provided as argument | |
const files = |
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
(defspec smallest-change | |
(prop/for-all [[coinset amount] gen-amount-from-coinset] | |
(let [change (make-change coinset amount)] | |
(= 1 (count change))))) |
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
repl=> (defmacro add-params [expr & params] | |
#_=> `(~@expr ~@params)) | |
;; add-params works as intended for regular functions | |
repl=> (macroexpand '(add-params (+ 5 6) 7 8 9)) | |
(+ 5 6 7 8 9) | |
repl=> (add-params (+ 1 2) 3 4 5) | |
15 |
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
bash-3.2$ scala | |
Welcome to Scala version 2.9.1.RC4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> val checked: Option[xml.Text] = None | |
checked: Option[scala.xml.Text] = None | |
scala> val a = <input checked={checked} /> | |
a: scala.xml.Elem = <input ></input> |
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
val command: String = params("Command").getOrElse("") | |
val response: String = command match { | |
// valid for any user | |
"help" => help(...) | |
"info" => info(...) | |
// only admin can execute the following commands | |
"add" => | |
if (isAdmin) | |
addUser(...) | |
else |
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
val command: String = params("Command").getOrElse("") | |
val response: String = command match { | |
// valid for any user | |
"help" => help(...) | |
"info" => info(...) | |
// only admin can execute the following commands | |
"add" if isAdmin => addUser(...) | |
"delete" if isAdmin => deleteUser(...) | |
_ => "unknown or unauthorized command" | |
} |