Skip to content

Instantly share code, notes, and snippets.

View laixintao's full-sized avatar
📟
I live in the terminal.

laixintao

📟
I live in the terminal.
View GitHub Profile
@riobard
riobard / tcpdump.txt
Last active August 12, 2022 08:19
Poem lines broadcast by my ISP-provided fiber optical modem
# My ISP-provided fiber optical modem broadcasts a line of a poem every ten seconds. Here's the tcpdump of the complete poem.
# The optical modem is made by Shanghai Nokia-Bell Co.,Ltd and its model number is G-140W-UD. It's provided by my ISP, China Unicom in Shenzhen.
$ tcpdump -i vlan10 ether proto 0x8300
15:59:00.720301 00:00:00:00:00:12 (oui Ethernet) > Broadcast, ethertype Unknown (0x8300), length 72:
0x0000: 0000 0000 e4ea 8386 d93c 5468 6520 6461 .........<The.da
0x0010: 7920 4920 6c6f 7374 206d 7920 7665 7279 y.I.lost.my.very
0x0020: 2066 6972 7374 2074 6f6f 7468 2c00 0000 .first.tooth,...
0x0030: 0000 0000 0000 0000 0000 ..........
15:59:10.740778 00:00:00:00:00:12 (oui Ethernet) > Broadcast, ethertype Unknown (0x8300), length 72:
#!/bin/bash
# SET THIS TO BE YOUR DESIRED USERNAME
export MY_USER_NAME_FOR_CERT=`whoami`
# This directory is optional, but will use it to keep the CA root key safe
mkdir keys certs
chmod og-rwx keys certs
# Set up a directory that will serve as the pgconf mount
@bee-san
bee-san / timsort.py
Last active August 15, 2021 10:28
An Python implementation of Timsort
# based off of this code https://gist.github.com/nandajavarma/a3a6b62f34e74ec4c31674934327bbd3
# Brandon Skerritt
# https://skerritt.tech
def binary_search(the_array, item, start, end):
if start == end:
if the_array[start] > item:
return start
else:
return start + 1
@0x4D31
0x4D31 / beautiful_idiomatic_python.md
Last active April 19, 2024 09:17 — forked from JeffPaine/beautiful_idiomatic_python.md
[Beautiful Idiomatic Python] Transforming Code into Beautiful, Idiomatic Python #python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@numberoverzero
numberoverzero / run_scheduled.py
Last active February 16, 2020 07:58
00.async.periodic.rst
import asyncio
import functools
import json
import secrets
import aiohttp
from concurrent.futures import ALL_COMPLETED
@gyribeiro
gyribeiro / tmux_italic.md
Last active March 5, 2024 12:05
enable italic font on tmux
@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@ewenchou
ewenchou / README.md
Last active July 8, 2023 04:36
Run Python script as systemd service
  1. Create a service file like dash_sniffer.service
  2. Put it in /lib/systemd/system/
  3. Reload systemd using command: systemctl daemon-reload
  4. Enable auto start using command: systemctl enable dash_sniffer.service
@laixintao
laixintao / Git常用命令.sh
Last active August 20, 2022 06:52
一些常用的git命令 速查表
------------------------------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------------------------------
@huangblue
huangblue / 从原仓库更新fork仓库
Created August 20, 2016 12:48
当原仓库更新后,如何更新自己fork别人的项目
git clone https://github.com/huangblue/codeparkshare 将fork的项目克隆到本地
git remote add codeparkshare https://github.com/Yixiaohan/codeparkshare 添加远程仓库(fork的原仓库)
git commit 提交本地变更
git remote update 更新原仓库
git checkout master 检出本地分支