Skip to content

Instantly share code, notes, and snippets.

@akihiro4chawon
akihiro4chawon / cyclical.scala
Created April 24, 2011 05:44
Hamming's Problem in scala
object Main {
def humming: Iterator[BigInt] = {
object ForwardReferenceable {
def output: Iterator[BigInt] = Iterator(BigInt(3), BigInt(4), BigInt(5)) ++ merged
val Seq(result, m2, m3, m5) = tee(output, 4)
val merged = merge(m2 map {_ * 2}, m3 map {_ * 3}, m5 map {_ * 5})
}
Iterator(BigInt(1), BigInt(2)) ++ ForwardReferenceable.result
}

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

def index(id:String) = Action {
getFirstData(id)
}
private def getFirstData(id:String) = {
Cache.get(id) match {
case Some(id2) => getSecondData(id2)
case None => NotFound
}
}
private def getSecondData(id2:String) = {
@loicdescotte
loicdescotte / Forcomptran.md
Last active May 27, 2023 06:27
Scala for comprehension translation helper

Scala for comprehension translation helper

"For comprehension" is a another syntaxe to use map, flatMap and withFilter (or filter) methods.

yield keyword is used to aggregate values in the resulting structure.

This composition can be used on any type implementing this methods, like List, Option, Future...

@daneko
daneko / build.sbt
Last active October 13, 2016 11:10
play2.x系Json周りメモ AngularJs + coffee + Play のためのメモ
// play-jsonをフツーのプロジェクトでも使いたいサンプル
name := "hello"
version := "1.0"
scalaVersion := "2.10.3"
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
@mkacky
mkacky / run_sim.sh
Last active December 16, 2015 07:58
xargsでリダイレクトを行うためのワンクッション。
#!/bin/bash
####################
## リダイレクト先に「xargsにパイプを経由して渡した引数を含むファイル名」を設定するためのワンクッション
func()
{
## コマンド及び引数の並び
# func <seed>
## 時間がかかる処理
@tsupo
tsupo / Twitter_API_1.1_rate_limit.txt
Created May 17, 2013 05:12
Twitter API 1.1 / 実行回数制限
Twitter API 1.1 の現行APIの制限
(REST API v1.1 Limits per window by resource)
https://dev.twitter.com/docs/rate-limiting/1.1/limits
・15分辺り最大何回実行できるか
Timelines
GET statuses/mentions_timeline 15回
GET statuses/user_timeline 180回/user, 300回/application
@thanhhh
thanhhh / Redmine installation
Last active March 11, 2024 12:23
How to configuration Redmine with puma and running on nginx (based on Gitlab's installation)
Add config/puma.ruby
--------------------
cd /home/redmine/redmine
sudo -u redmine -H curl --output config/puma.rb https://gist.github.com/thanhhh/5610668/raw/fdfe2a865c3a0afe912c8784c971ea7ca3e64cfd/puma.rb
Install Init Script
--------------------
Download the init script (will be /etc/init.d/redmine):
@sifue
sifue / DateTimeTypeMapper.scala
Last active December 20, 2015 22:19
org.joda.time.DateTimeをScala Slick 1.0.x で利用するためのTypeMapper。内部的にTimestampに変換している。また、比較演算子等も利用できる。ただし、日付リテラルは、MySQLのDATETIMEを前提としたものになっている。
import scala.slick.lifted._
import java.util.Date
import org.joda.time.DateTime
import scala.slick.driver.{BasicDriver, BasicProfile}
import scala.slick.session.{PositionedResult, PositionedParameters}
import scala.language.implicitConversions
/**
* [[org.joda.time.DateTime]]を[[java.sql.Date]]にSlickにおいて暗黙変換して利用する
*