Skip to content

Instantly share code, notes, and snippets.

View kakkun61's full-sized avatar
🚂
Choo-choo

Kazuki Okamoto kakkun61

🚂
Choo-choo
View GitHub Profile
FROM ubuntu
RUN apt update
RUN apt install -y libmysqlclient-dev gcc rsync
root@2aaacf161943:/wd/app# stack ghc -- -XTemplateHaskell -XRecordWildCards -XNoImplicitPrelude -XMultiParamTypeClasses -XOverloadedStrings -XFlexibleContexts -ddump-splices Model/Tweet.hs
[1 of 5] Compiling DataSource ( DataSource.hs, DataSource.o )
[2 of 5] Compiling Model.Table.Tweet ( Model/Table/Tweet.hs, Model/Table/Tweet.o )
Model/Table/Tweet.hs:12:3-21: Splicing declarations
defineTable "tweet"
======>
data Tweet
= Tweet {id :: !Int64,
accountId :: !Int64,
userId :: !Int64,
@kakkun61
kakkun61 / Path.cs
Last active November 16, 2016 12:36
normalizing path
private static string Normalize(string path)
{
// Example: path = "///1/..//../2/3/"
var trimed = path.Trim(new char[]{ Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); // "1/..//../2//3"
Console.WriteLine("trimed: " + trimed);
var maxDep = 1 + trimed.Count(c => c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar); // 6
Console.WriteLine("maxDep: " + maxDep);
var tmpParentPath = ""; // will be "a/a/a/a/a/a/"
for (var i = 0; i < maxDep; i++)
tmpParentPath = Path.Combine(tmpParentPath, "a");
@kakkun61
kakkun61 / MainNG.purs
Last active August 29, 2015 14:26
How to import effects explicitly in PureScript?
-- This is not OK.
module MainNG where
import Prelude (Unit)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
main :: forall eff. Eff (console :: CONSOLE | eff) Unit
main = log "Hi"
@kakkun61
kakkun61 / gist:1bcd9cc3338c39b90536
Created April 22, 2015 05:46
cabal install cairo -v
Using a sandbox located at ~/Programming/Yi/.cabal-sandbox
/usr/bin/gcc -dumpversion
/usr/local/bin/haddock --version
/usr/local/bin/hpc version
looking for tool hsc2hs near compiler in /usr/local/bin
found hsc2hs in /usr/local/bin/hsc2hs
/usr/local/bin/hsc2hs --version
/usr/local/bin/ghc -c /var/folders/l0/lpt_nm052wx3k1_skr95lksh0000gq/T/56410.c -o /var/folders/l0/lpt_nm052wx3k1_skr95lksh0000gq/T/56410.o
/usr/local/Library/ENV/4.3/ld -x -r /var/folders/l0/lpt_nm052wx3k1_skr95lksh0000gq/T/56410.o -o /var/folders/l0/lpt_nm052wx3k1_skr95lksh0000gq/T/56411.o
/usr/local/bin/pkg-config --version
\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\[\e[36m\]$(__git_ps1 " %s")\[\e[0m\]\n\$
// Rust 0.7
enum Term {
True, False, Zero,
Succ(@Term), Pred(@Term), IsZero(@Term),
If(@Term, @Term, @Term)
}
enum Value {
VTrue, VFalse, NV(@NumberValue)
@kakkun61
kakkun61 / gist:6260948
Created August 18, 2013 10:21
Rust 0.7 compiler does not stop when it compiles this code.
enum A {
A(B)
}
enum B {
B1, B2(B)
}
fn main() {
}
@kakkun61
kakkun61 / gist:5974679
Last active December 19, 2015 15:09
My incomplete answer for http://go-tour-jp.appspot.com/#47
// ! incomplete
package main
import (
"fmt"
"math/cmplx"
)
func Cbrt(x complex128) complex128 {
var z complex128 = 1
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
a, b := 1, 1
return func() int {
tmp := a