Skip to content

Instantly share code, notes, and snippets.

@viega
viega / defer.h
Created March 20, 2025 01:58
A C implementation of defer using `goto`
// defer.h
// [email protected]
// © 2025 Crash Override, Inc.
// Licensed under the BSD 3-Clause license
#pragma once
#include <stdint.h>
typedef struct n00b_defer_ll_t n00b_defer_ll_t;
@khalidx
khalidx / node-typescript-esm.md
Last active April 15, 2025 14:15
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@no-defun-allowed
no-defun-allowed / selling-lisp-by-the-pound.org
Last active April 17, 2024 06:10
Selling Lisp by the pound

Selling Lisp by the Pound

“Paper late!” cried a voice in the crowd,

“Old man dies!” The note he left was signed,

‘Old Kiczales’ - it seems he’s drowned!

@whiteinge
whiteinge / hello-report.txt
Last active May 11, 2024 16:36
File sizes for "hello world" in various comple-to-C and compile-to-binary languages
Default compiler settings used, unless noted otherwise. Host system is Fedora
x86_64. Linked libs produced via `ldd`.
Linked libs common to all below: linux-vdso libc ld-linux
Size Lang Specific libs Common libs
18K c - -
20K luastatic liblua libm libdl
22K vala libgobject libglib libffi libpcre libpthread

UPDATE:

These results are invalid. Some of the server implementations don't parse correctly and rust-tokio/ponylang-tcp don't seem to parse at all. See here for better benchmarks: https://gist.github.com/kprotty/5a41e9612657de00788478a7dde43d78

====

wrk -t4 -c128 -d10 --latency http://localhost:12345

  • Machine:
    • Intel Core i7-6700k (4 cores, 8 threads, 4.2ghz)
    • 16GB DDR4 2400mhz RAM
    • Arch Linux, Kernel 5.2.8
Command IDA Pro radare2 r2 (visual mode) GDB WinDbg
Analysis
Analysis of everything Automatically launched when opening a binary aaa or -A (aaaa or -AA for even experimental analysis) N_A N_A N/A
Navigation
@ffwff
ffwff / change-layout
Last active March 5, 2020 22:06
Changes layout of current i3 workspace
#!/bin/bash
if [[ "$1" = "fourbox" ]]; then
(i3-save-tree |sed -e's/^\s*\/\/\s[^\"].*//g' -e's/^\s*\/\///g' | \
jq '..|objects|select(.type=="con")|select(has("nodes")|not)'| \
jq -s '{layout:"splith","type":"con",nodes:[{"layout":"splitv",nodes:[.[0],.[1]]},{"layout":"splitv",nodes:[.[2],.[3]]}]}') > /tmp/layout
else
(i3-save-tree |sed -e's/^\s*\/\/\s[^\"].*//g' -e's/^\s*\/\///g' | \
jq '..|objects|select(.type=="con")|select(has("nodes")|not)'| \
jq -s '{layout:"'$1'","type":"con",nodes:.}') > /tmp/layout
@mbinna
mbinna / effective_modern_cmake.md
Last active April 21, 2025 14:17
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@Serikov
Serikov / main.cpp
Last active December 9, 2024 21:18
C++ Coroutines Ts generator<T> with co_await
#include <coroutine>
#include <stdexcept>
#include <variant>
#include <memory>
namespace detail {
// simple type erasure for iterators
template<typename T>
struct generic_iterable
@karanlyons
karanlyons / method_missing.py
Last active August 7, 2017 17:47
method_missing for Python: All the headaches of Ruby, now with added whitespace!
import dis
import inspect
class MethodMissingMixin:
def __getattr__(self, attr):
if hasattr(getattr(self, '__methodmissing__', None), '__call__'):
parent_frame = inspect.currentframe().f_back
instructions = dis.get_instructions(parent_frame.f_code)