Skip to content

Instantly share code, notes, and snippets.

@daniellowtw
daniellowtw / a.go
Created December 10, 2015 17:25
adding a method to another method
package main
type foo func(int, int)
func (f foo) bar(x int) {
f (x, x)
}
func main() {
add := func (x int, y int) {
@daniellowtw
daniellowtw / go_Interface_embedding_test.go
Last active March 31, 2016 10:20
Experiments with interface embedding
package main
import "testing"
type A interface {
x(key interface{}) interface{}
}
type B struct {
A
// Inside inner/inner.go
package inner
type A interface {
foo() string
}
type B interface {
Bar() string
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestName(t *testing.T) {
err := f()
assert.Error(t, err)
@daniellowtw
daniellowtw / fn.js
Created May 21, 2016 23:15
Extract javascript function name and body
var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
var FN_ARG_SPLIT = /,/;
var FN_ARG = /^\s*(_?)(.+?)\1\s*$/;
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
// annotate returns arguments and body, that can be passed into Function
function annotate(fn) {
var res,
fnText,
argDecl
@daniellowtw
daniellowtw / main.go
Created March 28, 2017 12:39
lazy-typechecking
package main
type A interface {
Bar() int
}
type AMaker func() A
type AImpl struct{}

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

// Easier to just refer than to programatically retrieve it
Scala> ZoneId.getAvailableZoneIds.toArray(Array[String]()).sorted.foreach(println)
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
@daniellowtw
daniellowtw / tmux-cheatsheet.markdown
Created April 11, 2018 21:09 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@daniellowtw
daniellowtw / timeformat.md
Last active January 8, 2023 08:05
Time format
format e.g
dd/MMM/yyyy:HH:mm:ss ZZZZ 19/Apr/2010:06:36:15 -0700
dd/MMM/yyyy HH:mm:ss 09/Mar/2004 22:02:40 08691
MMM dd, yyyy hh:mm:ss a Dec 2, 2010 2:39:58 AM
MMM dd yyyy HH:mm:ss Jun 09 2011 15:28:14
MMM dd HH:mm:ss yyyy Apr 20 00:00:35 2010
MMM dd HH:mm:ss ZZZZ yyyy Feb 07 15:22:31 -0700 2016
MMM dd HH:mm:ss ZZZZ Sep 28 19:00:00 +0000
MMM dd HH:mm:ss Mar 16 08:12:04