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 / 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 / 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){
init by gas-hub, just delete this file.
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
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
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
@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()
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 / int_sqrt_min.py
Created November 6, 2017 13:53
1から1000までの整数に対して最小連続平方根を求めそれが10以下であればその数と最小連続平方根を出力するスクリプト
# coding: utf-8
import math
def is_int(n):
return n % 1 == 0
def int_sqrt(n):
a = math.sqrt(n)
if is_int(a):
return int(a)
@matsubara0507
matsubara0507 / app.elm
Created December 26, 2017 13:08
elm-nankatsukuro#4
module Main exposing (..)
import Html exposing (Html, a, div, span, text, textarea)
import Html.Attributes exposing (class, readonly, type_, value, wrap)
import Html.Events exposing (onClick)
import List.Extra as List
type alias Key =
{ view : String