Skip to content

Instantly share code, notes, and snippets.

View hongta's full-sized avatar

Hongta hongta

  • Ap
  • Singapore
View GitHub Profile
@hongta
hongta / upgrade-centos.MD
Created July 2, 2020 02:31
Upgrade openssl in CentOS

Upgrade OpenSSL to latest in CentOS 7

Prepare

yum group install 'Development Tools' && yum install perl-core libtemplate-perl zlib-devel 

Download and extract

@hongta
hongta / notify.py
Last active June 1, 2018 02:16
[pushover]
# source: http://forums.fast.ai/t/training-metrics-as-notifications-on-mobile-using-callbacks/17330
def send_notification(msg_string):
'''
This function sends message to my mobile using Pushover.
'''
import requests
from datetime import datetime
url = "https://api.pushover.net/1/messages.json"
data = {
@hongta
hongta / model.py
Last active April 28, 2020 23:54
[Convert the Keras HDF5 model into TensorFlow SavedModel] #tensorflow #keras
# source: https://github.com/GoogleCloudPlatform/cloudml-samples/blob/master/census/keras/trainer/model.py
from keras import backend as K
import tensorflow as tf
from tensorflow.python.saved_model import builder as saved_model_builder
from tensorflow.python.saved_model import tag_constants, signature_constants
from tensorflow.python.saved_model.signature_def_utils_impl import predict_signature_def
def to_savedmodel(model, export_path):
"""Convert the Keras HDF5 model into TensorFlow SavedModel."""
@hongta
hongta / flatten.py
Last active April 25, 2018 02:35
[flatten nested Python dictionsries] #python
import collections
def flatten(d, parent_key='', sep='_'):
items = []
for k, v in d.items():
new_key = parent_key + sep + k if parent_key else k
if isinstance(v, collections.MutableMapping):
items.extend(flatten(v, new_key, sep=sep).items())
else:
items.append((new_key, v))
@hongta
hongta / tensorflow_1_7_sierra_gpu.md
Last active November 14, 2018 06:30 — forked from pavelmalik/tensorflow_1_7_high_sierra_gpu.md
Install Tensorflow 1.7 on macOS Sierra 10.12.6 with CUDA 9.0

Tensorflow 1.7 with CUDA on macOS Sierra 10.12.6, Anaconda, and Python 3.6

Largely based on the Tensorflow 1.6 gist, this should hopefully simplify things a bit. Mixing homebrew python2/python3 with pip ends up being a mess, so here's an approach to uses the built-in python27.

Requirements

  • NVIDIA Web-Drivers 378.05.05 for 10.12.6
  • CUDA 9.0 Toolkit
  • cuDNN 7.0.5 (latest release for mac os)
  • Python 3.6
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
cd
sudo apt-get update
sudo apt-get upgrade
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.