Skip to content

Instantly share code, notes, and snippets.

@suntong
suntong / Yaml-Example.go
Created June 15, 2015 04:21
Yaml Example
package main
import (
"fmt"
"log"
"gopkg.in/yaml.v2"
)
type Config struct {
$ easygen test/commandlineFlag
package easygenapi
import (
"flag"
"fmt"
"os"
)
////////////////////////////////////////////////////////////////////////////
// !!! !!!
// WARNING: Code automatically generated. Editing discouraged.
// !!! !!!
package main
import (
"flag"
"fmt"
"os"
$ 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 / 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
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