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 os | |
parent_pid = os.getpid() | |
print("parent pid: ", parent_pid) | |
forked_pid = os.fork() | |
print("forked_pid: ", forked_pid) | |
parent_pid = os.getpid() | |
print("my pid: ", parent_pid) |
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 os | |
import sys | |
from prompt_toolkit import prompt | |
pid = os.getpid() | |
print("old: ", pid) | |
forked_pid = os.fork() | |
print("forked pid: ", forked_pid) |
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
class Foo: | |
foo = "hello" | |
def print(self): | |
print(self.foo) | |
class Bar: | |
foo = "world" |
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
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; |