Skip to content

Instantly share code, notes, and snippets.

View olebedev's full-sized avatar
🏄‍♂️
🌊 🌊 🌊

Oleg Lebedev olebedev

🏄‍♂️
🌊 🌊 🌊
View GitHub Profile

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
((root, Library)->
if typeof! define is \Function && typeof! define[\amd] is "Object" && define[\amd]?
define <[ exports ]>, Library
else
Library = Library(typeof exports is "object" and exports or (root["Library"] = do
noConflict: ((original) ->
noConflict = ->
root["Libraby"] = original
delete! Library.noConflict
Library
MAIN_GOPATH=/usr/local/Cellar/go/1.2/workspace
export GOPATH=$MAIN_GOPATH
MAIN_PATH=$PATH:$GOPATH/bin
export PATH=$MAIN_PATH
# goenv functions
activate(){
export GOPATH="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)"
export OLDPS1=$PS1
export PS1="(go:$(basename $GOPATH)) $PS1"
@olebedev
olebedev / coin_flip.lua
Last active August 29, 2015 14:06
# airscript
-- Sample script to make an HTTP request with query parameters
local response = http.request {
url = 'http://www.random.org/integers/',
params = {
num=1, min=0, max=1, format='plain',
rnd='new', col=1, base=10
}
}
if tonumber(response.content) == 0 then
return 'heads'
@olebedev
olebedev / app.js
Last active August 29, 2015 14:06
var app = app || {
id: "unique application instance id",
session_id: "unique session id",
render: function(){
console.log("%c %s","font-size: 50px;color:yellow;",
"chat changed!");
console.table(chat);
}
};
@olebedev
olebedev / debug.sh
Last active August 29, 2015 14:08
Golang test debugging snippet for cgdb
#!/usr/bin/env bash
rm go-swarm.test || true
nohup go test -c -gcflags '-N -l' -work github.com/olebedev/go-swarm
WORK=$(cat nohup.out)
rm nohup.out
cgdb go-swarm.test -- -d ${WORK#WORK=} || rm go-swarm.test || true
# gdb --tui go-swarm.test -d ${WORK#WORK=} || rm go-swarm.test || true
rm go-swarm.test || true
echo ${WORK#WORK=}
PID = /tmp/awesome-golang-project.pid
GO_FILES = $(wildcard *.go)
serve:
@make restart
@fswatch -o . | xargs -n1 -I{} make restart || make kill
kill:
@kill `cat $(PID)` || true
@olebedev
olebedev / _readme.md
Last active August 29, 2015 14:13 — forked from steeve/_readme.md

How to cross compile Go with CGO programs for a different OS/Arch

It is possible to compile Go programs for a different OS, even though go build says otherwise.

You'll need:

package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)

Deploy your own PaaS!

Setting up Dokku with DigitalOcean and Namecheap

..or how I made my own heroku in a few hours for $3.98.

This write-up owes a great deal to dscape's Node.js Deployments with Docker, Dokku, & Digital Ocean, the dokku project itself, and the fine folks working on dokku's issues. I took dscape's article as a starting point when trying this out but found some details lacking so I documented my own process for getting dokku up and running.

1. Get a domain