Skip to content

Instantly share code, notes, and snippets.

@tehmoon
tehmoon / main.go
Last active December 31, 2017 15:24
Create and start http server in go
package main
import (
"github.com/pkg/errors"
"github.com/gorilla/mux"
"time"
"net/http"
"net"
"log"
"fmt"
@tehmoon
tehmoon / script.sh
Last active December 12, 2017 20:27
Disk space size of each remote branch in git
for a in $(git branch -a | grep remotes | awk '{print $1}' | sed 's/remotes\/origin\///'); do echo -n ${a} -\ ; git clean -d -x -f > /dev/null 2>&1 ;git checkout ${a} > /dev/null 2>&1; du -hs -I .git .;done
@tehmoon
tehmoon / main.go
Created December 12, 2017 20:47
Handling errors in go
package main
import (
"github.com/tehmoon/errors"
"fmt"
)
// This example is similar to "github.com/pkg/errors" from Dave Cheney
// The idea is to declare simple error and have them chained using WrapErr
// so it's easy to have the complete chain of errors if needed.
@tehmoon
tehmoon / Chrome.md
Last active August 22, 2018 16:26
*nix stuff

Use chrome to capture website to pdf:

--headless --temp-profile --print-to-pdf="/tmp/google.pdf" https://www.google.com

On Alpine docker:

docker run -ti --privileged=true --rm -v /tmp/prints:/tmp/prints alpine:edge /bin/sh
@tehmoon
tehmoon / main.go
Created December 19, 2017 02:30
Download from s3 in a streaming fashion
package main
import (
"net/url"
"fmt"
"github.com/tehmoon/errors"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/aws/aws-sdk-go/service/s3"
"io"
@tehmoon
tehmoon / .vimrc
Last active July 29, 2018 00:00
Vim stuff
syn on
se nu
se clipboard=unnamed
se iskeyword==,_,/,\",],[,:,\',.,\,,\(,\),{,}
se nofixendofline
se ts=2
se noexpandtab
set cindent
set sw=2
@tehmoon
tehmoon / main.go
Last active April 10, 2018 01:39
Drop privileges Go
package main
// From https://play.golang.org/p/dXBizm4xl3
import (
"io"
"fmt"
"net"
"net/http"
"os"
@tehmoon
tehmoon / README.txt
Created January 24, 2018 01:43
DNS rebinding PoC
Check if the process is vulnerable to DNS rebinding attack.
First run the server after changing the code:
$> go server.go
Find the ip address of one of you iface and then add this line to /etc/hosts:
x.x.x.x blihblah
@tehmoon
tehmoon / main.go
Last active April 27, 2018 18:43
Using Go templating engine with JSON
package main
import (
"encoding/json"
"os"
"text/template"
)
var data = map[string]interface{}{
"blih": true,
@tehmoon
tehmoon / .zshrc
Created February 15, 2018 01:23
Simple basic zsh config
export WORDCHARS='*?_[]~=&;!#$%^(){}'
setopt HIST_IGNORE_SPACE