Skip to content

Instantly share code, notes, and snippets.

View tnoda's full-sized avatar

Takahiro Noda tnoda

View GitHub Profile
@tnoda
tnoda / PrimeNumber.scala
Last active August 29, 2015 14:00
Sieve of Eratosthenes in Scala
import scala.annotation._
import scala.collection.mutable.ArrayBuffer
object PrimeNumber {
def apply(n: Int = 1000000): Array[Int] = sieve(n)
def sieve(n: Int): Array[Int] = {
val primes = new ArrayBuffer[Int]
val isPrime = Array.fill(n + 1)(true)
@tnoda
tnoda / BinarySearch.scala
Last active August 29, 2015 14:01
An unoptimized Scala equivalent of C++'s std::lower_bound and std::upper_bound
import scala.annotation.tailrec
object BinarySearch {
def lowerBound(xs: Array[Int], x: Int): Int = {
@tailrec
def loop(first: Int, count: Int): Int =
if (count == 0) first
else {
val step = count / 2
if (xs(first + step) < x) loop(first + step + 1, count - step - 1)
@tnoda
tnoda / pe10.clj
Last active August 29, 2015 14:03
Project Euler Problem 10 は Clojure でやっても 100ms 未満で計算できるはず。
(ns tnoda.pe10)
(defn- sieve
"Returns an array of primes below len. Retrieved from
https://github.com/tnoda/tnoda.math.prime."
[^long len]
(let [n len
not-prime (doto (boolean-array n)
(aset 0 true)
(aset 1 true))
@tnoda
tnoda / cf.go
Last active August 29, 2015 14:04
cf.go
package main
import (
"bufio"
"errors"
"fmt"
"io"
"os"
"strconv"
)
@tnoda
tnoda / mon-css-color.el
Created July 28, 2014 06:09
Mirror mon-css-color.el
;;; mon-css-color.el --- Highlight and edit CSS colors
;; -*- mode: EMACS-LISP; -*-
;;; ================================================================
;; Copyright © 2009, 2010 MON KEY. All rights reserved.
;; Copyright © 2008, 2009 Lennart Borgman
;; Copyright © 2008 Niels Giesen
;;; ================================================================
;; AUTHOR: Niels Giesen
$ make recipes/helm-ad
• Building recipe helm-ad ...
emacs --no-site-file --batch -l package-build.el --eval "(let ((package-build-stable nil) (package-build-archive-dir (expand-file-name \"./packages\" pb/this-dir))) (package-build-archive 'helm-ad))"
Error reading recipe /Users/tnoda/work/melpa/recipes/helm-ad~: Recipe 'helm-ad~' contains mismatched package name 'helm-robe'
;;; helm-ad
Fetcher: github
Source: tnoda/helm-ad

ぼっち.scala --- 「ぼっち」でも始められる Scala

第4回 Scala 関西ビギナーズ (session|LT) の提案.

概要

Scala はその人気の高まりとともに世界的には普及期に入りつつある. 日本においても,東京都心の D 社や D 社などを中心に Scala プログラマーが増えつつある. しかし,関西を含むほとんどの地域では Scala プログラマーお人口密度が低く,

@tnoda
tnoda / proposal.md
Last active August 29, 2015 14:07
Clojure 夜会プロポーザル

Clojure 夜会 LT プロポーザル

次の 1--3 のどれかで LT したいです.

  1. CodinGame チュートリアルをライブコーディング
    • CodinGame についての簡単な説明
    • チュートリアル問題の解説
    • チュートリアル問題をライブコーディング
  • ネットワーク繋らないとつらい (WiMAX ルータを持っていく予定)
(let [v ["ジョ" "ン" "ボ" "ヴィ"]
a (reverse ["ジョン" "ボン" "ジョヴィ"])
s (->> (repeatedly #(str (rand-nth v) (rand-nth v)))
(reductions #(cons %2 %) [])
(drop-while #(not= a (take 3 %)))
first)]
(println (->> (reverse s)
(interpose "・")
(apply str))
"\n"
@tnoda
tnoda / proposal.org
Last active August 29, 2015 14:10
#scala_kb proposal

12/13(土) 第1回 Scala 関西勉強会プロポーザル

プロポーザル

12/13(土) 第1回 Scala 関西勉強会.次の (1) か (2) のどちらかを予定.

(1) Competitive Scala Programming

前回の