Skip to content

Instantly share code, notes, and snippets.

@akihiro4chawon
akihiro4chawon / gist:f38603e39f4651f52ab5
Created November 30, 2014 07:27
久しぶりにリハビリ
module Main where
import Data.Array
-- mod m としたフィボナッチ数列 (繰り返しとなる時点で打ち切り)
fibMod :: Int -> [Int]
fibMod m = 0 : fibMod' 1 1
where
fibMod' 0 1 = []
fibMod' x y = x : fibMod' y (mod (x + y) m)
@akihiro4chawon
akihiro4chawon / Main.hs
Created December 3, 2012 08:12
BrainFuck Arrow
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
module Main where
import Control.Applicative
import Control.Arrow
import Control.Monad (void)
import Data.Attoparsec.ByteString.Char8
import qualified Data.ByteString.Char8 as B
@akihiro4chawon
akihiro4chawon / Main.scala
Created July 3, 2012 04:50
[ネタ] Scala 99 でリバビリ中
// scala99 http://aperiodic.net/phil/scala/s-99/
object Scala99 {
import Function.{const, uncurried}
//P01 (*) Find the last element of a list.
// Example:
//
// scala> last(List(1, 1, 2, 3, 5, 8))
// res0: Int = 8
@akihiro4chawon
akihiro4chawon / Main.hs
Created July 2, 2012 09:46
[ネタ] TransformListComp (generalized list comprehension) の勉強とか
{-# LANGUAGE ViewPatterns, TransformListComp #-}
-- 元ネタはいつもどおり route150 の日記
-- <http://d.hatena.ne.jp/route150/20120622/1340338820>
import GHC.Exts
import Control.Arrow
import Data.List
import Test.QuickCheck
-- GHC拡張(TransformListComp)使うと楽だったりする...
@akihiro4chawon
akihiro4chawon / ParserMain.scala
Created July 2, 2012 04:55
[ネタ] どう書くポーカーのScala 版
// solution to http://qiita.com/items/cbc3af152ee3f50a822f
// using parser combinators
import scala.util.parsing.combinator.RegexParsers
case class Card(suit: String, rank: String)
trait CardsParser extends RegexParsers {
def cards = repN(5, card)
def card: Parser[Card] = (suit ~ rank) ^^ {case s~r => Card(s, r)}
@akihiro4chawon
akihiro4chawon / Trie.scala
Created June 28, 2012 08:19
[ネタ] Trie を実装してみる
// mutable な trie と immutable な trie
// 久しぶりに scala 書いてみたらダーティ過ぎてワロタ。。。
// 仕様は http://d.hatena.ne.jp/route150/20120624/1340542890
// 破壊的操作はいいぞ(以下略
package trie {
// trie base
abstract class Trie[A] {
type ChildrenT <: collection.Map[A, Trie[A]]
val children: ChildrenT
@akihiro4chawon
akihiro4chawon / make_bsort_topology.m
Created May 14, 2012 08:29
Simulink でソート(するブロックの自動生成をMATLABで)をやってみた
function [ output_args ] = make_bsort( input_args )
%BSORT2 この関数の概要をここに記述
% 詳細説明をここに記述
global stack
% 整列対象の要素数
n_sort = 6;
stack = [];
bitonic_sort(1, n_sort, true);
// Spring Roo 1.2.1.RELEASE [rev 6eae723] log opened at 2012-02-28 19:26:39
project --topLevelPackage com.github.akihiro4chawon.singleroo --projectName spring-roo-exam-single --java 6
hint
jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
entity jpa --class ~.domain.Person --sequenceName PERSON_SEQ
field string --notNull --fieldName firstName --sizeMin 3 --sizeMax 30
field string --notNull --fieldName lastName --sizeMin 3 --sizeMax 30
test integration --entity ~.domain.Person
web mvc setup
web mvc all --package ~.web
@akihiro4chawon
akihiro4chawon / getTerminals.hs
Created February 20, 2012 10:45 — forked from aya-eiya/getTerminals.hs
指定したディレクトリを再帰的に探索して末端のパスのリストを返します。#haskell
module Main where
import Control.Monad
import Control.Monad.Trans
import Control.Monad.Trans.List
import System.Directory
getAllFilesIn :: FilePath -> IO [FilePath]
getAllFilesIn path = runListT $ getAllFilesIn' path
where
@akihiro4chawon
akihiro4chawon / FileExplorerComposer.java
Created February 15, 2012 12:41
ZK 6.0 FileExplorer Sample (in Scala/Java)
package zkthisisanexam.fileexplorer;
import java.io.File;
import java.io.FileFilter;
import java.text.SimpleDateFormat;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;