Skip to content

Instantly share code, notes, and snippets.

takuma-saito

Block or report user

Report or block takuma-saito

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View download.sh
#!/bin/bash -xe
[[ $# < 2 ]] && echo "$0 <projectname> <commit_id> <bucketname>" && exit 1
name=$1
commit_id=$2
bucketname=$3
[[ -z $ENV_DEFAULT_REGION ]] && echo "Please set \$ENV_DEFAULT_REGION" && exit 1
[[ -z $ENV_SECRET_ACCESS_KEY ]] && echo "Please set \$ENV_SECRET_ACCESS_KEY" && exit 1
[[ -z $ENV_ACCESS_KEY_ID ]] && echo "Please set \$ENV_ACCESS_KEY_ID" && exit 1
cat > ./aws <<EOF
[netlify]
@takuma-saito
takuma-saito / Pipfile
Last active Jun 24, 2019
show_diff.sh
View Pipfile
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
awscli = "*"
View primes.rs
fn primes(limit: i32) -> Vec<i32> {
let mut items = vec![true; (limit + 1) as usize];
let mut primes = Vec::<i32>::new();
let up = (limit as f32).sqrt() as i32 + 1;
let mut i = 2;
items[0] = false;
items[1] = false;
while i <= up {
let mut v = 2;
if !items[i as usize] {
View suffix-automan.rb
class Node
attr_accessor :edges, :terminal, :suffix_link, :id
def initialize
@edges = {}
@done = false
@suffix_link = nil
@id = nil
end
def [](char)
View level5-death.rb
INF = 2 ** 20
def turn(k, counter = 0)
@dp ||= {}
return nil if k < 1 || k > 255 || counter > 100
return @dp[k] if @dp[k]
return @dp[k] = {count: 1, prev: k, action: :D, current: k} if (k % 5) === 0
t1 = nil
t2 = turn(k/2, counter + 1)
t3 = turn(k + 10, counter + 1)
t4 = turn(k + 20, counter + 1)
@takuma-saito
takuma-saito / naive-suffix-tree.rb
Last active Mar 23, 2019
naive-suffix-tree.rb
View naive-suffix-tree.rb
class Node
attr_accessor :edges, :link
def initialize(link = nil, edges = {})
@link = nil
@edges = edges
end
end
class Edge
attr_reader :l, :r, :node, :text
def initialize(l, r, node, text)
View stack-calculator.rb
ORDER = {
'$' => 1,
'-' => 2,
'+' => 3,
'*' => 4,
'/' => 5,
}
OPERATOR = {
'-' => -> (a, b) {a - b},
View algo-1.rb
# a_1, a_2, ..., a_n に対して, それぞれ 0 <= a_i <= c_i という成約を満たしつつ
# \sum_{i = 1}^n a_i = N を満たす組み合わせをすべてリストアップする
def solve(n, sum, d, cap)
c = cap.pop
if cap.empty?
yield [sum]
cap.push c
return
end
@takuma-saito
takuma-saito / hitorini-sitekure-problem-7-1.rb
Last active Mar 3, 2019
hitorini-sitekure-problem-7-1.rb
View hitorini-sitekure-problem-7-1.rb
# coding: utf-8
def dfs(board, i, j)
return if (i <= 0 || i > LEN) ||
(j <= 0 || j > LEN) ||
board[i][j] <= 0 || board[i][j] > M
board[i][j] += M
[[i - 1, j], [i + 1, j], [i, j - 1], [i, j + 1]].each do |pos|
l, m = pos
v = board[l][m]
You can’t perform that action at this time.