Skip to content

Instantly share code, notes, and snippets.

@shyouhei
shyouhei / chart.png
Last active September 29, 2017 05:50
chart.png
import enumlike.{EnumCompanionBase, EnumLike}
import scalikejdbc._
trait ScalikeJDBCEnumCompanion {
self: EnumCompanionBase =>
implicit def optionalTypeBinder(implicit ev: TypeBinder[EnumLikeType#ValueType]): TypeBinder[Option[A]] = ev.map(valueOf)
implicit def typeBinder(implicit ev: TypeBinder[EnumLikeType#ValueType]): TypeBinder[A] = optionalTypeBinder(ev).map(_.get)
}
(*
OCaml translation of the ideas explained in http://fumieval.hatenablog.com/entry/2014/09/22/144401
To emulate the higher kinded polymorphism, the technique used explained in https://ocamllabs.github.io/higher/lightweight-higher-kinded-polymorphism.pdf
*)
module StateMonad = struct
type ('s, 'a) m = 's -> 's * 'a
@curi1119
curi1119 / cubewatch.rb
Last active August 29, 2015 14:02
cubewatch.rb
# -*- coding: utf-8 -*-
def cmd(target, pane, remote_command)
command = "tmux send-keys -t:#{target}.#{pane} #{remote_command} C-m"
system command
end
def window(window_name)
system "tmux new-window -a -n #{window_name}"
end
@gakuzzzz
gakuzzzz / enum.scala
Last active April 26, 2023 12:26
Enum
trait EnumLike {
type Value
def value: Value
}
trait StringEnumLike extends EnumLike {
type Value = String
}
@gakuzzzz
gakuzzzz / 1_.md
Last active August 2, 2023 01:59
Scala の省略ルール早覚え

Scala の省略ルール早覚え

このルールさえ押さえておけば、読んでいるコードが省略記法を使っていてもほぼ読めるようになります。

メソッド定義

def concatAsString(a: Int, b: Int): String = {
  val a_ = a.toString();
  val b_ = b.toString();
@leque
leque / gist:8035729
Last active December 31, 2015 19:49

各言語のコレクション操作高階関数(メソッド、手続き)

Language
Common Lisp mapc mapcar find-if remove-if-not reduce reduce :from-end t some every
Scheme for-each map find filter fold, fold-left fold-right any, exists every, for-all
Haskell mapM_ map find filter foldl foldr any all
Caml Light do_list map - - it_list list_it exists for_all
OCaml iter map find filter, find_all fold_left fold_right exists for_all
F# iter map find filter fold foldBack exists forall
@furugomu
furugomu / millionlive.user.js
Last active December 15, 2015 02:29
ミリオンライブのアニメーションを全てスキップするグリモン(Chrome用)
// ==UserScript==
// @name million live
// @include http://app.ip.bn765.com/app/index.php/*
// @include http://imas.gree-apps.net/app/index.php/*
// ==/UserScript==
var script = document.createElement('script');
var f = function() {
var handler = function(e) {
if (!e.ctrlKey) return;