Skip to content

Instantly share code, notes, and snippets.

@axxie
axxie / Axxie.json
Created October 2, 2025 12:07
The WindowsTerminal color scheme
{
"foreground": "#CCCCCC",
"background": "#0C0C0C",
"cursorColor": "#FFFFFF",
"black": "#2E3436",
"blue": "#0037DA",
"brightBlack": "#555753",
"brightBlue": "#3B78FF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
@axxie
axxie / arguing.md
Created January 30, 2025 09:02
The rules of constructive discussion
  1. The topic discussion is stated in agenda.
  2. The conversation is written down in real time and all participants can see the record. The arguments in the recod are attributed.
  3. If the new topic is added or the old one is changed and it is accepted, it is reflected in the agenda.
  4. There is a limit on the total time of discussion
  5. Each argument must follow the same format: claim, reasoning, consequence. Example: "I think X because Y, so the conclusion is Z (alternatively: we should do Z)". The format must make it clear what exactly are X, Y and Z in the specific argument.
  6. If someone critiques the idea, he must provide the alternative.
  7. If unrelated point is made, it is recored for later or separate discussion.
  8. The decision making criteria must be agreed before starting the discussion.
  9. The discussion must end with actionable takeaways. Each action item must be assigned to responsible person.
@axxie
axxie / xxd.py
Last active November 6, 2024 13:31
The gdb plugin to print memory hex dump.
# Usage:
# (gdb) source xxd.py
# (gdb) hex-dump var 0x100
# In vscode:
# -exec source xxd.py
# -exec hex-dump var 0x100
import gdb
from curses.ascii import isgraph
@axxie
axxie / colors.py
Created July 17, 2023 11:20
Print color table for 256-color terminal
for i in range(0, 256):
print(f"\033[38;5;{i}m[{i}]", end="")
print()
@axxie
axxie / forward.vue
Last active October 17, 2021 09:18
Component that forwards all props and events to another component and only processes some props on its own
<script setup>
import { defineProps } from 'vue'
import { useRouter } from 'vue-router'
const props = defineProps({
to: [String, Object]
})
const router = useRouter()
const click = () => {
@axxie
axxie / mysql_deadlocks.sh
Created January 19, 2021 13:18
Monitor MySQL for new deadlocks
watch -n 0.3 -d -c 'mysql -u <user> <db> --execute="SHOW ENGINE INNODB STATUS" |sed '"'"'s/\\n/\n/g'"'"'|grep "LATEST DETECTED DEADLOCK" -A 2'
@axxie
axxie / execsnoop-tree.py
Last active November 2, 2022 14:13
Collect started processes and display them in the form of tree
#!/usr/bin/python
# @lint-avoid-python-3-compatibility-imports
#
# execsnoop Trace new processes via exec() syscalls.
# For Linux, uses BCC, eBPF. Embedded C.
#
# USAGE: execsnoop [-h] [-t] [-x] [-n NAME]
#
# This currently will print up to a maximum of 19 arguments, plus the process
# name, so 20 fields in total (MAXARG).
@axxie
axxie / log_stream_events.js
Last active December 20, 2019 08:00
Function to log all emitted events on a stream in node.js
function logStreamEvents (emitter, name) {
var oldEmit = emitter.emit
emitter.emit = function () {
const event = arguments[0]
if (!(['data', 'pause', 'readable', 'drain'].includes(event))) console.error('on "%s" event "%s"', name, event)
oldEmit.apply(emitter, arguments)
}
}
@axxie
axxie / DeviceDB.sql
Created May 5, 2018 11:51
Demo of Device -> Active Lock and Lock -> Device relation model in SQL
# Setup DB
# ========
#
DROP TABLE IF EXISTS Devices;
DROP TABLE IF EXISTS LockRequests;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
unsigned int data;
asm("movw r0, #0x8475");
asm("movt r0, #0");
asm("ldr r4, [r0, #0]");
asm("mov %0, r4" : "=r"(data));
printf("read unaligned data: %x\n", data);