Skip to content

Instantly share code, notes, and snippets.

@dfang
dfang / keys.md
Last active May 15, 2018 13:20
iTerm shortcut keys

Jump backward or forward by word(option + left/right)

Preferences ---> Keys ---> Send Escape Sequence b/f

Insert proxychains4 -q before commands (option + q)

Preferences ---> Keys ---> Send Hex Code (0x01 0x70 0x72 0x6f 0x78 0x79 0x63 0x68 0x61 0x69 0x6e 0x73 0x34 0x20 0x2d 0x71 0x20 0x0D)

Insert http_proxy=http://0.0.0.0:8118 https_proxy=https://0.0.0.0:8118 before commands ( option + p)

Preferences ---> Keys ---> Send Hex Code (0x01 0x68 0x74 0x74 0x70 0x5f 0x70 0x72 0x6f 0x78 0x79 0x3d 0x68 0x74 0x74 0x70 0x3a 0x2f 0x2f 0x30 0x2e 0x30 0x2e 0x30 0x2e 0x30 0x3a 0x38 0x31 0x31 0x38 0x20 0x68 0x74 0x74 0x70 0x73 0x5f 0x70 0x72 0x6f 0x78 0x79 0x3d 0x68 0x74 0x74 0x70 0x73 0x3a 0x2f 0x2f 0x30 0x2e 0x30 0x2e 0x30 0x2e 0x30 0x3a 0x38 0x31 0x31 0x38 0x20 0x0D)

@dfang
dfang / builder.go
Created May 15, 2018 09:47 — forked from vaskoz/builder.go
Golang Builder pattern
package main
import "strconv"
import "fmt"
type Color string
type Make string
type Model string
const (
@dfang
dfang / negroni-gorilla.go
Created April 30, 2018 13:43 — forked from danesparza/negroni-gorilla.go
Negroni with Gorilla mux subrouter
package main
import (
"fmt"
"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
"log"
"net/http"
)
@dfang
dfang / converters.go
Created April 25, 2018 05:53 — forked from vishakvkt/converters.go
gorilla schema - convert html date
import(
"reflect"
"time"
"github.com/gorilla/schema"
)
func ConvertFormDate(value string) reflect.Value {
s, _ := time.Parse("2006-01-_2", value)
return reflect.ValueOf(s)
}
package poison
import (
"database/sql"
"reflect"
"github.com/gorilla/schema"
)
// Convertors for sql.Null* types so that they can be
@dfang
dfang / log.go
Created April 22, 2018 12:10 — forked from gonzaloserrano/log.go
logrus wrapper
package log
import (
"fmt"
"github.com/Sirupsen/logrus"
"runtime"
"strings"
)
var logger = logrus.New()
@dfang
dfang / docker-compose-coreos.sh
Created October 18, 2017 05:18 — forked from leowinterde/docker-compose-coreos.sh
Install latest version docker compose on coreos
sudo su -
mkdir -p /opt/bin
version=$(curl https://github.com/docker/compose/releases/latest -sLI -o /dev/null -w '%{url_effective}' | sed 's:.*/::')
curl -L "https://github.com/docker/compose/releases/download/$version/docker-compose-$(uname -s)-$(uname -m)" -o /opt/bin/docker-compose
chmod +x /opt/bin/docker-compose
docker -v
docker-compose -v
exit
@dfang
dfang / Dockerfile
Created October 8, 2017 13:25 — forked from royalicing/Dockerfile
Rails 5.1 Dockerfile
FROM ruby:2.4-alpine
ENV PATH /root/.yarn/bin:$PATH
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh build-base nodejs tzdata
RUN apk update \
&& apk add curl bash binutils tar gnupg \
&& rm -rf /var/cache/apk/* \
@dfang
dfang / README.md
Created October 1, 2017 13:45 — forked from githubutilities/README.md
Shadowsocks proxy and ssh proxy

Shadowsocks Proxy

apt-get install python-pip
pip install shadowsocks

sudo ssserver -p 443 -k password -m aes-256-cfb --user nobody -d start
@dfang
dfang / what-forces-layout.md
Created September 5, 2017 08:11 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()