This file contains hidden or 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
# from https://www.zhihu.com/people/tou-gou-bao-da | |
package main | |
import ( | |
"fmt" | |
"math" | |
"math/rand" | |
"reflect" | |
"runtime" | |
"sort" |
This file contains hidden or 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
#include <stdio.h> | |
#include <time.h> | |
#ifndef MERSENNE_TWISTER_H | |
#define MERSENNE_TWISTER_H | |
#define __STDC_LIMIT_MACROS | |
# define uint32_t unsigned int | |
#ifdef __cplusplus | |
extern "C" { |
This file contains hidden or 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
#include <u.h> | |
#include <libc.h> | |
/* | |
* algorithm by | |
* D. P. Mitchell & J. A. Reeds | |
*/ | |
#define LEN 607 | |
#define TAP 273 |
This file contains hidden or 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 ( | |
"fmt" | |
"os" | |
"os/exec" | |
"time" | |
) | |
func main() { |
This file contains hidden or 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
33 # search and kill | |
32 function gkill(){ | |
31 filter=$1 | |
30 exp=[${filter:0:1}]${filter:1} | |
29 echo '>ps aux | grep' $exp | |
28 echo $( ps aux | grep $exp --color=always | xargs -I % echo '\n' %) | |
27 echo "Kill?" | |
26 read Keypress | |
25 case "$Keypress" in | |
24 * ) kill $2 $args $(ps aux | grep $exp --color=always | awk '{print $2}'); |
This file contains hidden or 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 a = redis.call('get',KEYS[1]); | |
if a and a:find("^updateat:") ~= nil then | |
-- this key already update by anther thread. so we test | |
if tonumber(string.sub(a, 10, string.len(a))) <= tonumber(KEYS[2]) then | |
return redis.call('set',KEYS[1], KEYS[3]); | |
end | |
return; | |
end | |
return redis.call('set',KEYS[1], KEYS[3]); |
This file contains hidden or 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
dash_id=xxxx | |
api_key=xxx | |
app_key=xxx | |
# 1. export | |
curl -X GET "https://app.datadoghq.com/api/v1/dash/${dash_id}?api_key=${api_key}&application_key=${app_key}" > dash.json | |
# 2. edit dash.json | |
move "graphs", "title", "description" up one level in the json hierarchy, from being beneath "dash" to being at the same level |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
# | |
# Author : zhangxiaolin | |
# E-mail : [email protected] | |
# Date : 17/11/1 20:00 | |
# Desc : ... | |
import types | |
from selectors import DefaultSelector, EVENT_WRITE, EVENT_READ | |
from collections import deque |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
# | |
# Author : zhangxiaolin | |
# E-mail : [email protected] | |
# Date : 16/11/3 16:03 | |
# Desc : ... | |
import queue | |
from queue import Queue | |
import socket |
This file contains hidden or 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
(pycharm_ascle) [~]$ cat .git-templates/hooks/pre-commit | |
#!/usr/bin/env bash | |
git diff --cached -- '*.py' | `which pep8` --max-line-length=119 --show-source --diff | |
if [ $? -gt 0 ]; then | |
echo | |
echo '--------' | |
echo 'Lint check failed.' | |
exit 1 |