Skip to content

Instantly share code, notes, and snippets.

View mather's full-sized avatar
🐻
friendly bear

Eisuke Kuwahata mather

🐻
friendly bear
View GitHub Profile
@mather
mather / Main.java
Created January 30, 2014 02:24
Scalaの列挙型をJavaから参照してみる ref: http://qiita.com/mather314/items/9c0e58578597e264c41d
public class Main {
public static void main(String[] args) {
// Signal class
System.out.println(Signal.class.toString());
// Signal$ class (Signal.type @ Scala)
System.out.println(Signal$.class.toString());
// Signal singleton object
Signal$ obj = Signal$.MODULE$;
@mather
mather / file0.scala
Created January 29, 2014 12:03
traitのmix-inと依存性注入について(備忘録) ref: http://qiita.com/mather314/items/d0165374f657e42c35e0
trait Greeter {
def greetTo(to: String): String
}
class HelloGreeter(name: String) extends Greeter {
def greetTo(to: String) = s"${name} says 'Hello ${to}!'"
}
new HelloGreeter("Alice").greetTo("Bob") //=> Alice says 'Hello Bob!'
@mather
mather / Enum.scala
Last active January 4, 2016 09:19
scala.EnumerationをJavaから使う場合
/*
* scalac Enum.scala
*/
/**
* Define Signal Enumeration
*/
object Signal extends Enumeration {
val Green = Value //=> Val(0, "Green")
$ brew install pari
@mather
mather / 0_reuse_code.js
Created December 19, 2013 06:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mather
mather / file0.py
Created November 26, 2013 02:20
fabricで鍵認証をセットする ref: http://qiita.com/mather314/items/d8db37ab6aaaaccdabba
from fabric.api import *
@task
def copy_id(file="~/.ssh/id_rsa.pub"):
"""Identityをauthorized_keysに追加する"""
put(file, "/tmp/id.pub")
try:
run("if [ ! -d ~/.ssh ]; then mkdir -p ~/.ssh; fi")
run("if [ ! -f ~/.ssh/authorized_keys ]; then cp /tmp/id.pub ~/.ssh/authorized_keys && chmod 0600 ~/.ssh/authorized_keys; fi")
run("cat ~/.ssh/authorized_keys /tmp/id.pub | sort -u > /tmp/uniq.authorized_keys")
@mather
mather / brew-subversion.patch
Created October 30, 2013 00:45
homebrew の subversion Formula に対する一時的な修正。
--- a/Library/Formula/subversion.rb
+++ b/Library/Formula/subversion.rb
@@ -2,8 +2,8 @@ require 'formula'
class Subversion < Formula
homepage 'http://subversion.apache.org/'
- url 'http://www.apache.org/dyn/closer.cgi?path=subversion/subversion-1.8.3.tar.bz2'
- mirror 'http://archive.apache.org/dist/subversion/subversion-1.8.3.tar.bz2'
+ #url 'http://www.apache.org/dyn/closer.cgi?path=subversion/subversion-1.8.3.tar.bz2'
+ url 'http://archive.apache.org/dist/subversion/subversion-1.8.3.tar.bz2'

Untitled Slide

Welcome to Glide.

Glide is the easiest way to create useful slide for all of your Gists.

  • input key <- to go backward.
  • input key -> to go forward.

Publishing

@mather
mather / fib_cycle.rb
Last active December 19, 2015 09:39
剰余環でフィボナッチ列を作ったらどんな周期が生まれるの?
# -*- encoding: utf-8 -*-
def fib_cycle(q,a,b)
fib = [a,b]
fib_array = [fib]
while true
fib = [fib[1], (fib[0] + fib[1]) % q]
if (index = fib_array.index(fib))
break
else
@mather
mather / gist:5771655
Last active December 18, 2015 10:49
SlickでTimestampのカラムをDateTimeとして扱うために、暗黙の変換(implicit conversion)を行う方法。 単なるメモなので、動作は保証出来ません。
/* util パッケージで宣言する場合 */
package object util {
import java.sql.Timestamp
import com.github.nscala_time.time.Imports.DateTime
import scala.slick.lifted.MappedTypeMapper
/* 結果値 Timestamp をアプリケーションでは DateTime に変換して使う */
implicit def dateTimeMapper = MappedTypeMapper.base[DateTime,Timestamp](
/* f: DateTime -> Timestamp */
dt => new Timestamp(dt.getMillis),