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
// way faster than split2m | |
def split2f[T](list: Seq[T]): (Seq[T], Seq[T]) = { | |
val it = Iterator.iterate(true)(!_) | |
list.partition(_ => it.next) | |
} | |
// next approach, incredibly slow | |
// @TODO learn functional programming | |
def split2m[T](list: Seq[T]): (Seq[T], Seq[T]) = | |
list.foldLeft((Seq[T](), Seq[T]())) { | |
(tuple: (Seq[T], Seq[T]), element: T) => |
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 wandledi.java.Controller; | |
public class WandlediApp extends Controller { | |
public void index() { | |
getWriter().println("Hello World!"); | |
} | |
public static void main(String[] args) { | |
runStandAlone(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
implicit def trailingConditionals[T](any: => T) = new { | |
def provided(expr: Boolean) = if (expr) Some(any) else None | |
def unless(expr: Boolean) = if (!expr) Some(any) else None | |
} | |
implicit def verbosePlus(i: Int) = new { | |
def plus(j: Int): Int = { | |
println("Adding " + i + " and " + j); | |
i + 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
def form() { | |
<any name="author"/> merge <any value="Bobby"/> | |
// vs | |
get("name" -> "author").setAttribute("value", "Bobby") | |
// vs | |
<where name="author" setValue="Bobby"/>! | |
// vs | |
<any name="author"/> update { | |
"value" -> "Bobby" // [,\n"foo" -> "bar" ... | |
} |
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
def javaUsage() { | |
val model = new Model | |
model.onChange(new ChangeListener { | |
override def changed() { | |
// react | |
} | |
}) | |
} | |
def scalaUsage() { |
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
overriding method + in trait MapLike of type [B1 >: String](kv: (String, B1))scala.collection.mutable.Map[String,B1]; | |
[error] method + has incompatible type | |
[error] override def +[B1 >: String](kv: (String, B1)): Parameters = { | |
[error] ^ |
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
if(isComposite) { | |
_compositeKeyMembers.set(Some(new ArrayBuffer[SelectElement])) | |
println("set members to empty ArrayBuffer") | |
} | |
var res = proxy.invokeSuper(o, args); | |
if(isComposite) { | |
val ck = res.asInstanceOf[CompositeKey] | |
println("members before: " + ck._members) | |
ck._members = Some(_compositeKeyMembers.get.get.map(new SelectElementReference[Any](_)(NoOpOutMapper))) |
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
val msg: Option[String] = flash.get("msg") | |
// Do it like this? | |
$(".flashMessage") { node => | |
if (msg.isDefined) { | |
node.text = msg.get | |
} else node.hide() | |
} | |
// Or like this? |
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
Thread.start { | |
println("Waiting for Godot") | |
synchronized ("Godot") { | |
"Godot".wait() | |
} | |
println("Godot never came") | |
} | |
println("Press <return> to continue") | |
new BufferedReader(new InputStreamReader(System.in)).readLine() |
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
["/Volumes/finn/fitusagereporting/vendor/plugins/reporting_engine/lib/report/result.rb:160:in `sort!'", | |
"/Volumes/finn/fitusagereporting/vendor/plugins/reporting_engine/lib/report/result.rb:158:in `sort!'", | |
"/Volumes/finn/fitusagereporting/vendor/plugins/reporting_engine/lib/report/walker.rb:76:in `sort'", | |
"/Volumes/finn/fitusagereporting/vendor/plugins/reporting_engine/lib/report/walker.rb:36:in `headers'", | |
"/Volumes/finn/fitusagereporting/app/views/usage_reports/_usage_report_table.rhtml:42:in `_app_views_usage_reports__usage_report_table_rhtml__1158284054_2182735320_2781310'", | |
"/Users/markus/.rvm/gems/ree-1.8.7-2011.03/gems/actionpack-3.0.4/lib/action_view/template.rb:135:in `send'", | |
"/Users/markus/.rvm/gems/ree-1.8.7-2011.03/gems/actionpack-3.0.4/lib/action_view/template.rb:135:in `render'", | |
"/Users/markus/.rvm/gems/ree-1.8.7-2011.03/gems/activesupport-3.0.4/lib/active_support/notifications.rb:54:in `instrument'", | |
"/Users/markus/.rvm/gems/ree-1.8.7-2011.03/gems/actionpack-3.0.4/lib/action_view/tem |
OlderNewer