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 -*- | |
from ratelimit import limits, sleep_and_retry | |
from time import time | |
count = 0 | |
@sleep_and_retry | |
@limits(calls=3, period=5) | |
def call_api(): |
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
from subprocess import run | |
# not working, Bad file descriptor | |
run( | |
"head /dev/random -c 100", | |
stdout=open("/tmp/head.out", "wb", 0).fileno(), | |
shell=True, | |
) |
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
PASS: run-backtrace-fp-core-x86_64.sh | |
PASS: run-backtrace-fp-core-aarch64.sh | |
PASS: run-backtrace-fp-core-ppc64le.sh | |
PASS: run-backtrace-core-x32.sh | |
PASS: run-backtrace-core-i386.sh | |
PASS: run-backtrace-fp-core-i386.sh | |
PASS: run-backtrace-core-ppc.sh | |
PASS: run-backtrace-core-s390x.sh | |
PASS: run-backtrace-core-s390.sh | |
PASS: run-backtrace-core-aarch64.sh |
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
import React, { Component } from '@alipay/bigfish/react' | |
import { Flex, Card, WingBlank, WhiteSpace } from 'antd-mobile' | |
export default class ExampleCard extends Component { | |
render() { | |
return ( | |
<WingBlank size="lg"> | |
<WhiteSpace size="lg" /> | |
<Card> | |
<Card.Header |
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 re | |
re.compile(r'^(?:(?:\s){0,}(?P<n0>(?:CLUSTER(?:\s){1,}ADDSLOTS|CLUSTER(?:\s){1,}DELSLOTS|cluster(?:\s){1,}addslots|cluster(?:\s){1,}delslots))(?:\s){1,}(?P<n1>(?:\d){1,}(?:(?:\s){1,}(?:\d){1,}){0,})(?:\s){0,}|(?:\s){0,}(?P<n2>(?:CLUSTER(?:\s){1,}COUNT-FAILURE-REPORTS|CLUSTER(?:\s){1,}FORGET|CLUSTER(?:\s){1,}REPLICAS|CLUSTER(?:\s){1,}REPLICATE|CLUSTER(?:\s){1,}SLAVES|cluster(?:\s){1,}count-failure-reports|cluster(?:\s){1,}forget|cluster(?:\s){1,}replicas|cluster(?:\s){1,}replicate|cluster(?:\s){1,}slaves))(?:\s){1,}(?P<n3>(?:\d){1,})(?:\s){0,}|(?:\s){0,}(?P<n4>(?:CLUSTER(?:\s){1,}COUNTKEYSINSLOT|cluster(?:\s){1,}countkeysinslot))(?:\s){1,}(?P<n5>(?:\d){1,})(?:\s){0,}|(?:\s){0,}(?P<n6>(?:CLUSTER(?:\s){1,}FAILOVER|cluster(?:\s){1,}failover))(?:\s){1,}(?P<n7>(?:FORCE|TAKEOVER|force|takeover))(?:\s){0,}|(?:\s){0,}(?P<n8>(?:CLUSTER(?:\s){1,}RESET|cluster(?:\s){1,}reset))(?:\s){1,}(?P<n9>(?:HARD|SOFT|hard|soft))(?:\s){0,}|(?:\s){0,}(?P<n10>(?:CLUSTER(?:\s){1,}GETKEYSINSLOT|cluster |
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
echo "\$* in quotes..." | |
for v in "$*" | |
do | |
echo $v | |
done | |
echo "\$@ in quotes..." | |
for v in "$@" | |
do | |
echo $v |
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
for file in $(fd -x file | rg "UTF-8" | cut -f1 -d":") | |
do | |
echo "convert ${file}..." | |
iconv -f utf8 -t gbk "$file" > "$file.new" && | |
mv -f "$file.new" "$file" | |
done |
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
SELECT table_schema "DB Name", | |
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" | |
FROM information_schema.tables | |
GROUP BY table_schema; |
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
4KB 不是随机的一个数,Block device 的读操作是按照 block size 来的,读操作按照 block size align才会更快(size是block size的倍数)。 | |
可以用 dd 对比一下每次读 1bytes,读2097152次,和每次读 1024bytes,一共2048次的速度: | |
➜ ~ dd bs=1 count=2097152 if=/dev/zero of=pirate | |
2097152+0 records in | |
2097152+0 records out | |
2097152 bytes transferred in 6.048756 secs (346708 bytes/sec) | |
➜ ~ dd bs=1024 count=2048 if=/dev/zero of=pirate |
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
git filter-branch --env-filter ' | |
OLD_EMAIL="your email" | |
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] | |
then | |
export GIT_AUTHOR_DATE=$(git show -q --format=%aD $GIT_COMMIT | xargs -I {} gdate --date={} +"%F 23:00:00" | xargs -I {} gdate --date={} +%s) | |
export GIT_COMMITTER_DATE=$(git show -q --format=%aD "$GIT_COMMIT" | xargs -I {} gdate --date={} +"%F 23:00:00" | xargs -I {} gdate --date={} +%s) | |
fi | |
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] | |
then | |
export GIT_AUTHOR_DATE=$(git show -q --format=%aD "$GIT_COMMIT" | xargs -I {} gdate --date={} +"%F 23:00:00" | xargs -I {} gdate --date={} +%s) |