Skip to content

Instantly share code, notes, and snippets.

View tiqwab's full-sized avatar

Naohisa Murakami tiqwab

View GitHub Profile
@tiqwab
tiqwab / build.gradle
Created April 14, 2016 14:10
Example of build.gradle
subprojects {
apply plugin: 'eclipse'
apply plugin: 'java'
// 全ソースがUTF-8であることを指定する、
// この記述であればsourceSetが増えても対応可能。
def defaultEncoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.encoding = defaultEncoding
}
subprojects {
apply plugin: 'eclipse'
apply plugin: 'java'
// 全ソースがUTF-8であることを指定する、
// この記述であればsourceSetが増えても対応可能。
def defaultEncoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.encoding = defaultEncoding
}
@tiqwab
tiqwab / FileUtils.java
Created May 15, 2016 14:36
List files with antInclude
package org.tiqwab.util;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.apache.commons.io.FilenameUtils;
public class FileUtils {
const dataSet = [
[ 5, 20 ],
[ 480, 90 ],
[ 250, 50 ],
[ 100, 33 ],
[ 330, 95 ],
[ 410, 12 ],
[ 475, 44 ],
[ 25, 67 ],
[ 85, 21 ],
const dataSet = [
{ timepoint: '2016-06-08T12:00:00Z', temperature: 15.2 },
{ timepoint: '2016-06-08T13:00:00Z', temperature: 16.1 },
{ timepoint: '2016-06-08T14:00:00Z', temperature: 19.2 },
{ timepoint: '2016-06-08T15:00:00Z', temperature: 21.5 },
{ timepoint: '2016-06-08T16:00:00Z', temperature: 12.8 },
{ timepoint: '2016-06-08T17:00:00Z', temperature: 15.3 },
{ timepoint: '2016-06-08T18:00:00Z', temperature: 15.0 },
{ timepoint: '2016-06-08T19:00:00Z', temperature: 15.1 },
{ timepoint: '2016-06-08T20:00:00Z', temperature: 14.1 },
@tiqwab
tiqwab / State.hs
Last active August 24, 2016 13:38
Stateモナドの整理
import System.Random
import Control.Monad.State hiding (modify')
{-
newtype State s a = State { runState :: s -> (a, s) }
instance Monad (State s) where
return x = State $ \s -> (x, s)
(State h) >>= f = State $ \s -> let (v, newState) = h s
(State g) = f v
@tiqwab
tiqwab / Reader.hs
Last active July 25, 2016 14:25
Readerモナドの整理
import Control.Monad.Reader
-- do構文でReaderモナド
-- runReader addStuffD 3 = 19
addStuffD :: Reader Int Int
addStuffD = do
x <- reader (*2)
y <- reader (+10)
return (x+y)
@tiqwab
tiqwab / Writer.hs
Last active February 9, 2019 16:47
Writerモナドの整理
import Control.Monad.Writer
-- do構文でWriter
logCalcD :: Writer [String] Int
logCalcD = do
tell ["Process start"]
x <- writer (1, ["Initial value: " ++ " 1"])
y <- writer (x * 2, ["Multiply by two"])
tell ["Process end"]
return y
@tiqwab
tiqwab / Sudoku.hs
Last active August 6, 2016 01:26
数独Solver
import Data.List
import Control.Monad.Reader
import Control.Monad.Writer
import Data.Maybe
-- Pair of row and column
type Position = (Int, Int)
-- Pair of Position and possible numbers
type Cell = (Position, [Int])
-- List of Cell
import Text.Parsec
import Text.ParserCombinators.Parsec hiding (try)
{-
Basics of `Parsec` package.
-}
{-
data ParsecT s u m a
s: stream type