Skip to content

Instantly share code, notes, and snippets.

@na-o-ys
na-o-ys / circleci-cache.sh
Created November 17, 2016 08:49
yarn_de_kaiketu
####
# CircleCI のキャッシュを functions/*/node_modules に対して効かせるためのスクリプト.
# CircleCI 上でのみ実行される.
#
# ~/node_modules_cache をキャッシュディレクトリとして,
# 1. キャッシュのリストア
# 2. functions/* で npm install
# 3. キャッシュの保存
# を行う.
####
#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);
# 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
#! /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
)
@na-o-ys
na-o-ys / a_1.rb
Last active October 5, 2016 01:04
だんだん速くなるfizzbuzz
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
@na-o-ys
na-o-ys / anonymous_rec.cpp
Created May 20, 2016 00:41
Anonymous Recursion in C++
// $ 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...);
@na-o-ys
na-o-ys / atcoder.hs
Last active April 22, 2016 09:01
Haskell scraping
import Text.HTML.Scalpel
import Control.Applicative
import Control.Monad
data Submission
= AcSubmission {
createdTime :: String,
title :: String,
user :: String,
language :: String,
@na-o-ys
na-o-ys / gist:e9a1e04718c57d788605
Last active August 29, 2015 14:19
TCO 2015 Round 1A Med
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
class Autogame
@na-o-ys
na-o-ys / gist:b96a9a6569c1f3880c90
Last active August 29, 2015 14:19
TCO 2015 Round 1A Easy
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
using namespace std;
class Similars
{
public:
@na-o-ys
na-o-ys / gist:e2c87202d2acc7584c97
Created March 26, 2015 13:40
SRM 654 Div1 Easy
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
using namespace std;
class SquareScores
{
public: