Skip to content

Instantly share code, notes, and snippets.


Dat Nguyen datlife

Block or report user

Report or block datlife

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
datlife /
Last active Nov 10, 2019
Training Keras model with
"""An example of how to use tf.Dataset in Keras Model"""
import tensorflow as tf # only work from tensorflow==1.9.0-rc1 and after
def training_pipeline():
# #############
# Load Dataset
datlife /
Created Oct 7, 2019
Spark on K8s using helm

Status: alpha

alias k=kubectl

# Add microsoft charts to heml
helm repo add msftcharts
helm repo update

# Launch spark cluster with custom config
datlife /
Last active Sep 14, 2019
Fractional Scaling for Ubuntu 18.04
# Enable fractional scaling on Ubuntu 18.04
# Problem:
# --------
# - Ubuntu 18.04 runs on Gnome 3.28, whichs does not support fractional scaling (120%, 130%).
# - As a result, the text and icon on my 4K 27" monitor are very small.
# Usage:
# -------
datlife /
Last active Sep 10, 2019
Build LLVM / Clang on MacOS

Build LLVM / Clang on MacOS


Built-in Clang / LLVM shipped by Xcode does not support Leak Santizer (-fsantize=leak) feature. For example, this code has memory leak:

// File: main.c

#include <stdlib.h>
datlife / async.jsx
Last active May 19, 2019
Event Loop
View async.jsx
// Async should be first priority over callbacks and promises
// High level idea:
// - Avoid .then .catch in promise
// - Syntatic sugar to make async programming similar to sequential code
const axios = require('axios');
async function getUser(id) {
let resp = await axios.get(`${DEFAULT_URL}/users/${id}`)
datlife /
Created Feb 2, 2018
Export pre-trained TF Object Detection API model to Tensorflow Serving
Thiss script would convert a pre-trained TF model to a servable version for TF Serving.
A pre-trained model can be downloaded here
* A directory contains pretrained model (can be download above).
* Edit three arguments `frozen_graph`, `model_name`, `base_dir` accordingly
datlife /
Last active Mar 5, 2019
Setup Apache Spark/ Jupyter Notebook on MacOS
datlife / trie.h
Created Dec 3, 2018
Trie Implementation in Modern C++ (Kind of, I am learning)
View trie.h
* MIT License
* Copyright (c) 2018 Dat Nguyen
* Trie (aka Prefix Tree) is a type of Tree Data Structure. A node contains a
* list of child Nodes.
* Applications:
* ============
* * Word completion: quickly validate if a word is correctly type.
datlife / launch.json
Last active Nov 9, 2018
C/C++ Workspace settings for VSCode on MacOS (lldb for Debugger)
View launch.json
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit:
"version": "0.2.0",
"configurations": [
"name": "(lldb) Debug binary_tree",
"type": "cppdbg",
"""Move Forward
Start from the first element in the array (A), index is i. Move forward by A[i] steps max.
The algorithm is to return true/false, to indicate whether we can move from the first element
to the last element in the array
A = [2, 0, 1, 2, 0, 3] --> True
# Assumption:
* A[i] > 0 and there are [1 ... N] possible steps A[i] can move if A[i] = N.
You can’t perform that action at this time.