openssl genrsa -out server.key 2048
openssl req -new -x509 -key server.key -out server.pem -days 3650
/** | |
理论基础: https://en.wikipedia.org/wiki/Byte_serving | |
使用range header可以得到网络资源的一部分字节 | |
*/ | |
package main | |
import ( | |
"net/http" | |
"fmt" | |
"os" | |
"io/ioutil" |
# This config file was created for myself (@janlay). You may want to add or remove some rules to make efficient use of the Internet. | |
# This file depends on the main.conf which defines your own proxy. | |
# Your main.conf will look like this: | |
# ---- START ---- | |
# #!PROXY-OVERRIDE:rules.conf | |
# [Proxy] | |
# Proxy = https,server.address,port,username,password | |
# ---- END ---- | |
# |
#import <Foundation/Foundation.h> | |
@interface Communicator : NSObject <NSStreamDelegate> { | |
@public | |
NSString *host; | |
int port; | |
} | |
- (void)setup; |
#user nobody; | |
#Defines which Linux system user will own and run the Nginx server | |
worker_processes 1; | |
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores. | |
#error_log logs/error.log; #error_log logs/error.log notice; | |
#Specifies the file where server logs. |
# http://www.scipy-lectures.org/intro/numpy/exercises.html | |
import numpy as np | |
# 1 | |
a = np.linspace(1,15,15).reshape([3,5]).T | |
b = a[[1,3],:] | |
# 2 | |
a = np.arange(25).reshape(5, 5) | |
b = np.array([1., 5, 10, 15, 20]) |
import java.nio.charset.Charset; | |
public class Main { | |
public static void main(String[] args) { | |
String myString = "中文123abc"; | |
byte pText[] = myString.getBytes(Charset.forName("GBK")); // 10 bytes 2个字节代表1个中文 | |
byte pText2[] = myString.getBytes(Charset.forName("UTF-8")); // 12 bytes 3个字节代表1个中文 | |
byte pText3[] = myString.getBytes(Charset.forName("ASCII")); // 8 bytes 1个字节代表1个中文,精度损失了 |
// push.go | |
package push | |
import ( | |
"github.com/mediocregopher/radix.v2/pool" | |
) | |
func listenOnQueue() { | |
p, err := pool.NewCustom("tcp", "address", 5, queue.REDIS_CUSTOM_CONN_FACTORY) |
http.HandleFunc("/", SpecUIPage) | |
http.HandleFunc("/swagger.json", func(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Access-Control-Allow-Origin", "*") | |
// put swagger.json under current folder | |
http.ServeFile(w, r, "swagger.json") | |
}) | |
func SpecUIPage(w http.ResponseWriter, r *http.Request) { | |
swaggerAddr := "http://" + r.Host + "/swagger.json" |
from datetime import datetime | |
from time import mktime | |
import time | |
import sys | |
for line in sys.stdin: | |
try: | |
datestr =line.strip()[-10:] | |
dt = time.strptime(datestr, "%Y.%m.%d") | |
dt = datetime.fromtimestamp(mktime(dt)) |