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 laozhao | |
import java.util.concurrent.Semaphore | |
trait IBuffer { | |
def flush: Unit | |
} | |
class Item { | |
val semaphore = new Semaphore(0) |
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 scala.collection.mutable.ListBuffer | |
import scala.collection.mutable.HashMap | |
case class Account(val user:String,val money:Double) | |
sealed abstract class Op | |
case class Despoit(val money:Double) extends Op |
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 jdbctest | |
import org.scalatest.FlatSpec | |
import org.scalatest.Matchers | |
import model.Tables | |
import model.Tables.UserRow | |
import scala.concurrent.Future | |
import scala.concurrent.Await | |
class JDBCTestSpec2 extends FlatSpec with Matchers { |
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 scala.collection.mutable.ListBuffer | |
import scala.collection.mutable.HashMap | |
import scala.annotation.tailrec | |
/* | |
** author fairjm | |
** https://projecteuler.net/problem=5 | |
*/ | |
object P5 { | |
def getPrimesLEQ(num:Int):List[Int] = { |
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
defmodule Wordcount do | |
@moduledoc "a simple wordcount program by fairjm" | |
@nodecount 3 | |
def start(file) do | |
s = self | |
spawn(fn -> count(file,s) end) | |
end | |
defp count(file,caller) do |
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 script | |
// batch download from http://www.andrew.cmu.edu/course/15-749/READINGS/optional/ | |
//extract file name | |
def getAllFiles(url:String):List[String] = { | |
import scala.io._ | |
val regex = """<a href="(.+?\.pdf)">""".r | |
val content = Source.fromURL(url).mkString | |
regex.findAllMatchIn(content).map(_.group(1)).toList | |
} |
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 com.cc.graph.algorithm | |
import com.cc.graph.base.Graph | |
import scala.collection.mutable.ListBuffer | |
import scala.collection.mutable.HashMap | |
object NMI { | |
/** | |
* NMI(A,B)=2*H(A)/(H(A)+H(B)) |
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 StringCompressUtil { | |
private static final String DEFAULT_ENCODING = "UTF-8"; | |
public static String compress(final String str) throws IOException { | |
if (StringUtils.isEmpty(str)) { | |
return str; | |
} | |
String result; | |
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { |
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
open System.Text | |
open System.IO | |
open System.IO.Compression | |
let iso8859_1 = Encoding.GetEncoding("ISO-8859-1"); | |
let compress (s:string) = | |
let sBytes = Encoding.UTF8.GetBytes(s) | |
use original = new MemoryStream(sBytes) | |
let oBytes = using(new MemoryStream())(fun out -> |
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.IOException; | |
import java.io.PrintStream; | |
import java.lang.reflect.Method; | |
import java.util.LinkedList; | |
import java.util.List; | |
import org.apache.commons.lang3.ArrayUtils; | |
import org.springframework.core.io.Resource; | |
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | |
import org.springframework.core.io.support.ResourcePatternResolver; |
OlderNewer