Skip to content

Instantly share code, notes, and snippets.

View browny's full-sized avatar
👨‍💻

Browny Lin browny

👨‍💻
View GitHub Profile
func (e *Encryptor) Run(srcType, dstType string) error {
var src []byte
switch srcType {
case "file":
src = e.readFromFile(...)
case "database":
src = e.readFromDatabase(...)
}
// encrypt
@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)
}
@browny
browny / go_exec_ffmpeg.go
Last active October 28, 2023 23:55
Capture ffmpeg output when executed by Go os/exec pkg
package main
import (
"bufio"
"flag"
"fmt"
"os/exec"
"regexp"
"strings"
)
package main
import (
"fmt"
"time"
"github.com/csigo/metric"
)
var (
@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

@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 / twstock_name.py
Created September 15, 2014 23:37
Get TW stock name by its number
# requirements:
# beautifulsoup4==4.3.2
# uniout==0.3.7
import sys
import urllib2
import re
import uniout
from bs4 import BeautifulSoup
from pprint import pprint
@browny
browny / colorful_tail.sh
Created November 15, 2013 03:15
The bash script make the log colorful with specified tag
#!/bin/bash
TAIL=`which tail`
AWK=`which awk`
if [[ -z $TAIL ]]; then
echo -e "Cannot find tail executable.\n"
exit 1
fi
if [[ -z $AWK ]]; then
echo -e "Cannot find awk executable.\n"
exit 1

Git Diff

git diff                 // Look diff from previous commited version

git diff > temp.patch    // Output diff to patch file
git apply temp.patch     // Apply patch 'pk_xxx'

git reset --hard 6a137   // Force reset to version '6a137' will lost new commit

git format-patch HEAD^^^ // Patch to nth(^) previos version from HEAD, output multiple files

[user]
name = <Your Name>
email = <Your Emain>
[core]
excludesfile = ~/.gitignore
pager = less -FXrS -x4
filemode = false
whitespace = cr-at-eol
editor = vim