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
package org.pinky.code.extension.guice; | |
import com.google.inject.Key | |
import com.google.inject.servlet._ | |
import javax.servlet.http.{HttpServletResponse, HttpServletRequest, HttpServlet} |
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> f@Hedwig:~ $ scala | |
Welcome to Scala version 2.8.0.r21323-b20100403020201 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_17). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import java.lang.Math._ | |
import java.lang.Math._ | |
scala> def hasDivisor(i:Int) = { (2 to sqrt(i).toInt).exists{ x => i%x == 0 } } | |
hasDivisor: (i: Int)Boolean |
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
$ mvn clean install | |
Using Java version: 1.6 | |
[INFO] Scanning for projects... | |
WAGON_VERSION: 1.0-beta-2 | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Building specs_2.8.0.Beta1 | |
[INFO] task-segment: [clean, install] | |
[INFO] ------------------------------------------------------------------------ | |
Downloading: http://scala-tools.org/repo-releases/org/apache/maven/plugins/maven-clean-plugin/2.2/maven-clean-plugin-2.2.pom | |
[INFO] Unable to find resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' in repository scala-tools.org (http://scala-tools.org/repo-releases) |
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
/* Recursively compose an arbitrarily long list of functions into a single function. */ | |
function compose() { | |
/* One function, nothing to compose. */ | |
if(arguments.length == 1) | |
return arguments[0]; | |
else { | |
/* Compose the head with the immediate successor. */ | |
var args = arguments; | |
/* The composition: f(g(x)) */ | |
var f = [function() { |
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
public class Foo { | |
public String theCurrentWay(SomeData data) { | |
if (data.getFoo() != null) { | |
if (data.getFoo().getBar() != null) { | |
if (data.getBlah() != null) { | |
return data.getFoo().getBar().getBlah().toString(); | |
} | |
} | |
} | |
return null; |
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> f@Hedwig:~ $ scala | |
Welcome to Scala version 2.8.0.r21323-b20100403020201 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_17). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import java.lang.Math._ | |
import java.lang.Math._ | |
scala> def hasDivisor(i:Int) = { (2 to sqrt(i).toInt).exists{ x => i%x == 0 } } | |
hasDivisor: (i: Int)Boolean |
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
f@Hedwig:~$ scala | |
Welcome to Scala version 2.8.0.r21323-b20100403020201 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_17). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
//Some fun | |
scala> def fun(integer:Option[Int]) = println(integer.getOrElse("None")) | |
fun: (integer: Option[Int])Unit | |
// having fun |
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
config.action_controller.asset_host = Proc.new do |source, request| | |
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com" | |
ssl_host = "https://asset1.backpackit.com" | |
if request.ssl? | |
case | |
when source =~ /\.js$/ | |
ssl_host | |
when request.headers["USER_AGENT"] =~ /(Safari)/ | |
non_ssl_host |
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
// A simple trait: | |
trait CascadingActions { | |
implicit def tToActioneerT[T](t: T) = Actioneer(t) | |
case class Actioneer[T](tee: T) { | |
def withAction(action: (T => Unit)): T = | |
withActions(action) | |
def withActions(actions: (T => Unit)*): T = { |
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
// Welcome to Scala version 2.7.5.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_20). | |
// Type in expressions to have them evaluated. | |
// Type :help for more information. | |
scala> import dispatch._ | |
import dispatch._ | |
scala> import oauth._ | |
import oauth._ |
OlderNewer