Skip to content

Instantly share code, notes, and snippets.

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

Oleg Lebedev olebedev

🏄‍♂️
🌊 🌊 🌊
View GitHub Profile
@olebedev
olebedev / hn_seach.js
Created November 2, 2015 16:59 — forked from meiamsome/hn_search.js
hn job query search
// takes arguments and produces an array of functions that accept context
function handle_args() {
var args = Array.prototype.slice.call(arguments);
return args.map(function(arg) {
if(arg instanceof Function) return arg; // Presumably already a contex-accepting function.
if(arg instanceof Array) return and.apply(this, arg); // make arrays behave as and.
// Presuming a string, build a function to check.
var my_regex = new RegExp(arg.toString(), 'i');
return function(context) {
return context.search(my_regex) > -1;
@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
@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 / 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);
}
#!/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
#

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

package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
@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:

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 / 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=}