Skip to content

Instantly share code, notes, and snippets.

View tototoshi's full-sized avatar

Toshiyuki Takahashi tototoshi

View GitHub Profile
@tototoshi
tototoshi / XHRImage.js.scala
Created June 28, 2014 15:55
Scala.js で xhr で画像をとってきて表示する
package com.github.tototoshi.gifplayer
import scala.scalajs.js
import js.annotation.JSExport
import org.scalajs.dom
@JSExport
object GIFPlayer extends js.JSApp {
def main(): Unit = {
@tototoshi
tototoshi / is_animated_gif.php
Last active August 29, 2015 14:02
PHP で GIF を読む
<?php
class GIFReader
{
const TRAILER = 0x3b;
const IMAGE_INTRODUCER = 0x2c;
const EXTENSION_INTRODUCER = 0x21;
const GRAPHIC_CONTROL_LABEL = 0xf9;
@tototoshi
tototoshi / notification_center.py
Created May 27, 2014 02:55
OS X での通知
import subprocess
script = 'display notification "Finished" with title "Job Finished" sound name "Tritone"'
p = subprocess.Popen(["osascript"], stdin=subprocess.PIPE)
p.stdin.write(script)
p.stdin.close()
p.wait()
@tototoshi
tototoshi / array_merge_kowai.php
Last active August 29, 2015 13:59
array_merge 怖い
<?php
/* !! 入力配列の中にある数値添字要素の添字の数値は、 結果の配列ではゼロから始まる連続した数値に置き換えられます。 */
$a = array(
'a' => 'aaa',
'100' => '100100100',
);
$b = array(
'b' => 'bbb',
@tototoshi
tototoshi / build.sbt
Last active January 4, 2016 03:09
ガラパゴス化するbuild.sbt
libraryDependencies ++= Seq(
jdbc,
cache,
"org.scalikejdbc" %% "scalikejdbc" % "[1.7,)", // by scalikejdbc organization (@seratch, .....)
"org.scalikejdbc" %% "scalikejdbc-interpolation" % "[1.7,)", // by scalikejdbc organization
"org.scalikejdbc" %% "scalikejdbc-play-plugin" % "[1.7,)", // by scalikejdbc organization
"com.github.tototoshi" %% "play-flyway" % "1.0.1", // by me
"com.github.mumoshu" %% "play2-memcached" % "0.3.0.2", // by @mumoshu
"com.github.nscala-time" %% "nscala-time" % "0.6.0", // by nscala-time organization (@kmizu, @xuwei_k ...)
"jp.t2v" %% "play2-auth" % "0.11.0", // by @gakuzzzz
@tototoshi
tototoshi / H2BrowserLauncher.scala
Created November 30, 2013 17:24
Open h2-browser with Skinny TaskLauncher
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
object TaskLancher extends skinny.task.TaskLauncher {
register("h2-browser", (params) => {
val f = Future {
org.h2.tools.Server.main()
}
f.onFailure { case e => e.printStackTrace() }
@tototoshi
tototoshi / anata_to_java.alpaca
Created November 30, 2013 14:36
あなたとJAVA
#!/usr/bin/env alpaca
visit("http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html")
click("input[type=radio]")
click(partialLink("macosx-x64.dmg"))
@tototoshi
tototoshi / slick_change.scala
Created September 12, 2013 05:58
The difference of Slick's API between 1.x and 2.0.0-M2
/* 1.0.0 */
import scala.slick.driver.PostgresDriver.simple._
case class Task(id: Int, name: String)
object Task extends Table[Task]("task") {
def id = column[Int]("id")
def name = column[String]("name")
def * = id ~ name <> (Task.apply _, Task.unapply _)
}
@tototoshi
tototoshi / Build.scala
Last active December 22, 2015 12:39
Retrieve request token asynchronously
import sbt._
import sbt.Keys._
object ScalaoauthasyncBuild extends Build {
lazy val scalaoauthasync = Project(
id = "scala-oauth-async",
base = file("."),
settings = Project.defaultSettings ++ Seq(
name := "scala-oauth-async",
val m1 = Map(1 -> 2, 2 -> 5, 3 -> 1)
val m2 = Map(2 -> 4, 3 -> 3, 4 -> 3)
def toMultiMap[A, B](m1: Map[A, B], m2: Map[A, B]): Map[A, Set[B]] =
(m1.toSeq ++ m2.toSeq).groupBy(_._1).mapValues(_.map(_._2).toSet)
/*
scala> toMultiMap(m1, m2).mapValues(_.max)
res0: scala.collection.immutable.Map[Int,Int] = Map(2 -> 5, 4 -> 3, 1 -> 2, 3 -> 3)
*/