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
/* | |
* Copyright (C) 2012 The Guava Authors | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | |
* in compliance with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software distributed under the License | |
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
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 sbt._ | |
import sbt.Keys._ | |
import sbtassembly.Plugin.{MergeStrategy, assemblySettings, defaultMergeStrategy} | |
import sbtassembly.Plugin.AssemblyKeys.{assembly, mergeStrategy} | |
import sbtassembly.AssemblyUtils | |
object AppBuild extends Build { | |
lazy val app = Project( | |
id = "app", | |
base = file("app"), |
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
#!/usr/bin/env python | |
import SimpleHTTPServer | |
import BaseHTTPServer | |
import sys | |
""" | |
Usage: | |
python httpd.py [port] [additional headers ...] |
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 java.util.concurrent.Callable; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.LinkedBlockingQueue; | |
import java.util.ArrayList; | |
import java.util.Timer; | |
import java.util.TimerTask; | |
import java.util.Random; | |
class Main { |
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
object Main { | |
def main(args: Array[String]) = { | |
val data = testData() | |
val start1 = System.currentTimeMillis() | |
data.foreach(isValidIpFormat1) | |
val end1 = System.currentTimeMillis() | |
println("1: " + (end1 - start1)) | |
val start2 = System.currentTimeMillis() |
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
object Main { | |
def main(args: Array[String]) { | |
val to_s: Int => String = _.toString | |
val start = System.currentTimeMillis() | |
(0 until 5000000).foreach { i => | |
f(to_s, i) | |
// g(i) | |
} | |
val end = System.currentTimeMillis() | |
println(end - start) |
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 scala.collection.mutable.ArrayBuffer | |
import scala.util.Random | |
object Main { | |
def main(args: Array[String]) { | |
val data = testdata() | |
val start = System.currentTimeMillis() | |
val ret = f(data) // g, h | |
val end = System.currentTimeMillis() | |
println(ret) |
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
case class User(username: String, password: String) | |
trait UserRepositoryComponent { | |
val userRepository: UserRepository | |
// ordinal class | |
class UserRepository { | |
def authenticate(user: User): User = { | |
println("authenticating user: " + user) | |
user | |
} |
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
// ==UserScript== | |
// @name GitHub Wiki TOC | |
// @namespace http://www.daimatz.net/ | |
// @version 0.11 | |
// @description Add TOC to GitHub Wiki Page | |
// @include https://github.com/*/*/wiki/* | |
// @license MIT License(http://en.wikipedia.org/wiki/MIT_License) | |
// ==/UserScript== | |
(function() { |
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
f = Proc.new { puts "start f"; sleep 10; puts "end f" } | |
g = Proc.new { puts "start g"; sleep 5 ; puts "end g" } | |
puts "start" | |
[f, g].map{ |prc| Thread.new{ prc.call } }.map(&:join) | |
p Thread.list | |
puts "all end" |
NewerOlder