Skip to content

Instantly share code, notes, and snippets.

View clsung's full-sized avatar

Cheng-Lung Sung clsung

View GitHub Profile
!/usr/bin/env bash
# Pre-requisites
sudo apt-get -y update
sudo apt-get --no-install-recommends -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison pkg-config libffi-dev vim python2.7 python-dev
# Add SaltStack repository
# sudo add-apt-repository ppa:saltstack/salt
echo deb http://ppa.launchpad.net/saltstack/salt/ubuntu `lsb_release -sc` main | sudo tee /etc/apt/sources.list.d/saltstack.list
wget -q -O- "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x4759FA960E27C0A6" | sudo apt-key add -
@clsung
clsung / install_opencv_2.4.9.sh
Last active August 29, 2015 14:03
shell to install opencv 2.4.9 on my Centos
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip
unzip opencv-2.4.9
cd opencv-2.4.9
mkdir build
cd build
export PYTHON_EXECUTABLE=$(readlink -e $(which python))
export PYTHON_INCLUDE_DIR=${PYTHON_EXECUTABLE%/*/*}/include
export PYTHON_LIBRARY=${PYTHON_EXECUTABLE%/*/*}/lib/libpython2.7.a
export PYTHON_NUMPY_INCLUDE_DIR=${PYTHON_EXECUTABLE%/*/*}/lib/python2.7/site-packages/numpy/core/include/numpy
export PYTHON_PACKAGES_PATH=${PYTHON_EXECUTABLE%/*/*}/lib/python2.7/site-packages

Last updated: 2015-08-11

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

@clsung
clsung / redigin.go
Created September 27, 2016 04:40
gin with redigo
package main
import (
"flag"
"github.com/garyburd/redigo/redis"
"github.com/gin-gonic/gin"
)
var (
@clsung
clsung / bench_gingo.go
Created September 27, 2016 08:24
using github.com/clsung/gingo
package main
import (
"flag"
"log"
"github.com/clsung/gingo"
"github.com/garyburd/redigo/redis"
"github.com/gin-gonic/gin"
)
// Strings is a helper that converts an array command reply to a []string. If
// err is not equal to nil, then Strings returns nil, err. Nil array items are
// converted to "" in the output slice. Strings returns an error if an array
// item is not a bulk string or nil.
func Strings(reply interface{}, err error) ([]string, error) {
if err != nil {
return nil, err
}
switch reply := reply.(type) {
case []interface{}:
// Values is a helper that converts an array command reply to a []interface{}.
// If err is not equal to nil, then Values returns nil, err. Otherwise, Values
// converts the reply as follows:
//
// Reply type Result
// array reply, nil
// nil nil, ErrNil
// other nil, error
func Values(reply interface{}, err error) ([]interface{}, error) {
if err != nil {
@clsung
clsung / grpc_test.go
Created October 13, 2016 02:38
Test GRPC
// TestRMsvrSuccess test success case, this can't fail
func (s *FailTestSuite) TestRMsvrSuccess() {
err := StartResourceMgr(s.chErr, config.Config.QueueSize, config.Config.RMServerAddr, config.Config.QueuedTaskTTL)
assert.NoError(s.T(), err)
var conn *grpc.ClientConn
for ts := 250; ts <= 1000; ts += 250 {
time.Sleep(time.Duration(ts) * time.Millisecond)
conn, err = grpc.Dial(config.Config.RMServerAddr, grpc.WithInsecure(), grpc.WithTimeout(5*time.Second))
@clsung
clsung / golang-tls.md
Created January 14, 2017 02:27 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@clsung
clsung / libpng_test.c
Created March 30, 2017 13:16 — forked from niw/libpng_test.c
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
/*
* A simple libpng example program
* http://zarb.org/~gc/html/libpng.html
*
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
*
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng15 libpng_test.c