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
String signUp(Map namedArgs = [:], String firstName = 'Test', String lastName = 'User') { | |
namedArgs = namedArgs ?: [:] // In case they passed null to be a stinker | |
email = 'webonise.farmserver@gmail.com' | |
bothPasswords = "password" | |
setFullName(firstName, lastName) | |
organisation = namedArgs.remove('organisation') ?: "Webonise Farm" | |
phoneNumber = namedArgs.remove('phoneNumber') ?: "8001234567" | |
optionalTextingNumber = namedArgs.remove('optionalTextingNumber') ?: null | |
address = namedArgs.remove('address') ?: "9001 Glenwood Ave" | |
apartment = namedArgs.remove('apartment') ?: "100" |
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
/* | |
Three functions: | |
One if the message is hard-coded. | |
One if the message is provided entirely by the user. | |
One if the message needs a suffix provided by the user. | |
You could also create a function that used JavaScript's sprintf | |
and the arguments object (cast to an object by _.toArray()) for | |
truly flexible error messaging. That is left as an exercise for | |
the team. |
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 SamplePage { | |
static theResultDivImpl = { /* Your impl here */ } | |
static at = { /* Your basic test here */ && waitFor(theResultDivImpl) } | |
static content = { | |
theResultDiv(wait:true, theResultDivImpl) | |
} | |
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
scala> var opt = Some("Foo") | |
opt: Some[String] = Some(Foo) | |
So far, so good. I want to get the value from my Some. Checking the API for Option, and there's a .get() to retrieve the value — http://www.scala-lang.org/api/current/index.html#scala.Option | |
scala> opt.get() | |
<console>:9: error: not enough arguments for method apply: (index: Int)Char in class StringOps. | |
Unspecified value parameter index. | |
opt.get() | |
^ |
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
var foo; | |
_.each(bars, function(it) { | |
foo = it.someProperty; | |
... | |
}); | |
// foo is never used again |
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 org.specs2.mutable._ | |
import org.specs2.runner._ | |
import org.junit.runner._ | |
import play.api.test._ | |
import play.api.test.Helpers._ | |
import org.openqa.selenium.WebDriver | |
// This compiles | |
@RunWith(classOf[JUnitRunner]) | |
class IntegrationSpec extends Specification { |
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
/* | |
Here's the approach that I would take. In the description that follows, | |
P denotes the point where the user clicked, which has coordinates (x_p, y_p). | |
Each of these steps will involve checking pairs of points against the point | |
where the user clicked, denoted as A and B, with coordinates (x_a, y_a) | |
and (x_b, y_b). | |
We will move forward in three steps: | |
first, we will identify those pairs of points that could possibly be our point; | |
second, we will calculate the distance from the point to the line defined by |
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 Aliasing { | |
// Put your type alias right before the return value. | |
public static <L extends Long> String parseToHex(String str) { | |
return L.toHexString(L.parseLong(str)); | |
} | |
// Use this for when you have some ugly type. | |
public static <MAP extends Map<String,Set<String>>> boolean addToKey(String key, String value) { | |
MAP x = service.getKeyMap(); |
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
-# Here are the assumptions. | |
-# 1. We have a consistent UI concept of 'tabbed pages', which have a consistent frame (at least in terms of Haml). | |
-# 2. Each component of the tabbed pages can be represented as a partial. | |
-# | |
-# Given that, I propose that we create a helper that you would call like this. | |
= tabs {:first => "First Tab!", :second => "2nd Tab", :third => "last tab"} | |
-# The argument to that function we will call "tab_hash" | |
-# It would then first load the tab UI component, roughly equivalent to something like this. | |
= partial "partials/tabs", {:locals => tab_hash} |
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
{ | |
toFixed: function(num) { | |
return num.toFixed(0).replace(/./g, function(c, i, a) { | |
return i > 0 && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c; | |
}); | |
} | |
} |