Skip to content

Instantly share code, notes, and snippets.

View matsubara0507's full-sized avatar
:bowtie:
Working with Ruby

MATSUBARA Nobutada matsubara0507

:bowtie:
Working with Ruby
View GitHub Profile
@matsubara0507
matsubara0507 / _brainfuck.hs
Last active June 14, 2018 10:49
Brainf*ck in Haskell
import Data.Char (chr)
brainfuck :: String -> IO String
brainfuck cmds = loop ([], (return 0), (repeat $ return 0)) 0 []
where
max = length cmds
loop :: ([IO Int], IO Int, [IO Int]) -> Int -> [IO Char] -> IO String
loop (xs,y,zs) index outs
| index == max = sequence (reverse outs)
| otherwise = cnd (cmds !! index)
import Control.Applicative (liftA2)
import Data.List (unfoldr)
import Data.Tuple (swap)
solve :: Int -> [Int]
solve = fmap (radix10 3 . uncurry gen) . filter (uncurry check)
. zip [(2,0),(1,0),(0,1),(0,2)] . repeat . radix 3
check :: (Int, Int) -> [Int] -> Bool
check (x,y) = liftA2 (&&) (not . null) ((== x) . head) . dropWhile (== y) . reverse
@matsubara0507
matsubara0507 / graph-fluent.java
Last active June 27, 2017 16:10
ジェネリクス勉強会(https://connpass.com/event/56773/) の Haochen の発表ネタの実装をしてみた(合ってないかも)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.function.Consumer;
public class Main {
public static void main(String[] args) throws Exception {
System.out.println("hello!!!");
CanvasObj obj = Graphics.builder()
.newGroup()
def radix(d: Int, n: Int): List[Int] = {
def loop(x: Int): List[Int] =
if (x == 0) Nil else { val a = x / d; val b = x % d; b :: loop(a) }
loop(n).reverse
}
def isPalin(ns: List[Int]): Boolean = ns == ns.reverse
def isMultiPalin(n: Int): Boolean =
(2 to n).toList.map(radix(_, n)).count(xs => xs.length > 2 && isPalin(xs)) >= 2
import Data.List (unfoldr)
import Data.Tuple (swap)
solve :: Int -> Int
solve n = head $ filter isMultiPalidromic [n..]
isMultiPalidromic :: Int -> Bool
isMultiPalidromic n = countTwo . filter isPalidromic' $ map (`convertRadix` n) [2..n]
isPalidromic :: [Int] -> Bool
module Main where
import Data.Maybe (isJust)
import Text.Read (readMaybe)
import Control.Monad (join)
main :: IO ()
main = do
let initState = (Nothing, GradesCounter 0 0 0 0)
_ <- doWhileM updateGrade (isJust . fst) initState
init by gas-hub, just delete this file.
@matsubara0507
matsubara0507 / hunter_ss.js
Last active May 1, 2017 04:41
スプレッドシート用の huner スクリプト(ランダムな動物の名前にカーソルを合わせる)
function hunt() {
var prop = PropertiesService.getScriptProperties().getProperties();
/* Load Spread Sheet */
var sheet = SpreadsheetApp.openById(prop.SPREAD_SHEET_ID).getSheetByName(prop.SHEET_NAME);
var names = sheet.getRange(1, 1, prop.ROW_NUM, 2).getValues();
Logger.log(names);
var unuseNames = names.filter(
function(row){
@matsubara0507
matsubara0507 / hunter.gs
Created April 29, 2017 14:22
動物の名前を返す Slack Bot
function doPost(e) {
var prop = PropertiesService.getScriptProperties().getProperties();
const BOT_NAME = 'hunter';
const BOT_ICON = 'http://drive.google.com/uc?export=view&id=' + prop.ICON_ID;
if (prop.VERIFY_TOKEN != e.parameter.token) {
throw new Error("invalid token.");
}
@matsubara0507
matsubara0507 / comparison_of_chat_tools.md
Last active April 16, 2017 07:51
Comparison of Chat Tools

チャットツールの比較

現状 slack (free) を使ってるけど、他にいいの無いかなぁ...

feture slack(free) Discord(free)
過去ログ 10000件まで 無制限
ファイルのアップロード 全部で5GBまで 一回のアップロードが8MB
カスタム絵文字 使える 最大50個
ユーザーアカウント チームごとに別々 グローバルなアカウントがある