Skip to content

Instantly share code, notes, and snippets.

@lintianzhi
lintianzhi / design.md
Last active January 3, 2016 18:39
毕业设计的设计 0v0

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

Authorization
加密的时候加密内容为: <uri>\n<body>
// 上传任务
package main
import (
"fmt"
"crypto/aes"
"crypto/cipher"
"encoding/hex"
"path/filepath"
"io/ioutil"
"os"
@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

前端对分发的请求API:

POST /new
Content-Type: application/json

<description>
 (title, time, memory, source, input, output, sample_input, sample_output)
@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"))
}
@lintianzhi
lintianzhi / build.sh
Created September 11, 2013 05:16
go build different os arch
#!/bin/bash
if [ $# -lt 1 ]; then
echo xxx
exit 0
fi
GOOS=windows
GOARCH=386
go build
@lintianzhi
lintianzhi / imageView_Des.md
Last active December 20, 2015 17:49
Description of imageView

我们将 mode 看做 3 个 bits,即 mode = X Y Z,其中:

  • X = 0(表示WH - 限定宽高),1(表示LS - 限定长短边)
  • Y = 0(表示LimitOut - 限定图片恰好超出矩形),1(表示LimitIn - 限定图片不能超出矩形)
  • Z = 0(表示NoCrop - 不进行裁剪),1(表示Crop - 进行裁剪,对于 LimitIn 而言无意义)

注意

@lintianzhi
lintianzhi / fetch.go
Last active December 20, 2015 10:59
搜索一个网站内所有包含关键字的页面,并统计
package main
import (
"os"
"log"
"fmt"
"io/ioutil"
"net/http"
"regexp"
)
@lintianzhi
lintianzhi / double.scm
Created December 13, 2012 15:40
How to understand the result?
(define (inc x) (+ x 1))
(define (double fun) (lambda (x) (fu (fu x))))
(((double (double double)) inc) 5)
@lintianzhi
lintianzhi / daemonize.c
Created December 8, 2012 10:04
daemonize the program
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
int main(int argc, char *argv[])
{
int i;
pid_t pid;
if(argc < 2)