This file contains hidden or 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 A | |
| def name | |
| "itang" | |
| end | |
| end | |
| macro field(obj, name) | |
| if {{obj}}.responds_to? {{name}} | |
| {{obj}}.{{name.id}} | |
| end |
This file contains hidden or 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
| a = "hello" | |
| def get_it(a) | |
| if a | |
| "a" | |
| else | |
| nil | |
| end | |
| end |
This file contains hidden or 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/bash | |
| DIR=$1 | |
| TARGET=$DIR/package.sql | |
| contains() { | |
| string="$1" | |
| substring="$2" | |
| if test "${string#*$substring}" != "$string" | |
| then |
This file contains hidden or 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> import play.api.libs.json._ | |
| scala> val json = Json.parse(s"""{"a":1,"b":[1,2,3]}""") | |
| json: play.api.libs.json.JsValue = {"a":1,"b":[1,2,3]} | |
| scala> val a = json \ "a" | |
| a: play.api.libs.json.JsLookupResult = JsDefined(1) | |
| scala> a == JsDefined(JsNumber(1)) | |
| res27: Boolean = true |
This file contains hidden or 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
| a = nil | |
| if true | |
| a = "hello" | |
| end | |
| # puts a.length //undefined method 'length' for Nil | |
| puts a.length if a |
This file contains hidden or 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
| crul get http://localhost:9000/echo_json -d '{"hello":"world"}' -H Content-Type:application/json -j |
This file contains hidden or 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
| (as-> "hello" name (count name) (str "hello-" name )) | |
| => | |
| "hello-5" |
This file contains hidden or 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 play.api.Logger | |
| import play.api.mvc._ | |
| import scala.concurrent.Future | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| object XRuntimeFilter extends Filter { | |
| def apply(next: (RequestHeader) => Future[Result])(request: RequestHeader): Future[Result] = { | |
| val s = System.nanoTime() | |
| val result = next(request).map { response => | |
| val e = System.nanoTime() |
This file contains hidden or 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
| <classpathentry kind="src" path="target/scala-2.11/twirl/main"/> |
This file contains hidden or 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
| weeks = "monday","tuesday","wednesday","thursday", "friday", "saturday", "sunday" | |
| weeks.each do |w| | |
| puts "schedule_#{w}_start schedule_#{w}_end" | |
| end | |
| puts "*" * 100 | |
| weeks.each do |w| |