Skip to content

Instantly share code, notes, and snippets.

View olebedev's full-sized avatar
🎾

Oleg Lebedev olebedev

🎾
View GitHub Profile
@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=}
@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

#!/bin/sh
# OPTIONAL FLAGS:
#
# -geoip true
# this will install maxmind geoip and auto update crontab file
#
# -cloudwatch true
# this will install aws cloud watch metrics and send them to aws dashboard
#
@olebedev
olebedev / tiny closure Promise.js
Last active August 29, 2015 14:26 — forked from briancavalier/tiny closure Promise.js
A closure version of my mod (https://gist.github.com/814313) to unscriptable's tiny promise (https://gist.github.com/814052/)
function Promise() {
var callbacks = [],
promise = {
resolve: resolve,
reject: reject,
then: then,
safe: {
then: function safeThen(resolve, reject) {
promise.then(resolve, reject);
}
@olebedev
olebedev / tmux-cheatsheet.markdown
Last active August 29, 2015 14:27 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@olebedev
olebedev / wercker.yml
Created October 14, 2015 17:27 — forked from mies/wercker.yml
default golang wercker.yml
box: wercker/golang
# Add services here
# Build definition
build:
# The steps that will be executed on build
steps:
# Sets the go workspace and places you package
# at the right place in the workspace tree
- setup-go-workspace