Skip to content

Instantly share code, notes, and snippets.

View nqbao's full-sized avatar
Make Stuff Works

Bao Nguyen nqbao

Make Stuff Works
View GitHub Profile
@nqbao
nqbao / install.sh
Last active February 15, 2018 07:21
Install common prometheus exporter to a node
#!/bin/bash
if [ ! -f "/etc/systemd/system/node_exporter.service" ]; then
wget https://github.com/prometheus/node_exporter/releases/download/v0.15.2/node_exporter-0.15.2.linux-amd64.tar.gz
tar -xvf node_exporter*
sudo mv node_exporter-0.15.2.linux-amd64/node_exporter /usr/sbin
sudo bash -c 'cat <<EOT > /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
----------------------------------------
Exception happened during processing of request from ('10.26.0.173', 63486)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
@nqbao
nqbao / install_fluentd.sh
Last active July 25, 2017 19:01
Quick script to install fluentd
#!/bin/bash
sudo apt-get update
sudo apt-get -y install ruby-dev libjemalloc-dev net-tools
sudo gem install fluentd -v "~> 0.14.0" --no-ri --no-rdoc
sudo gem install fluent-plugin-record-modifier
sudo gem install fluent-plugin-cloudwatch-logs
@nqbao
nqbao / bench_grpc_3.py
Last active April 25, 2017 17:13
bench_grpc_3.py
#!/usr/bin/env python
import grpc.beta.implementations
import tensorflow_serving.apis.predict_pb2 as predict_pb2
import tensorflow_serving.apis.prediction_service_pb2 as prediction_service_pb2
import random
import numpy as np
import tensorflow as tf
import threading
### Keybase proof
I hereby claim:
* I am nqbao on github.
* I am nqbao (https://keybase.io/nqbao) on keybase.
* I have a public key ASC9DdgdV1S915zhkOswS6NVKUYnAoYm4IEpFJcFJrig8Qo
To claim this, I am signing this object:
@nqbao
nqbao / bench_grpc2.py
Last active February 27, 2017 22:46
TF gRPC Benchmark
import grpc.beta.implementations
import tensorflow_serving.apis.predict_pb2 as predict_pb2
import tensorflow_serving.apis.prediction_service_pb2 as prediction_service_pb2
import numpy as np
import tensorflow as tf
import threading
from timeit import timeit
# from concurrent.futures import ProcessPoolExecutor
@nqbao
nqbao / install_mesos.sh
Last active February 27, 2017 06:09
install_mesos.sh
#!/bin/bash
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
CODENAME=$(lsb_release -cs)
echo "deb http://repos.mesosphere.io/${DISTRO} ${CODENAME} main" | \
sudo tee /etc/apt/sources.list.d/mesosphere.list
sudo apt-get update
sudo apt-get install -y mesos
@nqbao
nqbao / openvpn_auth.sh
Created February 2, 2017 05:16
OpenVPN auth-user-pass-verify example script
#!/bin/bash
readarray -t lines < $1
username=${lines[0]}
password=${lines[1]}
if [[ "$password" == "bao" ]]; then
echo "ok"
@nqbao
nqbao / export.py
Created January 27, 2017 18:05
Export named signatures from a tf.contrib.learn estimator
# XXX: Only work with tf 11
from tensorflow.contrib.learn.python.learn.utils import export
from tensorflow.contrib.session_bundle import exporter
def my_input_fn():
# Return features tensors, the name is empty because when we build the model
# we feed in empty column name
return {
"": tf.placeholder(tf.float32, shape=[None, 4])
@nqbao
nqbao / read_serving.py
Created January 26, 2017 21:25
read serving signatures from tensorflow
# XXX: this only works for tf 0.11
import tensorflow as tf
from tensorflow.core.protobuf import meta_graph_pb2
from tensorflow.contrib.session_bundle import manifest_pb2
def read_serving_signatures(meta_file):
tf.reset_default_graph()
with tf.Session() as sess:
new_saver = tf.train.import_meta_graph(meta_file)