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.io.FileOutputStream | |
import java.net.URL | |
import java.nio.channels.{Channels, ReadableByteChannel} | |
import java.util.Scanner | |
import java.util.zip.ZipFile | |
object JenkinsPluginDownloader { | |
def main(args: Array[String]): Unit = { | |
if(args.length < 2) { | |
println(s"usage: scala JenkinsPluginDownloader junit 1.19") |
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
#!/usr/bin/python | |
import sys | |
import zipfile | |
import urllib | |
def download_plugin(name,version): | |
pluginUrl = "http://updates.jenkins-ci.org/download/plugins/%s/%s/%s.hpi" % (name,version,name) | |
print "downloading: %s" % pluginUrl | |
file = "%s.hpi" % name |
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 ScalaForApp extends App { | |
val scalaFor = new ScalaFor() | |
benchmark("testForeach", 10){scalaFor.testForeach()} | |
benchmark("testWhile", 10){scalaFor.testWhile()} | |
def benchmark(msg: String, times: Int)(f: => Unit): Unit = { | |
var i = 0 | |
val start = System.nanoTime() | |
while(i != times){ | |
f |
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 spark | |
import java.io._ | |
import java.util.zip.Deflater | |
import com.esotericsoftware.kryo.io.{Input => KryoInput, Output => KryoOutput} | |
import com.esotericsoftware.kryo.serializers.DeflateSerializer | |
import com.twitter.chill.{AllScalaRegistrar, EmptyScalaKryoInstantiator} | |
import org.apache.hadoop.io.compress.DeflateCodec |
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
//d3, a function return dom, but not handle a outside or global dom. | |
//refact: http://bl.ocks.org/mbostock/3885304 | |
function type(d) { | |
d.frequency = +d.frequency; | |
return d; | |
} | |
function createSvg(data) { | |
var margin = {top: 20, right: 20, bottom: 30, left: 40}, |
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
/** | |
* Curry - Function currying | |
* Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com | |
* Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) | |
* Date: 10/4/2008 | |
* | |
* @author Ariel Flesler | |
* @version 1.0.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
function add(x) {return function(y) {return x + y;}} | |
var add5 = add(5) | |
add5(1) | |
//log, warn,info,notice | |
function counter() {var count = 0; return function() {count ++; return count;}} | |
var increment = counter() | |
increment() //1 | |
increment() //2 |
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
(1 to 100 by 2).map(v => v * v).sum | |
//Parallel | |
(1 to 100 by 2).par.map(v => v * v).par.sum | |
//reduce can not Parallel | |
(1 to 100 by 2).reduce((acc,v) => acc + v * v) | |
//lazy, read from infinite | |
Stream.from(0).map(_ * 2 + 1).take(50).reduce((acc,v) => acc + v * v) |
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
function head(l) { return l[0];} | |
function tail(l) { return l.slice(1, l.length);} | |
function map(f,l) { if(l.length ==0 ) {return l;} | |
else {return [f(head(l))].concat(map(f,tail(l)));}} | |
map(function (i) {return i+1}, [1,2,3]) //[2,3,4] | |
function filter(p,l) { |
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
{ | |
"provider": { | |
"name": "Activate Service" | |
}, | |
"consumer": { | |
"name": "Zoo App" | |
}, | |
"interactions": [ | |
{ | |
"description": "Activate user with empty request body", |
NewerOlder