Skip to content

Instantly share code, notes, and snippets.

View snaga's full-sized avatar

Satoshi Nagayasu snaga

View GitHub Profile
@snaga
snaga / PuLP.ipynb
Last active March 4, 2018 07:11
線形計画をPythonで解いてみる
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/sh
cd `dirname $0`
pwd
PGHOME=/usr/pgsql-9.6
export PGHOME
function git_checkout()
{
@snaga
snaga / pd.sh
Created October 23, 2016 11:11
pd.sh
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $0 <python file>"
exit 0
fi
M=`echo $1 | sed 's/.py//'`
echo $M
@snaga
snaga / tsp_to_kml.py
Created September 17, 2016 09:14
tsp_to_kml.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import codecs
import psycopg2
import re
import sys
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
@snaga
snaga / kml_to_sql.py
Created September 17, 2016 09:13
kml_to_sql.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import codecs
import re
import sys
from pykml import parser
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
@snaga
snaga / NDL防災津波噴火データ集計.csv
Created July 31, 2016 12:57
NDL防災津波噴火データ集計.csv
We can't make this file beautiful and searchable because it's too large.
collectedYear,facet,keyword,mcode,n_docs,mname
2010,タイトル,防災,2000,20747,青森県
2010,タイトル,防災,15000,17671,新潟県
2010,タイトル,防災,27000,9956,大阪府
2010,タイトル,防災,22130,1845,静岡県 浜松市
2010,タイトル,防災,32000,1752,島根県
2010,タイトル,防災,28000,1599,兵庫県
2010,タイトル,防災,12000,1598,千葉県
2010,タイトル,防災,37000,1516,香川県
2010,タイトル,防災,13000,1119,東京都
@snaga
snaga / foo.sql
Created July 6, 2016 12:13
parallel safe/unsafe functions
select version();
create table t1 as
select generate_series(1,10000000) c1;
set force_parallel_mode = true;
set max_parallel_workers_per_gather = 4;
create or replace function f1_safe(c int8)
returns int8
@snaga
snaga / gist:362a965683fb2581bc693991b1fcf721
Created July 6, 2016 12:12
parallel safe/unsafe functions
testdb=# select version();
version
-------------------------------------------------------------------------------------------------------------
PostgreSQL 9.6beta2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17), 64-bit
(1 row)
testdb=# create table t1 as
testdb-# select generate_series(1,10000000) c1;
SELECT 10000000
testdb=# set force_parallel_mode = true;
@snaga
snaga / build_madlib.sh
Last active April 10, 2016 03:47
build_madlib.sh
#!/bin/sh
rm -rf incubator-madlib
git clone https://github.com/snaga/incubator-madlib.git
cd incubator-madlib
git checkout v1.9
git log -1
function _build()
{
@snaga
snaga / md2blog.py
Created January 10, 2016 10:02
md2blog.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
out = ""
in_pre = False
in_ul = False