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 Text.HTML.Scalpel | |
import Control.Applicative | |
import Control.Monad | |
data Submission | |
= AcSubmission { | |
createdTime :: String, | |
title :: String, | |
user :: String, | |
language :: String, |
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
// $ g++-4.9 -std=c++1y anonymous_rec.cpp | |
#include <iostream> | |
template<typename Func> | |
struct fixed { | |
Func f; | |
template<typename... Args> | |
auto operator()(Args... args) { | |
return f(fix(f), args...); |
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
max = ARGV[0].to_i | |
1.upto(max) do |i| | |
if i % 15 == 0 | |
puts "FizzBuzz" | |
elsif i % 3 == 0 | |
puts "Fizz" | |
elsif i % 5 == 0 | |
puts "Buzz" | |
else |
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
#! /usr/bin/env ruby | |
require 'pp' | |
source = $*[0] | |
iseq = File.basename(source, ".*") + ".iseq.rb" | |
open(iseq, 'w').puts( | |
"@iseq = " + | |
RubyVM::InstructionSequence.compile_file(source).to_a.pretty_inspect | |
) |
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
# value = object | array | string | number | true | false | null | |
# object = { string : value \{ , string : value \} } | |
# array = [ value \{ , value \} ] | |
# | |
# string = " .* " | |
# number = -?\d+(\.\d+)?([eE][-+]?\d+) -- "10", "-3.1", "0.34E-6" | |
# true = true | |
# false = false | |
# null = null |
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
#include <bits/stdc++.h> | |
using namespace std; | |
random_device rnd; | |
mt19937 mt(rnd()); | |
void print_array(int* arr, int len) { | |
cout << *arr; | |
while (--len) cout << ", " << *(++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
#### | |
# CircleCI のキャッシュを functions/*/node_modules に対して効かせるためのスクリプト. | |
# CircleCI 上でのみ実行される. | |
# | |
# ~/node_modules_cache をキャッシュディレクトリとして, | |
# 1. キャッシュのリストア | |
# 2. functions/* で npm install | |
# 3. キャッシュの保存 | |
# を行う. | |
#### |
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
// compile: tsc src.ts --lib es2017,dom -t es2015 | |
// 1. Async/Await | |
async function concatPromises(): Promise<string> { | |
const v0 = getValue() | |
const v1 = await getPromise1() | |
const v2 = await getPromise2() | |
return v0 + v1 + v2 | |
} | |
concatPromises().then(console.log) //=> Value: helloworld |
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
type T = 1 | |
type F = 0 | |
function nand(v1: T, v2: T): F; | |
function nand(v1: T, v2: F): T; | |
function nand(v1: F, v2: T): T; | |
function nand(v1: F, v2: F): T; | |
function nand(v1, v2) { | |
return 0 // dummy | |
} |
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
type Zero = 0 | |
type Num = Zero | { 0: Num } | |
const any: any = null | |
function succ<T>(v: T): { 0: T } { | |
return any | |
} | |
type FizzNum = Zero | {0:{0:{0: FizzNum }}} |