Skip to content

Instantly share code, notes, and snippets.

View ckeyer's full-sized avatar
🏍️
On My Way

Chuanjian Wang ckeyer

🏍️
On My Way
  • On My Way
  • Xian,Beijing,Wuhan
View GitHub Profile
@ckeyer
ckeyer / [email protected]
Created July 1, 2015 11:23
通过百度API查找IP对应地理位置的小测试
package main
import (
// "bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
// "unicode/utf8"
)
@ckeyer
ckeyer / google.conf
Created July 2, 2015 04:04
Nginx上配置Google反向代理
server {
listen 80;
server_name s.ckeyer.com search.ckeyer.com;
location / {
proxy_pass https://s.ckeyer.com/;
}
}
server {
listen 443;
server_name s.ckeyer.com search.ckeyer.com;
@ckeyer
ckeyer / structtime2json.go
Last active August 29, 2015 14:24
json编码含有time.Time类型的结构体时的格式化
package main
import (
"encoding/json"
"fmt"
"time"
)
type JsonTime struct {
time.Time
@ckeyer
ckeyer / baseController.go
Created July 4, 2015 08:53
跨域访问WebApi服务器是出现 No 'Access-Control-Allow-Origin' 的问题
package controllers
import (
"github.com/astaxie/beego"
)
type Controller struct {
beego.Controller
}
@ckeyer
ckeyer / fun_bug.go
Created July 6, 2015 16:32
闲得DT写的
package main
import (
"fmt"
)
type CkString string
func (c *CkString) String() string {
return fmt.Sprint(c)
@ckeyer
ckeyer / host_info.py
Created July 7, 2015 10:56
获取主机信息
#!/usr/bin/python
import os
kernel_version = os.popen('''/bin/uname -a | awk \'{print $1,$3}\'''').read().strip('\n')
ip = os.popen('''/sbin/ifconfig | grep 'inet'|awk '{print $2}'|cut -d ":" -f 2''').read().strip('\n')
ipv6 = os.popen('''/sbin/ifconfig | grep 'inet6'|awk '{print $3}' ''').read().strip('\n')
memory = os.popen('''free -m | head -2''').read().strip('\n')
disk = os.popen('''df -hT''').read().strip('\n')
print "Kernel Version:",kernel_version
@ckeyer
ckeyer / monitor.go
Created July 8, 2015 17:27
监控框架
package main
import (
"fmt"
"sync"
"time"
)
type Set struct {
Name string
@ckeyer
ckeyer / https_get.go
Last active November 6, 2015 07:51
Golang HTTP GEt 设置
package monitor
import (
"errors"
"net"
"net/http"
"time"
“crypto/tls"
)
// 返回Get数据
@ckeyer
ckeyer / selection_sort.go
Created July 13, 2015 14:30
选择排序:从所有序列中先找到最小的,然后放到第一个位置。之后再看剩余元素中最小的,放到第二个位置……
package main
import (
"sort"
)
// 选择排序:从所有序列中先找到最小的,然后放到第一个位置。
// 之后再看剩余元素中最小的,放到第二个位置……
func SelectionSort(data interface{}, args ...int) {
if v, ok := data.(sort.Interface); ok {
@ckeyer
ckeyer / insertion_sort.go
Created July 13, 2015 14:31
直接插入排序
package main
import (
"sort"
)
// 直接插入排序是一种简单的插入排序法,其基本思想是: * 把待排序的纪录
// 按其关键码值的大小逐个插入到一个已经排好序的有序序列中,直到所有的纪
// 录插入完为止,得到一个新的有序序列
func InsertionSort(data interface{}, args ...int) {