Skip to content

Instantly share code, notes, and snippets.

View trknhr's full-sized avatar
🎈
Focusing

Teruo Kunihiro trknhr

🎈
Focusing
  • Nulab.inc
  • Fukuoka, Japan
View GitHub Profile
'use strict';
(function(global){
function isFunction(item) {
return typeof item === 'function';
}
function extend(target, options){
var copy;
if(typeof target !== 'object' && !isFunction(target)){
target = {};
}
object FizzBuzz{
def main(args: Array[String])={
fizz_buzz(20)
}
def fizz_buzz(n: Int) = {
val threes = Stream.continually(List(None, None, Some("Fizz")).toStream).flatten
val fives = Stream.continually(List(None, None, None, None, Some("Buzz")).toStream).flatten
val hoge = threes.zip(fives).zip(from(1)).take(n).map{a =>
a._1 match{
case (None, None) => a._2
tap 'caskroom/cask'
tap 'caskroom/versions'
tap 'homebrew/bundle'
tap 'homebrew/core'
tap 'homebrew/versions'
cask 'java'
brew 'ant'
brew 'autoconf'
brew 'openssl'
brew 'jpeg'
defmodule MyList do
def len([]), do: 0
def len([head|tail]), do: 1 + len(tail)
end
defmodule MyList do
def mapsum(array, func), do: Enum.reduce(array, 0, &(&2 + func.(&1)))
def max(array), do: Enum.reduce(array, nil, fn(v, arr) ->
case arr do
nil -> v
x when v <= x -> x
x when v > x -> v
end
defmodule Caeser do
def caesar([], n), do: []
def caesar([head | tail], n) when head + n <= ?z, do: [head + n | caesar(tail, n)]
def caesar([head | tail], n), do: [head + n - (?z - ?a + 1) | caesar(tail, n)]
end
defmodule OpenBrace do
def regex(str) do
regex = ~r/\{.*\}/
match_strs = Regex.scan(regex, str)
remain_strs = Regex.split(regex, str)
ary = Enum.map(match_strs, fn(x) ->
match_str = to_string(x)
match_array = String.split(match_str, ",")
export abstract class Either<T, U>{
abstract isRight(): boolean;
abstract fold<X>(l: (t: T) => X, r: (u: U) => X): X;
isLeft(): boolean{
return !this.isRight();
}
map<B>(f: (U) => B): Either<T, B>{
return this.fold(
const STR_LEN = 80
const SUSHI_INTERVAL =10
let cnt = 0;
function sushiDraw(){
const sa = new Array(STR_LEN).fill(' ')
for(let i = 0; i < STR_LEN; i += SUSHI_INTERVAL){
const sushiIndex = sa.length - 1 - (cnt + i) % sa.length
sa.splice(sushiIndex, 1, '🍣')
}
@trknhr
trknhr / index.html
Created December 1, 2016 15:00
PPAP SCSS
<div class="ppap">
</div>