Skip to content

Instantly share code, notes, and snippets.

View lotusirous's full-sized avatar
💭
for { Learn() }

Kha Nguyen lotusirous

💭
for { Learn() }
View GitHub Profile
@lotusirous
lotusirous / install-minikube-coredns.md
Created December 9, 2018 01:12
Install minikube with coredns plugin

Install local kubernetes cluster with minikube

#!/bin/bash

JQ_VERSION="1.6"
GOSS_VERSION="v0.3.6"

function download {
    # $1 is url, # $2 is name
@lotusirous
lotusirous / change-ip-ubuntu18-04.md
Created December 8, 2018 06:17
Change IP in Ubuntu Server 18.04

Change IP in Ubuntu server 18.04

The configuration files are stored in 50-cloud-init.yaml (If it does not exist, using command sudo netplan generate to generate it)

network:
    ethernets:
        eno1:
            addresses: []
 dhcp4: true
@lotusirous
lotusirous / parallel-fetcher.go
Last active December 3, 2018 14:24
fetch a list of urls in parallel by go
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"sync"
)
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-proxy
labels:
proxy: nginx
spec:
template:
metadata:
labels:
@lotusirous
lotusirous / vue-render.js
Created August 2, 2018 07:54
An example of vue render
/**
* Mixins patter
for create other components
* @param {*} heading level for example h1, h2
*/
export function generateTitle(level) {
return {
render: function(createElement) {
return createElement(
`h${level}`,
!! Transparent
urxvt*transparent: true
urxvt*shading: 42
!! Appearance
urxvt.termName: rxvt-unicode
urxvt.scrollBar: false
urxvt.background: black
urxvt.foreground: gray
!! Font prefferenes
@lotusirous
lotusirous / wrap_keras_training.py
Created July 25, 2018 09:22
Log keras training output by wrapping stdout
from __future__ import print_function
from streamlogger import StreamLogger
import logging
import sys
# Set up logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler("./out.log")
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
@lotusirous
lotusirous / stdout_wrapper.py
Last active July 25, 2018 09:34
Python wrap stdout for logging purpose. However, this method is not support to write or read binary data from/to the standard streams.
import logging
import sys
# Setup logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler("./out.log")
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setLevel(logging.DEBUG)
handler.setFormatter(formatter)
@lotusirous
lotusirous / simpleWeb.go
Created July 19, 2018 10:48
Go simple web server.
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@lotusirous
lotusirous / filter_dict_by_value.py
Last active July 17, 2018 14:56
Filter a dict by value in one line
d = {
'a' : 1,
'c': 1,
'b': 2
}
r = list(filter(lambda x: x[1] == 1, d.items())) # x is a tuple (k,v) == x[0], x[1]
print(r)
# result is [('a', 1), ('c', 1)]