Skip to content

Instantly share code, notes, and snippets.

View nguyendangminh's full-sized avatar

Nguyen Dang Minh nguyendangminh

View GitHub Profile
@nguyendangminh
nguyendangminh / reflection.go
Created January 28, 2018 02:37 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@nguyendangminh
nguyendangminh / gist:f5576bdabcf5dbf1ec5e66d857485d80
Created November 25, 2017 04:33
Create PDF with Google Chrome headless
chrome --headless --disable-gpu --print-to-pdf https://www.minhnd.com
@nguyendangminh
nguyendangminh / Caddyfile
Created August 7, 2017 11:16
Caddyfile for Single Page Web Application
ticket.fpt.ai {
root /home/ubuntu/frontend/dist/
rewrite {
to {path} {path}/ /index.html
}
}
@nguyendangminh
nguyendangminh / email_smtp.go
Created August 4, 2017 08:02
Send SMTP email in Go
package main
import (
"fmt"
"log"
"net/smtp"
)
const (
SMTP_SERVER = "smtp.gmail.com"
@nguyendangminh
nguyendangminh / go_get_private_repository.sh
Last active September 8, 2018 09:51
go get private repository
$ git config --global url."[email protected]:".insteadOf "https://bitbucket.org/"
$ git config --global url."[email protected]:".insteadOf "https://github.com/"
$ git config --global url."[email protected]:".insteadOf "https://gitlab.com/"
@nguyendangminh
nguyendangminh / stopinator.py
Created July 29, 2016 08:54
Stop EC2 instances by tag
#!/usr/bin/env python
# Shameless copy from qwiklab
import boto.ec2, os
# Connect to EC2 in this region
region = os.environ.get('EC2_REGION')
connection = boto.ec2.connect_to_region(region)
# Get a list of all instances
@nguyendangminh
nguyendangminh / snapshotter.py
Last active October 9, 2020 19:16
AWS EBS snapshotter
#!/usr/bin/env python
# Shameless copy from qwiklab
import boto.ec2, os, datetime
MAX_SNAPSHOTS = 2 # Number of snapshots to keep
# Connect to EC2 in this region
region = os.environ.get('EC2_REGION')
connection = boto.ec2.connect_to_region(region)
@nguyendangminh
nguyendangminh / get_public_ip.sh
Created July 29, 2016 08:15
Get your public IP address
curl -s icanhazip.com
@nguyendangminh
nguyendangminh / kubernetes-install.sh
Created July 13, 2016 10:06
Kubernetes install via bash
#!/bin/bash
# Copyright 2014 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#