Skip to content

Instantly share code, notes, and snippets.

akiniwa akiniwa

Block or report user

Report or block akiniwa

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 docker_aerospike.sh
$ docker-machine env
# export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/home/hoge/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval $(docker-machine env)
mkdir volume
cp aerospike.conf volume/aerospike.conf
View docker_init.sh
$ docker-machine create -d virtualbox default
@akiniwa
akiniwa / init.sh
Last active Feb 18, 2017
Aerospike on OSX
View init.sh
# http://www.aerospike.com/docs/operations/install/vagrant/mac
vagrant init aerospike/centos-6.5
vagrant up
vagrant ssh -c "sudo service aerospike status"
# Aerospike Management Console (AMC)
vagrant ssh -c "sudo service amc status"
vagrant ssh -c "sudo grep -i cake /var/log/aerospike/aerospike.log"
vagrant ssh -c "ip addr"|grep 'global eth1'
# >>
# inet 172.28.128.6/24 brd 172.28.128.255 scope global eth1
@akiniwa
akiniwa / lr.py
Last active Jan 26, 2017
Logistic Regression CV
View lr.py
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.cross_validation import train_test_split
from sklearn.metrics import accuracy_score, roc_auc_score
def score(model, X, y):
X_train, X_test, y_train, y_test = train_test_split(X, y)
model.fit(X_train, y_train)
pred_proba = model.predict_proba(X_test)
View gist:32f5041d84042050e6f4bdce0318b26a
多段sshをしたら、commandが実行されない問題。
run('pwd', pty=False)
としたら動いた。
(他のエラーが発生している。)
Python3では、Fabric使わないほうがよさそう。
https://github.com/paramiko/paramiko/issues/789
View gist:8d13c252df54ce7e8098b3f2984967a3
AWS環境で, Fabricの実行結果がhungすることがある。
Fabricは、デフォルトでコマンドの前に、"/bin/bash -l c"とする。
このとき、-lをつけると、実行されずにhungする。
とりあえず、
env.shell = "/bin/bash -c"
とすると実行できる。
http://www.fabfile.org/faq.html#faq-bash
@akiniwa
akiniwa / gist:7707d3b135c43adfa12d85b9b8522c75
Created Nov 11, 2016
Conda入れてからvagrant upでコケる
View gist:7707d3b135c43adfa12d85b9b8522c75
https://github.com/mitchellh/vagrant/issues/7969
sudo rm -rf /opt/vagrant/embedded/bin/curl
@akiniwa
akiniwa / gist:a2848d1a41fdd57daa27550832bb447f
Last active Nov 10, 2016
Error: b'pyenv: pg_config: command not found\n'
View gist:a2848d1a41fdd57daa27550832bb447f
running this command.
$ pip install psycopg2
Collecting psycopg2
Using cached psycopg2-2.6.2.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
View kmeans_elbow.py
# http://stackoverflow.com/questions/6645895/calculating-the-percentage-of-variance-measure-for-k-means
cents = [km.kmeans.cluster_centers_ for km in kms]
D_k = [cdist(rid_brand_pca, cent, 'euclidean') for cent in cents]
# 最も近い中心との距離
dist = [np.min(D,axis=1) for D in D_k]
avgWithinSS = [sum(d)/rid_brand_pca.shape[0] for d in dist]
# elbow curve
View datetime.py
import datetime
from datetime import timedelta
# 現在時刻
now = datetime.datetime.now()
# 文字列へのフォーマット
now.strftime('%Y-%m-%d') # => '2015-09-15'
# 引き算
now - datetime.timedelta(days=2)
You can’t perform that action at this time.