Skip to content

Instantly share code, notes, and snippets.

@4ydx
4ydx / nginx.conf
Last active August 29, 2015 14:16 — forked from plentz/nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@4ydx
4ydx / Better error handling
Created April 26, 2015 02:05
Wrapping multiple similar calls so that error handling code is reduced.
type WriteDB struct {
Conn *sql.DB
Err error
}
func (db *WriteDB) Do(
update,
title,
updated_at,
updated_by,
@4ydx
4ydx / Register Gob Caution
Last active August 29, 2015 14:20
Beware accidentally using non-pointer values when calling register gob
package main
import (
"bytes"
"encoding/gob"
"fmt"
)
type Animal interface {
Height() int
@4ydx
4ydx / Permutation
Created May 9, 2015 09:23
Permute an array of integers, finding the largest number represented by concatinating the array values
package main
import (
"fmt"
)
func orderOfMagnitude(magnitude, val int) int {
for {
if val == 0 {
break
@4ydx
4ydx / Vim Setup
Last active September 7, 2019 05:09
Vim Setup
- mac:
brew install lua
brew install vim --with-lua
- plugin manager: https://github.com/junegunn/vim-plug
- double check that vim has +lua support: vim --version
- if not, compile:
@4ydx
4ydx / Go Sqlite3 Backup
Created June 17, 2015 02:00
Go Sqlite3 Backup
package main
import (
"database/sql"
"fmt"
"github.com/mattn/go-sqlite3"
"log"
"os"
"regexp"
"time"
@4ydx
4ydx / Xterm + XQuartz + Xmonad
Last active August 29, 2015 14:23
Xterm + XQuartz + Xmonad
.xmodmap (for japanese keyboard)
keycode 101 = backslash bar backslash bar
.Xdefaults:
xterm*Background: black
xterm*Foreground: white
xterm*faceName: Monaco
xterm*faceSize: 9
.bashrc:
@4ydx
4ydx / Install XMonad
Created June 27, 2015 06:49
Install XMonad
- http://ghcformacosx.github.io/
- http://xquartz.macosforge.org/landing/
- LIBRARY_PATH=/opt/X11/lib:$LIBRARY_PATH cabal install X11
- cabal install xmonad
@4ydx
4ydx / .bashrc
Created July 1, 2015 03:51
.bashrc
findg() {
find . -type f -exec grep -Hn "$1" {} \;
}
vim_open() {
vim $(find . -type f -exec grep -l "$1" {} \;)
}
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)