Sending Email from Gmail using Go

Turn on “2-Step Verification” so that an “App password” can be generated go get gopkg.in/gomail.v2 Send your Email like the example below: package main import ( "gopkg.in/gomail.v2" ) func main() { m := gomail.NewMessage() m.SetHeader("From", "[email protected]") m.SetAddressHeader("To", "to_adress@xxx", "to_name") m.SetAddressHeader("Cc", "cc_adress@xxx", "cc_name") m.SetHeader("Subject", "Hello! TEST!") m.SetBody("text/html", "Hello! <b>TEST</b>!") d := gomail.NewPlainDialer("smtp.gmail.com", 587, "[email protected]", "the App password") if err := d.DialAndSend(m); err != nil { panic(err) } }

January 31, 2016

SSH Resources in Go

golang.org/x/crypto/ssh github.com/YuriyNasretdinov/GoSSHa Articles: SSH Client connection in Golang Using Go to Execute Commands on Hundreds of Servers with SSH

January 31, 2016

How to Remove All Exited Containers & Dangling Images for Docker?

Updates at 2020-07-08: docker system prune Old tricks: docker ps --quiet --filter=status=exited | xargs docker rm docker images --no-trunc=true --filter="dangling=true" --quiet=true | xargs docker rmi

August 3, 2015

A Comprehensive Note about Proxy Settings

Git > cat ~/.gitconfig [http] proxy = socks5://[host]:[port] [https] proxy = socks5://[host]:[port] Curl (Homebrew) > cat ~/.curlrc socks5 = "[host]:[port]" Docker pull env HTTP_PROXY=http://xxx docker pull yyy GAE Set proxy export HTTP_PROXY http://[host]:[port] export HTTPS_PROXY http://[host]:[port] Delete cacerts.txt under GAE SDK installation to disable SSL verification ( make sure the proxy is safe before this step). Deploy. appcfg.py . --email=[address] --passin

July 8, 2015

Phonetic Notations

Google Dictionary Google dictionary uses a phonetic notation same as NORD (New Oxford American Dictionary). To figure out an unknown phonetic notation, the simple way is to look up a few words that you know how to pronounce: church, hat, which, judge, game, thing, ship, thin, this, yes, pleasure cat, pay, care, father, arm, let, see, here, city, my, pot, no, caught, war, force, boy, put, tour, boot, out, cut, word, item, rabbit, winner, pupil ...

June 30, 2015

Notes on the Design of Go

Refusing new features Avoid leaky abstraction as much as possible. If an abstraction is not solid enough, you’d rather not use them at all. Go is designed like this, the features are carefully selected. If a feature is not solid enough, it will not be allowed to enter Go. No implicit string concatenation Rob: That used to be in the language but was dropped when the semicolon insertion rules went in. You need the + to be able to span lines, and if you can’t span lines operatorless concatenation is close to pointless. ...

June 29, 2015

What Go cannot Do

This is a list about the corner cases that Go cannot do, and their work arounds. Run all deferred functions of other goroutines when a goroutine panics Uncaught panicking of one goroutine will exit the program without executing deferred functions of other goroutines. Workaround: this is the standard behavior, C++ with RAII also has the same problem. Persist your data in a way that crashing will not cause data integrity issue. ...

June 16, 2015

Ebook Manipulation Tools

Ebook manager: Calibre Kindle PDF optimizer: k2pdfopt PDF Border Cropper Briss CHM File Extractor archmage PDF editing Xournal convert images to PDF sudo apt-get install imagemagick convert *.jpg pictures.pdf convert between different formats: sudo apt-get install calibre ebook-convert xxx.mobi xxx.txt --unsmarten-punctuation

June 4, 2015

How to "go get" Behind a Proxy

Proxy for “go get” https_proxy=http://user:pass@proxy_host:port go get ... Proxy for Git In $HOME/.gitconfig: [https] proxy = proxy_url Proxy for Mercurial In $HOME/.hgrc: [http_proxy] host = host:port user = ... passwd = ...

May 6, 2015

Tips on SSH

Generate SSH keys ssh-keygen -C [email protected] Authorize public key at remote server ssh-copy-id user@host On Mac OSX, ssh-copy-id should be installed first. brew install ssh-copy-id Generate PEM ssh-keygen -f ~/.ssh/id_rsa -e -m pem > ~/.ssh/id_rsa.pem Copy file by base64 On remote session, run base64 < myfile and copy the output. On local terminal, run base64 -d > myfile, paste the content and press ctrl+D.

April 28, 2015