Skip to content

Instantly share code, notes, and snippets.

View t11a's full-sized avatar

t11a t11a

  • Tokyo, Japan
View GitHub Profile
@t11a
t11a / custom_policy_request.rb
Created June 13, 2015 01:58
CloudFront - Signed Cookies Using a Custom Policy
#!/usr/bin/env ruby
require 'json'
require 'base64'
require 'openssl'
### CloudFront Key Pair
KEY_PAIR_ID = "XXXXX"
PRIVATE_KEY = "pk-XXXXX.pem"
### Destination URL and RESOURCE for Policy
@t11a
t11a / custom_policy_request.rb
Last active July 25, 2017 06:07
CloudFront - Signed Cookies Using a Custom Policy
#!/usr/bin/env ruby
require 'json'
### CloudFront Key Pair
KEY_PAIR_ID = "XXXXX"
PRIVATE_KEY = "pk-XXXXX.pem"
### Destination URL and RESOURCE for Policy
DST_URL = "https://xxxx.cloudfront.net/index.html"
RESOURCE = "http*://xxxx.cloudfront.net/index.html"
@t11a
t11a / .vimrc
Created June 2, 2014 13:19
vimrc sample
"=============================================================================
" vimrc: vimrcはシステム管理者が必要最小限の設定をしておくものであり、
" 個人用の設定は_vimrc(.vimrc)で行う。
" 従ってvimrcは基本的に変更しない。
" 本設定ファイルでは主に文字コードの自動認識のみ行っている。
"=============================================================================
set nocompatible
"----------------------------------------
"文字コードの自動認識
"----------------------------------------
@t11a
t11a / Levenshtein_distance.cpp
Last active August 29, 2015 13:57
Levenshtein distance
#include <iostream>
#include <string>
#define FOR(i,m,n) for (int i=(m); i<(int)(n) ;i++)
int main() {
string x = "google";
string y = "gooogle";
int size_x = x.length();
class ColorfulRoad {
private:
int colorid(char ch) {
switch(ch) {
case 'R': return 0;
case 'G': return 1;
case 'B': return 2;
default: return -1;
}
}
@t11a
t11a / 5_min_interval.sql
Created January 17, 2014 16:53
5分おきの頻度を出力するクエリ。
select FROM_UNIXTIME(TRUNCATE(UNIX_TIMESTAMP(addtime(created_at,'09:00:00'))/300,0)*300) as _time, count(*)
from sales
where
created_at between '2014-01-17 15:00:00' and '2014-01-18 14:59:59'
GROUP BY _time;
class StackWithTwoQueues
def initialize
@q1 = []
@q2 = []
end
def push(item)
@q1 << item
end
class StackWithSingleQueue
def initialize
@queue = []
end
def push(item)
@queue << item
end
class QueueWithTwoStacks
def initialize
@s1 = []
@s2 = []
end
def enqueue(item)
@s1 << item
end
class QueueWithSingleStack
def initialize
@stack = []
end
def enqueue(item)
@stack << item
end