RSS

================================================================================

Before Today

================================================================================

If I was crying
In the van, with my friend
It was for freedom
From myself and from the land

================================================================================

12/03/2010 16:03:23

--------------------------------------------------------------------------------

10/19/2010 18:40:00

test

--------------------------------------------------------------------------------

10/14/2010 11:29:00

Mac | F11

Windows でいう win + D
Mac OS 10.5 だけかもしれない

--------------------------------------------------------------------------------

10/01/2010 02:55:24

Scala | Project Euler Probrem 1

val r = (0 to 999)
((r by 3) ++ (r by 5)).distinct.sum // => 233168

--------------------------------------------------------------------------------

10/01/2010 02:50:00

Scala | Project Euler Probrem 2

import scala.collection.mutable

def isEven(n: BigInt): Boolean = (n % 2 == 0)

var fibs = mutable.Map[Int, BigInt]()
def fib(n: Int): BigInt = {
  if (fibs.isDefinedAt(n)) return fibs(n)
  if (n <= 2) return 1;
  fibs(n) = fib(n - 1) + fib(n - 2)
  return fibs(n)
}

var result = (1 to 28).map(n => fib(n)).reduceLeft { (a, b) => if (isEven(b)) println(a, b); if (isEven(b)) a + b else a + 0 }
println(result)
//(1,2)
//(3,8)
//(11,34)
//(45,144)
//(189,610)
//(799,2584)
//(3383,10946)
//(14329,46368)
//(60697,196418)
//257115

--------------------------------------------------------------------------------

09/23/2010 00:45:16

Scala | collatz2

def collatz(n: Int, list: List[Int] = Nil): List[Int] = n match {
  case 1               => (n :: list).reverse
  case n if n % 2 == 0 => collatz(n / 2, n :: list)
  case _               => collatz(3 * n + 1, n :: list)
}

println(collatz(69)) // => List(69, 208, 104, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1)

--------------------------------------------------------------------------------

09/21/2010 23:18:13

Scala | collatz

def collatz(n: Int) = n match {
  case n if n % 2 == 0 => n / 2
  case n               => (3 * n) + 1
}

def nestWhileList[A](f: A => A, initial: A, p: A => Boolean) = {
  val result = Stream.iterate(initial)(f).takeWhile(p).toList
  result :+ f(result.last)
}

val cs = nestWhileList(collatz(_: Int), 200, (_: Int) != 1)

--------------------------------------------------------------------------------

09/14/2010 01:32:51

Scala | repl 補完

scala> "foo".

+                     asInstanceOf          charAt                codePointAt           codePointBefore       codePointCount        compareTo             compareToIgnoreCase   concat
contains              contentEquals         endsWith              equalsIgnoreCase      getBytes              getChars              indexOf               intern                isEmpty
isInstanceOf          lastIndexOf           length                matches               offsetByCodePoints    regionMatches         replace               replaceAll            replaceFirst
split                 startsWith            subSequence           substring             toCharArray           toLowerCase           toString              toUpperCase           trim

“foo” で タブを押すと補完される

--------------------------------------------------------------------------------

09/07/2010 10:07:20

"もうこの時点で「いやいやrequireは絶対パスで書くだろ、常識的に」とか「autoloadじゃないの?」とか「"

--------------------------------------------------------------------------------

08/26/2010 19:08:20

Smarty | 変数の展開 - バッククオートを使う

<% assign var="url" value="http://`$rows.foo`.sample.com" %>

--------------------------------------------------------------------------------

08/26/2010 10:46:23

"「あなたへのおすすめ」じゃなくて「あなたが意地張ってフォローしない人たち」になってる"

--------------------------------------------------------------------------------

08/25/2010 06:16:35

GAE | 開発環境の管理画面の URL

/_ah/admin/

--------------------------------------------------------------------------------

08/18/2010 11:15:20

bash | if 文を一行で

$ [ -d /var/log/hoge ] && echo 'HELLO'
$ [ ! -d /var/log/hoge ] && echo 'HELLO' # 否定

--------------------------------------------------------------------------------

08/13/2010 04:47:15

Scala | 単語の削除

def deleteWord(replaceWords: String, originalWords: String) = {
  val pattern = "[" + replaceWords + "]"
  pattern.r.replaceAllIn(originalWords, " ").mkString
}

println(deleteWord("golf","flogwaiurhgm"))

http://d.hatena.ne.jp/mzp/20100811/deleteWord

--------------------------------------------------------------------------------

07/27/2010 16:22:29

SSL | Connection Partially Encrypted

サイトの一部に http で通信しているものがあり、完全に暗号化できているわけではないというエラー。

--------------------------------------------------------------------------------

pg 1 of 40

================================================================================

Designed: Robert Boylan
Powered: Tumblr