Skip to content

Instantly share code, notes, and snippets.

$ ffcvt
Usage:
ffcvt [flags]
Flags:
-aes audio encoding method set (FFCVT_AES)
-ves video encoding method set (FFCVT_VES)
-aea audio encoding method append (FFCVT_AEA)
@suntong
suntong / CascadedSelections.html
Created September 5, 2015 13:50
Cascading Select boxes
<html>
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript" defer="defer">
function cascadeSelect(parent, child){
var childOptions = child.find('option:not(.static)');
child.data('options',childOptions);
parent.change(function(){
@suntong
suntong / Dockerfile
Last active June 19, 2017 00:20
Dockerfile for ubuntu
# DevEnv:ubuntu
# Dockerfile for build environment for ubuntu
FROM sfxpt/ubuntu:zesty
# set the http_proxy to make use of cached packages from caching proxy server
#ENV http_proxy MY_HTTP_PROXY
# Set the env variables to non-interactive
ENV DEBIAN_FRONTEND noninteractive
@suntong
suntong / k-means_scikit.ipynb
Created September 21, 2015 03:25
k-means scikit
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@suntong
suntong / strings.go
Created October 31, 2015 21:45
Golang strings 包中的函数和方法
// strings.go
// Credit: http://www.cnblogs.com/golove/p/3236300.html
------------------------------------------------------------
// Count 计算字符串 sep 在 s 中的非重叠个数
// 如果 sep 为空字符串,则返回 s 中的字符(非字节)个数 + 1
// 使用 Rabin-Karp 算法实现
func Count(s, sep string) int
@suntong
suntong / go_io-read_packages.md
Last active July 20, 2022 09:32
[go-nuts] Differences between os, io, ioutils, bufio, bytes (with Buffer type) packages for file reading

http://grokbase.com/t/gg/golang-nuts/142spmv4fe/go-nuts-differences-between-os-io-ioutils-bufio-bytes-with-buffer-type-packages-for-file-reading

I'm quite confused as there seems to be multiple redundant ways to solve my problem (read a file, parse the content, serve it via http). Most people on stackoverflow would use bufio, but I just can't get the differences between this package and the Buffer type of bytes and just reading a file with the os methods. Also I don't know when and why I should choose those ways to do it, when I have the simple, but non-versatile, ioutils.ReadFile.

func getReqAddons(r Request) string {
ret := ""
if len(r.RequestPlugins.RequestPlugin) != 0 {
for _, v := range r.RequestPlugins.RequestPlugin {
ret += fmt.Sprintf(" R: (%s) %s\n", v.Name, minify(v.RuleParameters.Xml))
}
}
if len(r.ExtractionRules.ExtractionRule) != 0 {
for _, v := range r.ExtractionRules.ExtractionRule {
ret += fmt.Sprintf(" E: (%s: %s) %s\n", v.Name, v.VariableName, minify(v.RuleParameters.Xml))
func getReqAddons(r Request) string {
var buf bytes.Buffer
if len(r.RequestPlugins.RequestPlugin) != 0 {
for _, v := range r.RequestPlugins.RequestPlugin {
fmt.Fprintf(&buf, "  R: (%s) %s\n", v.Name,
minify(v.RuleParameters.Xml))
}
}
if len(r.ExtractionRules.ExtractionRule) != 0 {
for _, v := range r.ExtractionRules.ExtractionRule {
@suntong
suntong / OdbcDemo.go
Created November 10, 2015 21:42
Odbc Demo
////////////////////////////////////////////////////////////////////////////
// Porgram: OdbcDemo
// Purpose: Go MSSQL odbc demo, using the code.google.com/p/odbc driver
// Authors: Tong Sun (c) 2013, All rights reserved
////////////////////////////////////////////////////////////////////////////
// Style: gofmt -tabs=false -tabwidth=2 -w
package main
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.