Skip to content

Instantly share code, notes, and snippets.

@nkaretnikov
nkaretnikov / README.md
Created September 27, 2019 15:08
lldb trace

Start debugserver:

tty0 # debugserver localhost:8000 main

Start tracing:

tty1 $ lldb
tty1 (lldb) command script import trace.py
@boukeversteegh
boukeversteegh / sortArrays.js
Last active February 15, 2023 09:21
Sorting multiple arrays in Javascript
/**
* Sorts all arrays together with the first. Pass either a list of arrays, or a map. Any key is accepted.
* Array|Object arrays [sortableArray, ...otherArrays]; {sortableArray: [], secondaryArray: [], ...}
* Function comparator(?,?) -> int optional compareFunction, compatible with Array.sort(compareFunction)
*/
function sortArrays(arrays, comparator = (a, b) => (a < b) ? -1 : (a > b) ? 1 : 0) {
let arrayKeys = Object.keys(arrays);
let sortableArray = Object.values(arrays)[0];
let indexes = Object.keys(sortableArray);
let sortedIndexes = indexes.sort((a, b) => comparator(sortableArray[a], sortableArray[b]));
@JerryLokjianming
JerryLokjianming / Crack Sublime Text Windows and Linux.md
Last active May 10, 2025 09:18
Crack Sublime Text 3.2.2 Build 3211 and Sublime Text 4 Alpha 4098 with Hex

How to Crack Sublime Text 3.2.2 Build 3211 with Hex Editor (Windows | Without License) ↓

  1. Download & Install Sublime Text 3.2.2 Build 3211
  2. Visit https://hexed.it/
  3. Open file select sublime_text.exe
  4. Offset 0x8545: Original 84 -> 85
  5. Offset 0x08FF19: Original 75 -> EB
  6. Offset 0x1932C7: Original 75 -> 74 (remove UNREGISTERED in title bar, so no need to use a license)
@sepastian
sepastian / pdftk_rotate_even_odd_pages_differently.sh
Created June 18, 2019 15:19
PDFTK: rotate even/odd pages differently
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# From https://unix.stackexchange.com/a/18631/56290
# Rotate even pages by 180 degrees, don't rotate odd pages.
pdftk A=infile.pdf shuffle Aoddnorth Aevensouth output outfile.pdf
@cheesits456
cheesits456 / uneval.js
Last active January 12, 2020 12:36 — forked from cho45/uneval.js
Stringify multiple JS Object Types
function uneval(o) {
switch (typeof o) {
case "undefined": return "(void 0)";
case "boolean": return String(o);
case "number": return String(o);
case "string": return `"${o.replace(/\W/gi, function(_) { return `\\u${(0x10000 + _.charCodeAt(0)).toString(16).slice(1)}` })}"`;
case "function": return `(${o.toString()})`;
case "object":
if (o == null) return "null";
let ret, type = Object.prototype.toString.call(o).match(/\[object (.+)\]/);
@Rich-Harris
Rich-Harris / what-is-svelte.md
Last active March 20, 2025 20:49
The truth about Svelte

I've been deceiving you all. I had you believe that Svelte was a UI framework — unlike React and Vue etc, because it shifts work out of the client and into the compiler, but a framework nonetheless.

But that's not exactly accurate. In my defense, I didn't realise it myself until very recently. But with Svelte 3 around the corner, it's time to come clean about what Svelte really is.

Svelte is a language.

Specifically, Svelte is an attempt to answer a question that many people have asked, and a few have answered: what would it look like if we had a language for describing reactive user interfaces?

A few projects that have answered this question:

@WesThorburn
WesThorburn / 1.Instructions.md
Last active January 18, 2025 16:18
Linux: Compile C++ to WebAssembly and JavaScript using Emscripten and CMake

Linux: Compile C++ to WebAssembly and JavaScript using Emscripten and CMake

Download and Install Emscripten

  • My preferred installation location is /home/user
  • Get the latest sdk: git clone https://github.com/emscripten-core/emsdk.git
  • Enter the cloned directory: cd emsdk
  • Checkout main: git checkout main
  • Install the lastest sdk tools: ./emsdk install latest
  • Activate the latest sdk tools: ./emsdk activate latest
  • Activate path variables: source ./emsdk_env.sh
@Nadrieril
Nadrieril / shell.nix
Last active May 6, 2025 10:11
Building LineageOS on NixOS
# I used this shell.nix to build LineageOS 13.0 for my maguro (Samsung Galaxy Nexus GSM) phone
# The build instructions for normal Linuxes are here: https://wiki.lineageos.org/devices/maguro/build
# For NixOS, follow those instructions but skip anything related to installing packages
# Detailed instructions:
# cd into an empty directory of your choice
# copy this file there
# in nix-shell:
# $ repo init -u https://github.com/LineageOS/android.git -b cm-13.0
# $ repo sync
# $ source build/envsetup.sh
@johncf
johncf / torr-details.py
Created March 28, 2018 19:24
Torrent: download specific pieces with libtorrent
#!/bin/env python3
import libtorrent as lt
with open("/path/to/file.torrent", "rb") as f:
e = lt.bdecode(f.read())
info = lt.torrent_info(e)
print(info.num_pieces(), 'pieces')
files = info.files()
def humanize(size_bytes):
@ricksladkey
ricksladkey / log.py
Last active April 25, 2024 12:27
Example Python script for GDB that reads and displays the text in a ring buffer every time the program stops
from __future__ import print_function
import struct
import gdb
def log():
# Get the inferior.
try: