This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"debug/elf" | |
"fmt" | |
"log" | |
"os" | |
"github.com/bnagy/gapstone" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func reverse(s interface{}) { | |
n := reflect.ValueOf(s).Len() | |
swap := reflect.Swapper(s) | |
for i, j := 0, n-1; i < j; i, j = i+1, j-1 { | |
swap(i, j) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func reverse(slice interface{}) interface{} { | |
// Completely inefficient but syntactically "convenient" | |
s := reflect.ValueOf(slice) | |
switch s.Kind() { | |
case reflect.String: | |
// Support proper rune stuff, but terribly | |
ret := "" | |
for _, v := range slice.(string) { | |
ret = string(v) + ret | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//连接数据库示例(通过*sql.DB执行数据库操作,其内部维护了数据库连接池) | |
func OpenDatabase(ipport, database, user, pwd string) (*sql.DB, error) { | |
connStr := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4", user, pwd, ipport, database) | |
return sql.Open("mysql", connStr) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set theQuery to "{query}" | |
-- 今天的开始、结束,用于筛选今天的事件列表 | |
set todayStart to (current date) | |
set time of todayStart to 0 | |
copy todayStart to todayEnd | |
set time of todayEnd to 86400 | |
todayEnd | |
-- 待添加事件的开始、结束时间,我喜欢按照时间顺序追加的添加方式 | |
copy todayStart to todoStart | |
set hours of todoStart to 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; | |
; AutoHotkey Version: 1.1 | |
; Language: English | |
; Platform: Win9x/NT | |
; Author: Yibo Yang | |
; | |
; Script Function: | |
; Remap Windows10's virtual desktop switcher keyboard shortcut from the default "Ctrl + Win + Left/Right" to Unity's "Ctrl + Alt + Left/Right" | |
; Put into the startup folder so that it will run every time your computer starts (http://superuser.com/questions/948616/windows-10-change-shortcut-keys-to-switch-between-desktops) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Short of learning how to actually configure OSX, here's a hacky way to use | |
# GNU manpages for programs that are GNU ones, and fallback to OSX manpages otherwise | |
alias man='_() { echo $1; man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $1 1>/dev/null 2>&1; if [ "$?" -eq 0 ]; then man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $1; else man $1; fi }; _' |