Skip to content

Instantly share code, notes, and snippets.

View techno-tanoC's full-sized avatar
💻

techno-tanoC techno-tanoC

💻
View GitHub Profile
@techno-tanoC
techno-tanoC / blood.rb
Last active April 7, 2016 13:42
簡単な世代間血液型割合の変化のシミュレート。
class Blood
def initialize f, g
@blood = [f, g].sort
end
def type
case @blood
when %w(A A) then "A"
when %w(A O) then "A"
when %w(B B) then "B"
inp = <<INP
A:c,b,a
B:a,b,d
C:a,c,b
D:d,a,c
a:A,C,D
b:D,A,B
c:B,A,C
d:D,C,A
INP
@techno-tanoC
techno-tanoC / get_matcher.rb
Created November 14, 2014 05:19
get_matcher
# coding: utf-8
require 'spec_helper'
RSpec::Matchers.define :get do |first|
match do |actual|
actual.public_send(@second, *@args) == first
end
chain :by_call do |second, *args|
@techno-tanoC
techno-tanoC / extractor.rb
Last active August 29, 2015 14:10
extractor.rb
module Extractable
module Initializer
def initialize *args
self.class.class_eval do
define_method(:extract) do |&block|
if block
block.(*args)
else
args
end
@techno-tanoC
techno-tanoC / mod7.hs
Created January 14, 2015 10:08
mod7占い (paizaランク S 相当)
import Control.Monad
import Control.Applicative
import Data.List
type Triple = (Int, Int, Int)
data Pat = Pat {
triple :: Triple,
mods :: [Int]
} deriving (Show)
@techno-tanoC
techno-tanoC / hackason4_3.hs
Created January 15, 2015 16:21
マンガ版「エンジニアでも恋がしたい!」〜転職初日にぶつかった女の子が同僚だった件〜|paizaオンラインハッカソン4 Lite https://paiza.jp/poh/enkoi-ending/fe7cbf79
import Control.Applicative
import Control.Monad
import Data.IntMap
diffRange :: IntMap Int -> Int -> Int -> Int
diffRange xs t d = l - h
where
h = xs ! (d)
l = xs ! (d + t)
@techno-tanoC
techno-tanoC / stm.hs
Last active August 29, 2015 14:20
Scotty+STMで状態を持ったサーバ
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Concurrent
import Control.Concurrent.STM
import Control.Monad.IO.Class
import Data.Text.Lazy
import Web.Scotty
import Data.Aeson.Types
@techno-tanoC
techno-tanoC / set.hs
Last active March 20, 2019 08:10
集合論のあれ
data Fruit = Apple | Lemon | Banana
data Beverage = Coffee | Tea | Beer
data Temperature = Hot | Cool
-{
Food = { Food, Lemon, Curry }
Flavor = { Sweet, Sour, Spicy }
@techno-tanoC
techno-tanoC / stm-test.hs
Last active September 29, 2015 01:04
performance of stm
module Main where
import Control.Monad
import Control.Concurrent
import Control.Concurrent.STM
-- STM (TVar [STM (TVar Int)])
type Data = TVar Int
type DataList = TVar [STM Data]
@techno-tanoC
techno-tanoC / fcitx
Last active November 15, 2015 14:37
/etc/X11/xinit/xinput.d/fcitx
XIM=fcitx
XIM_PROGRAM=/usr/bin/fcitx
XIM_ARGS=""
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
DEPENDS="fcitx"