# defult: -i=2 -t=20 -u=100
> java SimpleSnowflakeTest.java
Generators QPS: [ 187 181] Total IDs: 4176 (368 /s) Conflicts: 1139 (104/s) 27.275%
# -t=20 -u=200 => 20 tokens pre 200 ms (100/s)
> java SimpleSnowflakeTest.java -t=20 -u=200
Generators QPS: [ 100 99]] Total IDs: 3404 (199 /s) Conflicts: 1062 (52 /s) 31.199%
This file contains 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 ( | |
"crypto/sha512" | |
"flag" | |
"log" | |
"syscall" | |
"time" | |
) |
This file contains 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
local function assign(dist, source) | |
for k,v in pairs(source) do dist[k] = v end | |
end | |
M = {} | |
local actions = {} | |
actions.__mt = {} | |
actions.__mt.__index = { | |
method = 'GET', |
I hereby claim:
- I am wcp1231 on github.
- I am wcp1231 (https://keybase.io/wcp1231) on keybase.
- I have a public key whose fingerprint is 17FC 73FF 2142 3B77 BA36 AF4E 5F55 40D9 90F8 4418
To claim this, I am signing this object:
This file contains 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
# python has no tail recursion optimization. | |
def f(n): | |
if n == 0: return 1 | |
return n * f(n-1) | |
f(5000) | |
# > RuntimeError: maximum recursion depth exceeded | |
# so, we can use trampoline | |
def f(n): |
This file contains 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
ruby -run -e httpd . -p 5000 |
This file contains 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
# 已知的bug是,如果一个元素分成几行就不会被匹配上 | |
ruby -i.bak -rdate -pe '$_.gsub!(/(<(script|link|img)[^@%>]*=["][^"]*\.(js|css|png|jpg))/) {%Q|#{$1}?#{DateTime.now.strftime "%Y%m%d%H"}|}' ./**/*.jsp |
This file contains 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
# -*- coding: utf-8 -*- | |
import sys | |
from concurrent.futures import ThreadPoolExecutor | |
from datetime import datetime | |
import os | |
import re | |
def build_replace_func(): | |
version_string = "?ver=%s" % datetime.now().strftime("%Y%m%d%H") | |
def func(match_obj): |
This file contains 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
public static String getFilecharset(File sourceFile) { | |
String charset = "GBK"; | |
byte[] first3Bytes = new byte[3]; | |
try { | |
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(sourceFile)); | |
bis.mark(0); | |
int read = bis.read(first3Bytes, 0, 3); | |
System.out.println("字节大小:"+read); | |
if (read == -1) { | |
return charset; //文件编码为 ANSI |
This file contains 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
// ==UserScript== | |
// @name BISTU_Auto_Evaluate | |
// @namespace http://wcp1231.github.io | |
// @include http://jwgl.bistu.edu.cn/* | |
// @version 1 | |
// ==/UserScript== | |
for(var i = 2; i < 8; i++) { | |
var id = "DataGrid1__ctl" + i + "_JS1"; | |
document.getElementById(id).selectedIndex = 1; |
NewerOlder