Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@uehaj
uehaj / Cargo.toml
Last active January 21, 2018 10:59
TAPLのML実装をRustでやってみるシリーズ「7章 ラムダ計算のML実装」
[package]
name = "ch7"
version = "0.0.1"
authors = ["UEHARA Junji <uehaj@jggug.org>"]
@uehaj
uehaj / file0.txt
Last active August 29, 2015 14:16
第27回 オフラインリアルタイムどう書くの問題「分岐と行き止まり」をRustで解く ref: http://qiita.com/uehaj/items/25caa06ce666fc175d99
/*
http://nabetani.sakura.ne.jp/hena/ord27raswi/
*/
#![feature(collections)]
#![feature(core)]
extern crate core;
use std::string::String;
use std::collections::BTreeSet;
use core::iter::FromIterator;
@uehaj
uehaj / ShowTestTarget.groovy
Last active August 29, 2015 14:14
直近の10個のログから、修正量の多い順にファイル名を表示する
class ShowTestTarget {
static void main(args) {
"git log -10 --numstat --pretty=<@>%s".execute().text.split(/<@>/).drop(1).collect{it.split(/\n/).drop(2)}.flatten().collectMany { def m= (it=~ /(\d+)\W+(\d+)\W+(.*)/); m.matches()?[(m.collect{it}[0][1..-1])]:[] }.sort{-(Integer.parseInt(it[0])+Integer.parseInt(it[1]))}.each {
println it[2]
}
}
}
import Graphics.Input (..)
import Signal
import Signal(Channel)
import Graphics.Element (..)
import Text(..)
import List(..)
type Keys = Number Int | Add | Sub | Mul | Div | Clear | Enter
keys : Channel Keys
import groovy.transform.SourceURI
class UriTest {
static main(String[] args) {
@SourceURI String src
println src
}
}
FROM onesysadmin/gvm
# [Build]
# cd /path/to/grails/project
# docker build -t you/product .
# [Run]
# docker run -it -v /path/to/grails/project:/app --link pg:db you/project:latest
# docker run -d -v /path/to/grails/project:/app --link pg:db you/project:latest run-app
ENV PROXY_HOST 1.2.3.4 # proxy address/hostname
ENV PROXY_PORT 18080 # proxy port
@uehaj
uehaj / TypeClassTest.groovy
Last active August 29, 2015 14:08
TypeClass for groovy
import java.util.function.*
import groovy.transform.TypeChecked
import static Util.*
/* Type Classes */
@TypeChecked
interface Semigroup<T> {
def T mappend(T t1, T t2);
}
@TypeChecked
@uehaj
uehaj / gist:046956f36f0fe29ee75f
Created October 27, 2014 06:50
Higher kind type parameter sample for groovy
import java.util.function.*;
interface Functor<T,R> {
public R fmap(Function<T,R> func, T t);
}
interface Applicative<A,T,R> extends Functor<T,R> {
public A<T> pure(T t);
public A<T> ap(A<Function<T,R>> func, A<R> a); // <*> :: f (a -> b) -> f a -> f b
}
import Window
thickLine = { defaultLine | width <- 20 }
roundLine = { thickLine | cap <- Round }
smoothLine = { thickLine | join <- Clipped, cap <-Round }
main = let
disp w h = collage w h
[ move (-100,250) <| outlined thickLine <| ngon 5 100
, move (-100,250) <| outlined thickLine <| polygon [(200, 0),(250,100),(150,100)]
import Mouse
import Window
data Event = MouseUp | MouseDown | MouseMove Int Int
type Status = { mouseDown:Bool, points:[(Int, Int)] }
initialState : Status
initialState = Status False []
nextState : Event -> Status -> Status