Skip to content

Instantly share code, notes, and snippets.

@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active July 1, 2025 18:34
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@yrro
yrro / backup.py
Last active July 1, 2025 18:28
Orchestrate backups via borgbackup
#!/usr/bin/python3
# Usage: 'backup' alone will back the system up
# 'backup ARGS' will run borg with ARGS, configuring repository location, passphrase etc.
# e.g., 'backup list ::' will list backups in the repository
# Goals: run on RHEL 8's default Python interpreter (3.6) with no non-RHEL packages required
# Non-goals: backing up multiple filesystems, any configurability save modifying values set
# in code.
@nitred
nitred / optimal_mtu.md
Last active July 1, 2025 18:27
Wireguard Optimal MTU

About

  • I faced bandwidth issues between a WG Peer and a WG server. Download bandwidth when downloading from WG Server to WG peer was reduced significantly and upload bandwidth was practically non existent.
  • I found a few reddit posts that said that we need to choose the right MTU. So I wrote a script to find an optimal MTU.
  • Ideally I would have liked to have run all possible MTU configurations for both WG Server and WG Peer but for simplicity I choose to fix the WG Server to the original 1420 MTU and tried all MTUs from 1280 to 1500 for the WG Peer.

Testing

  • On WG server, I started an iperf3 server
  • On WG peer, I wrote a script that does the following:
    • wg-quick down wg0
  • Edit MTU in the /etc/wireguard/wg0.conf file
% RESUME DOCUMENT STYLE -- Released 23 Nov 1989
% for LaTeX version 2.09
% Copyright (C) 1988,1989 by Michael DeCorte
\typeout{Document Style `res' <26 Sep 89>.}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% res.sty
%
% \documentstyle{res}
@vasanthk
vasanthk / System Design.md
Last active July 1, 2025 18:19
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@gleitz
gleitz / reload.js
Last active July 1, 2025 18:18
Reloading modules from the repl in Node.js
// Reloading modules from the repl in Node.js
// Benjamin Gleitzman ([email protected])
//
// Inspired by Ben Barkay
// http://stackoverflow.com/a/14801711/305414
//
// Usage: `node reload.js`
// You can load the module as usual
// var mymodule = require('./mymodule')
// And the reload it when needed
@burkeholland
burkeholland / 4.1.chatmode.md
Created June 30, 2025 02:15
4.1 Beast Mode v2
description
4.1 Beast Mode

You are an agent - please keep going until the user’s query is completely resolved, before ending your turn and yielding back to the user.

Your thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough.

You MUST iterate and keep going until the problem is solved.

@R3V1Z3
R3V1Z3 / vscode-snakecase-to-camelcase.md
Last active July 1, 2025 18:14
Convert all occurrences of snake_case to camelCase in VS Code. Windows/Linux walk-through here: https://youtu.be/vlHel1fN5_A

Convert snake_case to camelCase in VS Code

  • Press CTRL-H ( ⌥⌘F on Mac ).
  • Press ALT-R ( ⌥⌘R on Mac ).
  • Type _([a-zA-Z]).
  • Press TAB and type $1.
  • Press ALT-ENTER ( ⌥ENTER on Mac ).
  • Press F1 and type upper, then press ENTER.
  • Press CTRL-ALT-ENTER ( ⌥ENTER on Mac ).
@weristwiegott
weristwiegott / Calendar.vue
Last active July 1, 2025 18:14
ShadCN Vue - Enhanced Calendar with Integrated Date Picker
<script lang="ts" setup>
import { cn } from '@/lib/utils';
import { CalendarDate } from '@internationalized/date';
import { CalendarRoot, type CalendarRootProps, useForwardPropsEmits } from 'reka-ui';
import { computed, type HTMLAttributes, ref, watch } from 'vue';
import {
CalendarCell,
CalendarCellTrigger,
CalendarGrid,
CalendarGridBody,
@renschni
renschni / Manus_report.md
Last active July 1, 2025 18:09
In-depth technical investigation into the Manus AI agent, focusing on its architecture, tool orchestration, and autonomous capabilities.

I wrote an in-depth research prompt to conduct a GPT-Deep-Research on the Manus topic, seeking to replicate it with currently available open source tools. This is the result:

TLDR: Manus AI Agent Report

Manus is an autonomous AI agent built as a wrapper around foundation models (primarily Claude 3.5/3.7 and Alibaba's Qwen). It operates in a cloud-based virtual computing environment with full access to tools like web browsers, shell commands, and code execution. The system's key innovation is using executable Python code as its action mechanism ("CodeAct" approach), allowing it to perform complex operations autonomously. The architecture consists of an iterative agent loop (analyze → plan → execute → observe), with specialized modules for planning, knowledge retrieval, and memory management. Manus uses file-based memory to track progress and store information across operations. The system can be replicated using open-source components including CodeActAgent (a fine-tuned Mistral model), Docker for sandbox