Skip to content

Instantly share code, notes, and snippets.

@timezstyle
timezstyle / Golang program stdin stdout interaction.md
Created November 28, 2017 06:22 — forked from jamesrr39/Golang program stdin stdout interaction.md
Using stdout and stdin from other programs in Golang

Go program interaction

Example of how to use stdout and stdin from other programs in golang

Requires go

Run

go run parentprocess.go
package main
import (
"context"
"errors"
"log"
"net/http"
"sync"
"time"
@timezstyle
timezstyle / private-fork.md
Created May 10, 2017 03:25 — forked from DavideMontersino/private-fork.md
How to fork to a private gitlab instance

Theory:

your git repository can have more than one remote server; In this case we want to have two:

  1. one for our private repository on gitlab (will be the default one, called origin)
  2. one to be connected to the source repo on github, to be able to pull new changes (will be called upstream)

How to make a private fork from github to gitlab

@timezstyle
timezstyle / decorator.py
Last active October 26, 2016 04:43
Decoroator Pattern
import functools
def memoize(fn):
known = dict()
@functools.wraps(fn)
def memoizer(*args):
if args not in known:
known[args] = fn(*args)
@timezstyle
timezstyle / decorator.py
Last active October 20, 2016 01:54
Python Design Pattern
# encoding: utf-8
"""
The Decorator Pattern
Use Cases:
• Caching
• Logging
• Monitoring
• Debugging
• Business rules
@timezstyle
timezstyle / request_handler_test.py
Created July 28, 2016 23:40 — forked from didip/request_handler_test.py
Testing Tornado RequestHandlers
import unittest, os, os.path, sys, urllib
import tornado.database
import tornado.options
from tornado.options import options
from tornado.testing import AsyncHTTPTestCase
# add application root to sys.path
APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(os.path.join(APP_ROOT, '..'))
@timezstyle
timezstyle / styles.less
Last active April 13, 2016 03:03
atom tab character with sublime-text like,
/**
* Go to "Atom" => "Stylesheet..."
* Add this below
**/
atom-text-editor::shadow {
/**
* Open your Atom settings and under "Editor Settings" change your
* "Invisbles Tab" field to a single space (" ").
* Otherwise you will see both tab indicators.
*/
@timezstyle
timezstyle / mock.go
Created February 18, 2016 04:02 — forked from imosquera/gist:6716490
golang mock
package main
// Restorer holds a function that can be used
// to restore some previous state.
type Restorer func()
// Restore restores some previous state.
func (r Restorer) Restore() {
r()
}
@timezstyle
timezstyle / Ubuntu 14.04 LTS install docker 1.10.1
Last active November 27, 2016 21:53
Ubuntu 14.04 LTS install docker 1.10.1
# install docker
apt-get update
apt-get install -y --force-yes apt-transport-https ca-certificates
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
# edit /etc/apt/sources.list.d/docker.list
vi /etc/apt/sources.list.d/docker.list
deb https://apt.dockerproject.org/repo ubuntu-trusty main
apt-get update
@timezstyle
timezstyle / sendMail.go
Created November 1, 2015 05:11 — forked from andelf/sendMail.go
golang send mail net/smtp SMTP
package main
import (
"log"
"net/mail"
"encoding/base64"
"net/smtp"
"fmt"
"strings"