This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { curry } from "ramda"; | |
export const throwIf = curry( | |
(predicate: (_: any) => boolean, error: Error, value: any) => { | |
if (predicate(value)) { | |
throw error; | |
} else { | |
return value; | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 文字列の行頭にあるスペースのサイズを取得する | |
const getSpaceLengthAtBeginningOfLine = (str: string) => | |
str.match(/^(\s*)/)![1].length; | |
// 末尾の空行を削除する | |
const trimTailSpaces = (str: string) => str.match(/(.*?)(\s*)$/)![1]; | |
// Number の配列から最小の値を取りだす | |
// see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min | |
const getMinOfArray = (arr: number[]) => Math.min.apply(null, arr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
all, | |
curry, | |
equals, | |
isNil, | |
mapObjIndexed, | |
pipe, | |
propSatisfies, | |
values, | |
} from "ramda"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
# block/proc/lambda のおさらい① | |
# | |
# - block とは | |
# メソッドに「処理」を渡したい時に使うもの | |
def hoge(&block) | |
block("World") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn fibonacchi | |
[n] | |
(condp = n | |
0 1 | |
1 1 | |
(+ (fibonacchi (- n 1)) (fibonacchi (- n 2))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn fizzbuzz | |
[n] | |
(cond | |
(and (= (rem n 3) 0) (= (rem n 5) 0)) "fizzbuzz" | |
(= (rem n 5) 0) "buzz" | |
(= (rem n 3) 0) "fizz" | |
:else (.toString n))) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuadraticEquation | |
attr_reader :x | |
def initialize(a:, b:, c:) | |
@a = a.to_f | |
@b = b.to_f | |
@c = c.to_f | |
@x = result | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qsort [] = [] | |
qsort (p:xs) = qsort lt ++ [p] ++ qsort gteq | |
where lt = [x | x <- xs, x < p] | |
gteq = [x | x <- xs, x >= p] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'streamio-ffmpeg' | |
require 'yaml' | |
INPUT_PATH = "~/変換元ディレクトリ" | |
OUTPUT_PATH = "~/変換後のファイルを保存するディレクトリ" | |
# YAMLから変換する曲のアーティスト一覧を取得 | |
# example: artists.yml | |
# - Bireli\ Lagrene | |
# - John\ Pizzarreli |