Skip to content

Instantly share code, notes, and snippets.

View browny's full-sized avatar
👨‍💻

Browny Lin browny

👨‍💻
View GitHub Profile
@browny
browny / note_on_functional_thinking.md
Last active August 29, 2015 14:06
Note on Functional Thinking

Notes on Functional Thinking

Chap2. Shift

3 common building blocks of functional language

  1. Filter Use filter to produce a subset of a collection based on supplied filtering criteria.

  2. Map

@browny
browny / note_on_eloquent_javascript.md
Last active August 29, 2015 14:06
note_on_eloquent_javascript

Eloquent JavaScript

http://eloquentjavascript.net/

Chap1. Values, Types, and Operators

There are six basic types of values in JavaScript: numbers, strings, Booleans, objects, functions, and undefined values

JavaScript uses a fixed number of bits, namely 64 of them, to store a single number value

There are three special values in JavaScript that are considered numbers but don’t behave like normal numbers: Infinity, -Infinity and NaN

package main
import (
"fmt"
"time"
"github.com/csigo/metric"
)
var (
@browny
browny / go_exec_ffmpeg.go
Last active July 10, 2025 07:44
Capture ffmpeg output when executed by Go os/exec pkg
package main
import (
"bufio"
"flag"
"fmt"
"os/exec"
"regexp"
"strings"
)
@browny
browny / diig_run_01.go
Created September 7, 2017 08:23
diig_run_01.go
func (e *Encryptor) Run(src, dst string) error {
dat, err := ioutil.ReadFile(src)
if err != nil {
return nil
}
result := e.encrypt(dat)
return ioutil.WriteFile(dst, result, 0644)
}
func (e *Encryptor) Run(srcType, dstType string) error {
var src []byte
switch srcType {
case "file":
src = e.readFromFile(...)
case "database":
src = e.readFromDatabase(...)
}
// encrypt
func (e *Encryptor) Run(srcType, dstType string) error {
var src []byte
switch srcType {
case "file":
src = e.readFromFile(x, y, z)
case "database":
src = e.readFromDatabase(i, j)
}
// encrypt
func (e *Encryptor) Run(
srcType, dstType, x, y, z, i, j string,
) error {
var src []byte
switch srcType {
case "file":
src = e.readFromFile(x, y, z)
case "database":
src = e.readFromDatabase(i, j)
}
type IReader interface {
Read() ([]byte, error)
}
type IWriter interface {
Write(dat []byte) error
}
func (e *Encryptor) Run(r IReader, w IWriter) error {
// read file
type fileReader struct {
src string
}
func (f *fileReader) Read() ([]byte, error) {
return ioutil.ReadFile(f.src)
}
type dbReader struct {
host string