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
# hint: read this link before answering: | |
# https://stackoverflow.com/questions/1466000/difference-between-modes-a-a-w-w-and-r-in-built-in-open-function | |
with open("a.txt", "w") as f: | |
f.write("abcd") | |
with open("a.txt", "r+") as f: | |
f.write("x") | |
x = f.read(1) | |
print(x) |
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 requests.adapters import HTTPAdapter, Retry | |
from requests import Session | |
retries = Retry( | |
total=5, backoff_factor=1, status_forcelist=[502, 503, 504] | |
) | |
session = Session() # reuse tcp connection | |
session.mount("http://", HTTPAdapter(max_retries=retries)) | |
session.mount("https://", HTTPAdapter(max_retries=retries)) |
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
vim -i NONE \ | |
-c 'set nomore' +'redir! > /dev/stdout' \ | |
+'silent! echo "sK7gstart"' \ | |
+'silent! verbose map' \ | |
+'silent! verbose map!' \ | |
+'silent! echo "aYx9end"' \ | |
+'redir END' \ | |
+'qall' | \ | |
curl -X POST --data-binary @- http://127.0.0.1:5005/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
def escape_ansi(line): | |
# 7-bit and 8-bit C1 ANSI sequences | |
ansi_escape_8bit = re.compile( | |
rb""" | |
(?: # either 7-bit C1, two bytes, ESC Fe (omitting CSI) | |
\x1B | |
[@-Z\\-_] | |
| # or a single 8-bit byte Fe (omitting CSI) | |
[\x80-\x9A\x9C-\x9F] | |
| # or CSI + control codes |
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 time | |
def generate(): | |
try: | |
for i in range(5): | |
time.sleep(0.5) | |
yield i | |
finally: | |
print("My jos is done, clock out!") |
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
- #morning-stand-up | |
- Recap | |
- Today's plan | |
- morning announcement: | |
- yesterday and today's work todos | |
- {{[[query]]: {and: [[TODO]] {between: [[yesterday]] [[today]]} } }} |
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
aahed | |
aalii | |
aapas | |
aargh | |
abaca | |
abaci | |
aback | |
abaft | |
abaka | |
abamp |
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 ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func main() { | |
fmt.Printf("Generated service id: %s\n", CreateServiceID()) |
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 asyncio | |
async def subshell(): | |
print("start sleep...") | |
process = await asyncio.create_subprocess_shell( | |
"sleep 23", | |
) | |
print("sub process create, my id {}".format(process, process.pid)) | |
await asyncio.sleep(23) |
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 Hide bilibili video popup | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description hide annoying pop up choices. | |
// @author laixintao | |
// @match https://www.bilibili.com/* | |
// @icon https://www.google.com/s2/favicons?domain=bilibili.com | |
// @grant GM_addStyle | |
// ==/UserScript== |
NewerOlder