Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯

Dat Nguyen datlife

🎯
View GitHub Profile
@datlife
datlife / README.md
Last active Feb 4, 2020
UNIX Tricks
View README.md

Format /etc/passwd file

tail -n +11 /etc/passwd| sort -t$':' -k3 -n | awk -F":" \
'
 BEGIN {
    printf "GID | Name        | User_dir          | Bash_Access        | Description      \n"
    printf "--- | ----------- | ----------------- | ------------------ | -----------------\n"
 }
 {
    printf "%s | %s | %s | %s | %s\n",$3, $1, $6, $7, $5 
@datlife
datlife / dga.dat
Created Feb 1, 2020
Extract all DGA data to a file
View dga.dat
bqkrtxgkmriwsiwcngtivpx.info
jdtmfupdyueqeldvhsjzdvzob.net
guhmpoxzivhba.com
nqqxqhuacaqhzurde.org
lgqsqgpqzijwid.info
ykolyecdcyk.biz
ztvflnxqzpxvpfobv.biz
zqrmkpivrbxccawozqwqpfzh.org
iqyqwhntrxfeq.org
ftadkbomxlnsib.info
@datlife
datlife / README.md
Created Oct 7, 2019
Spark on K8s using helm
View README.md

Status: alpha

alias k=kubectl

# Add microsoft charts to heml
helm repo add msftcharts http://microsoft.github.io/charts/repo
helm repo update

# Launch spark cluster with custom config
@datlife
datlife / fscale.sh
Last active May 1, 2020
Fractional Scaling for Ubuntu 18.04
View fscale.sh
#!/bin/bash
# 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
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');
DEFAULT_URL = "https://jsonplaceholder.typicode.com"
async function getUser(id) {
let resp = await axios.get(`${DEFAULT_URL}/users/${id}`)
@datlife
datlife / README.md
Last active Aug 8, 2020
Build LLVM / Clang on MacOS
View README.md

Build LLVM / Clang on MacOS

Problem

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
datlife / notes.md
Last active Jul 27, 2020
Setup Apache Spark/ Jupyter Notebook on MacOS
View notes.md
@datlife
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
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: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Debug binary_tree",
"type": "cppdbg",
View move_forward.py
"""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.