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
object BenchWithScala extends App { | |
val data = Array("foo", 23, true) | |
val n = 1000000 | |
val result = new Array[Any](n * 3) | |
var i = 0 | |
val before = System.currentTimeMillis() | |
while (i < n) { | |
var j = 0 | |
while (j < 3) { | |
result(i * 3 + j) = foo(data(j)) |
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 static void main(String[] args) { | |
int iterations = 1000000; | |
Object[] items = {"foo", 23, true}; | |
int size = items.length; | |
Object[] absoluteResult = new Object[iterations*size]; | |
long before = System.currentTimeMillis(); | |
for (int i=0; i < iterations; i++) { | |
for (int j=0 ; j< size; j++) { | |
absoluteResult[3*i+j]=foo(items[j]); | |
} |
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
ssh-add -l >/dev/null 2>&1 | |
if [ $? = 2 ]; then | |
# exit-status 2 = couldn't connect to ssh-agent | |
rm $SSH_AUTH_SOCK | |
echo -n "Starting SSH agent ... " | |
eval `ssh-agent -a $SSH_AUTH_SOCK` | |
ssh-add | |
fi |
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
// see http://wayne-adams.blogspot.fr/2011/10/generating-minable-event-stream-with.html | |
import scala.collection.JavaConversions.asScalaBuffer | |
import scala.collection.JavaConversions.asScalaIterator | |
import com.sun.jdi.connect.Connector | |
import com.sun.jdi.event.BreakpointEvent | |
import com.sun.jdi.request.BreakpointRequest | |
import com.sun.jdi.request.EventRequest | |
import com.sun.jdi.Bootstrap | |
import com.sun.jdi.StringReference |
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
def pascal(c: Int, r: Int): Int = | |
if (c == 0 || c == r) 1 | |
else if (r == 1) 1 | |
else pascal(c, r - 1) + pascal(c - 1, r - 1) |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>info.daviot</groupId> | |
<version>0.1-SNAPSHOT</version> | |
<artifactId>template</artifactId> |
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 java.net.URL | |
import scala.xml.XML | |
import org.xml.sax.InputSource | |
import scala.xml.parsing.NoBindingFactoryAdapter | |
import org.ccil.cowan.tagsoup.jaxp.SAXFactoryImpl | |
import java.net.HttpURLConnection | |
import scala.xml.Node | |
object HTML { | |
lazy val adapter = new NoBindingFactoryAdapter |
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 models | |
import scala.slick.session.Database | |
import Database.threadLocalSession | |
import play.api.db.slick.Config.driver.simple._ | |
case class Bar(id: Option[Int] = None, name: String) | |
object Bars extends Table[Bar]("bar") { | |
def id = column[Int]("id", O.PrimaryKey, O.AutoInc) |
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
abstract class Animal { | |
def greetings { | |
println("an animal") | |
} | |
} | |
trait Mammal extends Animal { | |
abstract override def greetings { | |
println("I'm a mammal") | |
super.greetings |
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 SingleThreadDemo { | |
public static void infiniteLoop() { | |
while (true) { | |
} | |
} | |
public static void main(String[] args) throws InterruptedException { | |
Thread t = new Thread() { | |
@Override | |
public void run() { |
OlderNewer