Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I wrote like 10 lines of code a week then I sleep.

laixintao

💭
I wrote like 10 lines of code a week then I sleep.
View GitHub Profile
View asy.py
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)
View hide-bilibili-popup.js
// ==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==
@laixintao
laixintao / files.txt
Created Jul 21, 2021
files in gavinmroy/alpine-redis 5.0.9-0 d6617494cb6d 8 months ago 6.96MB docker image.
View files.txt
.
├── bin
│   ├── arch -> /bin/busybox
│   ├── ash -> /bin/busybox
│   ├── base64 -> /bin/busybox
│   ├── bbconfig -> /bin/busybox
│   ├── busybox
│   ├── cat -> /bin/busybox
│   ├── chgrp -> /bin/busybox
│   ├── chmod -> /bin/busybox
View output
number1| x| name
4x| 3| Hi
2| 1|808890312093
5|Hi| Bye
@laixintao
laixintao / Git常用命令.sh
Last active Jun 11, 2021
一些常用的git命令 速查表
View Git常用命令.sh
------------------------------commit------------------------------
$ git status # 检查文件当前的状态
$ git add [文件名] # 追踪新的文件
$ git diff --cached # 若要看已经暂存起来的文件和上次提交时的快照之间的差异
$ git commit -m "Story 182: Fix benchmark" # 用一行命令提交更新
$ git commit -a -m 'added new benchmarks' # 跳过add命令直接提交
$ git rm --cached log.log # 从git仓库中删除不小心追踪的文件(用于gitignore之前追踪的文件)
$ git mv file_from file_to # 移动文件/重命名文件
------------------------------branch------------------------------
@laixintao
laixintao / with_lock.py
Last active May 20, 2021
list.append is an atomic action, so no lock needed when multiple threads append on same list.
View with_lock.py
urls_to_download = ['baidu.com', 'taobao.com', 'zhihu.com', 'douban.com']
done_count = 0
done_count_lock = Lock()
def download(url):
requests.get(url)
with done_count_lock:
done_count += 1
print(f"currnet process: {done_count} / {len(urls_to_download)}")
View 6.48. Libelf from Elfutils-0.177
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
View a.py
def foo(num):
print("foo run")
return num ** 20
def bar(x):
if 0:
print(x)
View magic.py
import ctypes
def deref(addr, typ):
return ctypes.cast(addr, ctypes.POINTER(typ))
deref(id(3), ctypes.c_int)[6] = 2
View autocompletion.py
#!/usr/bin/env python
import sys
from prompt_toolkit import prompt
from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.contrib.regular_languages.compiler import compile
from prompt_toolkit.lexers import Lexer, PygmentsLexer, SimpleLexer
from prompt_toolkit.contrib.regular_languages.completion import GrammarCompleter
from prompt_toolkit.contrib.regular_languages.lexer import GrammarLexer
animal_completer = WordCompleter(