Skip to content

Instantly share code, notes, and snippets.

@lintianzhi
lintianzhi / redirect.go
Last active December 26, 2015 04:49
http.Post() 301 303
package main
import (
"net/http"
)
func handleGet(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(200)
w.Write([]byte("Hello World"))
}

前端对分发的请求API:

POST /new
Content-Type: application/json

<description>
 (title, time, memory, source, input, output, sample_input, sample_output)
@lintianzhi
lintianzhi / upload-v3.rb
Created November 28, 2013 09:41
qiniu ruby sdk v3, upload
#!/usr/bin/env ruby
require 'qiniu-rs'
Qiniu::RS.establish_connection! :access_key => 'access key',
:secret_key => 'secret key'
bucket_name = 'test963'
token = Qiniu::RS.generate_upload_token :scope => bucket_name,
:expires_in => 3600
package main
import (
"fmt"
"crypto/aes"
"crypto/cipher"
"encoding/hex"
"path/filepath"
"io/ioutil"
"os"
@lintianzhi
lintianzhi / design.md
Last active January 3, 2016 18:39
毕业设计的设计 0v0

内部的依赖关系可以设计为一个任务保存一个rely number,然后完成一个任务去把所有依赖它的任务的rely number减一,遇到零则该任务进入队列,重复直至所有任务完成。

Authorization
加密的时候加密内容为: <uri>\n<body>
// 上传任务
func SetTimeout(client *Client, t int) (err error) {
timeout := time.Duration(t) * time.Second
dialTimeout := func(network, addr string) (net.Conn, error) {
return net.DialTimeout(network, addr, timeout)
}
if client.Transport == nil {
client.Transport = &http.Transport{
Dial: dialTimeout,
@lintianzhi
lintianzhi / av.md
Last active August 29, 2015 13:56
参考

七牛转码引导

在七牛上面使用转码功能,我们根据客户的实际场景提供了一些转码的建议。

转码的容器

  1. mp4
    • mp4 容器的兼容性在所有的浏览器,移动设备里面是最好的
    • 默认使用H.264视频编码器,acc音频编码器
  2. webm
package main
import (
"fmt"
"math/rand"
"strings"
"time"
)
var (
package main
import (
"fmt"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":8080")
package main
import (
"runtime/debug"
"time"
)
func main() {
m := int64(1024*1024) * 100