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
def factors(n:Int):List[Int] = for(x <- List.range(1,n+1); if n % x == 0) yield x | |
def prime(n:Int):Boolean = (factors(n) == List(1,n)) | |
def seq(n:Int,m:Int):Stream[Int] = n #:: seq(n+m,m) | |
//for(x <- seq(10000,1);if prime(x)) print(x + ",") | |
def next_prime(n:Int):Int = if(prime(n)) n else next_prime(n+1) | |
def primes(n:Int):Stream[Int] = { | |
val m = next_prime(n) | |
m #:: primes(m+1) |
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
val lib = Project("lib", file("lib")) | |
val libTest = Project("lib", file("libTest"), settings = Seq(dxInputs in Android <<= (dxInputs in Android, classDirectory in Compile in lib, unmanagedBase) map { (dxInputs, classDirectory, unmanagedBase) => | |
dxInputs :+ classDirectory :+ unmanagedBase | |
}) |
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
package com.qtamaki.tryparser | |
import scala.util.parsing.combinator._ | |
class Arith extends JavaTokenParsers { | |
def expr: Parser[Double] = { | |
term~rep( | |
"+"~>term ^^ { | |
case d:Double => d.+(_:Double) | |
} |
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
package com.qtamaki.tryparser | |
import scala.util.Random | |
class ExpressionGenerator { | |
val r = new Random() | |
def gen(facts: Int):String = rands.take(facts).toList match { | |
case x :: xs => xs.foldLeft[String](x.toString)(ope) | |
case Nil => "" |
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
package com.qtamaki.tryrhino | |
import org.mozilla.javascript.Context | |
import com.qtamaki.tryparser.ExpressionGenerator | |
import com.qtamaki.tryparser.Arith | |
object RhinoApp { | |
def main(args: Array[String]): Unit = { | |
val cx = Context.enter() |
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 PARTAKE_TWITTER_LINK | |
// @namespace partake | |
// @include http://partake.in/events/* | |
// @version 1 | |
// ==/UserScript== | |
(function(){ | |
function makeFunc(twid){return function(){ | |
// window.location.target = "_blank"; |
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 System.Random | |
------------------------------------------------------------------------------ | |
-- RANDOM Stream | |
------------------------------------------------------------------------------ | |
randomX x = randomR (0,x -1) | |
type RandomF = StdGen -> (Int, StdGen) | |
ranStImpl :: StdGen -> RandomF -> [Int] |
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
tails :: String -> [String] | |
tails [] = [] | |
tails (x:[]) = [[x]] | |
tails (x:xs) = (x:xs) : tails xs | |
isDigit :: Char -> Bool | |
isDigit x = '0' < x && x < '9' | |
f :: String -> String -> String | |
f (xs) (y:[]) = xs |
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
database.ymlを使わない場合 | |
http://d.hatena.ne.jp/ux00ff/20120229/1330502390 | |
PhantomJS ヘッドレスなWeb実行環境 | |
wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2 | |
tar jxvf phantomjs-1.9.0-linux-x86_64.tar.bz2 | |
cat > loadspeed.js | |
var page = require('webpage').create(), |
OlderNewer