try:
except (ConnectionError, ChunkedEncodingError, TooManyRedirects, NewConnectionError) as e:
logging.warn("Skip URL {} Reason: {}".format(url, e))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script compacts daily based csv files to monthly based parquet file. | |
# The CSV files should be named like "YYYY-MM-DD.csv" format. | |
# | |
# このスクリプトは日付毎のcsvファイルを月毎のparquetファイルに変換します。 | |
# CSVファイルの名前は"YYYY-MM-DD.csv"の形式にしてください。 | |
# | |
import pandas as pd | |
import numpy as np | |
import pyarrow as pa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import MeCab | |
from collections import Counter | |
from sklearn.feature_extraction.text import CountVectorizer | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
m = MeCab.Tagger("-Ochasen") | |
m2 = MeCab.Tagger("-Owakati") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROFILE=your_profile | |
INSTANCE_NAME=your_instance_name | |
SSH_KEYPATH=your_ssh_key_path | |
PUBLIC_HOSTNAME=`aws --profile ${PROFILE} ec2 describe-instances | jq -r ".Reservations[] | select(.Instances[0].Tags[].Value == \"${INSTANCE_NAME}\") | .Instances[0] | .PublicDnsName"` | |
echo "establish SOCKS proxy" | |
echo "ssh -i ${SSH_KEYPATH} -D 8157 -q ec2-user@${PUBLIC_HOSTNAME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROFILE=your_profile | |
INSTANCE_NAME=your_instance_name | |
aws --profile ${PROFILE} ec2 describe-instances | jq -r ".Reservations[] | select(.Instances[0].Tags[].Value == \"${INSTANCE_NAME}\") | .Instances[0] | {PrivateDnsName: .PrivateDnsName, PrivateIpAddress: .PrivateIpAddress, PublicDnsName: .PublicDnsName, PublicIpAddress: .PublicIpAddress}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dirs_compressor.py | |
# | |
# Usage: | |
# $ python dirs_compressor.py targed_dir | |
# | |
import sys | |
import os | |
import os.path | |
import logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COLS=100000 | |
with open("/tmp/create_table_with_many_columns.hql", "w") as f: | |
f.write("CREATE TABLE many_cols_tbl (\n") | |
for i in xrange(COLS): | |
f.write("id%d INT,\n" % (i,)) | |
f.write("last_id INT);\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create Ansible directory layaout based on Ansible Documentation http://docs.ansible.com/ansible/playbooks_best_practices.html | |
# | |
# inventory file for production servers | |
touch production | |
# inventory file for staging environment | |
touch staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import random | |
from wsgiref import simple_server | |
誰 = ['太郎', '二郎', '花子'] | |
どこ = ['東京', '大阪', '名古屋'] | |
どうした = ['泳いだ', '走った', '仕事した'] | |
def pick(l): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
# | |
# hipchatdump2csv.py | |
# | |
# convert hipchat message logs from json to csv. | |
# csv format: | |
# from.name, from.user_id, date, message | |
# | |
# usage: python convert.py | |
# |