Skip to content

Instantly share code, notes, and snippets.

@aamine
aamine / collect_partial_path.sql
Last active August 29, 2015 14:19
セッショナイズされたアクセスログから部分パスの出現回数を集計する
create table sessionized_access_log
( session_id int
, session_seq int
, log_time timestamp
, pv_signature text -- 1アクセスを表現する値。pathとか
);
-- 長さ3の部分パスの出現回数を集計(ウィンドウ関数使わない編)
-- partitionから任意長のウィンドウフレームを自力で切り出すためにも使えるぞ!
select
@aamine
aamine / Redshift_uuid.sql
Last active October 6, 2015 08:20
RedshiftでUUID v4生成
select
id
, replicate('0', 4 - len(w1)) || w1
|| replicate('0', 4 - len(w2)) || w2
|| '-'
|| replicate('0', 4 - len(w3)) || w3
|| '-'
|| replicate('0', 4 - len(w4)) || w4
|| '-'
|| replicate('0', 4 - len(w5)) || w5
@aamine
aamine / MigrateSubversionToGitHub
Last active March 3, 2021 12:49
How to migrate Subversion repository into GitHub with all history, all branches, all tags, using standard layout and temporary bare git repository.
1. Write Authors.txt, which maps Subversion user ID to Git user.
For example:
taro = Taro Yamada <taro@example.com>
2. Create temporary, local, bare Git repository and map Subversion branches and tags.
$ git --bare init proj.git
$ cd proj.git
@aamine
aamine / HorizVert.md
Last active August 16, 2023 03:46
RDBの縦持ちテーブルと横持ちテーブル、およびその変換について

テーブルの縦持ち横持ちについて

横持ちテーブルと縦持ちテーブル

横持ちはいわゆる「普通の」データの持ちかたのこと。 例えばレコードごとにa, b, c, dの4つの属性を持つ テーブルを作る場合、次のようなテーブルが横持ちテーブルである。