Skip to content

Instantly share code, notes, and snippets.

View billywhizz's full-sized avatar
🤓
always be learning

Andrew Johnston billywhizz

🤓
always be learning
View GitHub Profile
@datenwolf
datenwolf / xcb_shmimg.c
Created March 28, 2025 22:36
minimal example of using XCB to set up a framebuffer to draw to an X11 window
#include <stdlib.h>
#include <stdio.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <xcb/xcb.h>
#include <xcb/shm.h>
#include <xcb/xcb_image.h>
@jwbee
jwbee / jq.md
Last active April 27, 2025 11:31
Make Ubuntu packages 90% faster by rebuilding them

Make Ubuntu packages 90% faster by rebuilding them

TL;DR

You can take the same source code package that Ubuntu uses to build jq, compile it again, and realize 90% better performance.

Setting

I use jq for processing GeoJSON files and other open data offered in JSON format. Today I am working with a 500MB GeoJSON file that contains the Alameda County Assessor's parcel map. I want to run a query that prints the city for every parcel worth more than a threshold amount. The program is

@zackradisic
zackradisic / index.ts
Created February 14, 2025 20:42
Visitor pattern vs sum types and pattern matching
// First, let's look at the traditional visitor pattern
// This is how we might implement a simple expression evaluator
// Traditional Visitor Pattern
namespace Traditional {
// Abstract base class for expressions
abstract class Expr {
abstract accept<T>(visitor: ExprVisitor<T>): T;
}
@tivrfoa
tivrfoa / garbage-collection-vs-manual-memory-management-chatgpt-answer.md
Created February 9, 2025 12:25
when does Garbage collection is faster than manual memory management?

Garbage collection (GC) can sometimes be faster than manual memory management in specific scenarios due to its ability to optimize allocations, reduce fragmentation, and efficiently manage short-lived objects. Here are some situations where GC outperforms manual memory management:

1. Frequent Short-Lived Object Allocations

  • Languages with GC (e.g., Java, Go, C#) often use generational garbage collection, where short-lived objects are allocated in the "young generation" (or equivalent), which is optimized for fast allocation and collection.
  • Example: In a high-throughput web server, frequent allocation and deallocation of request objects can be handled efficiently by GC with minimal overhead.

2. Avoiding Fragmentation

  • Manual memory management (e.g., malloc/free in C, new/delete in C++) can lead to heap fragmentation, slowing down future allocations.
  • GC-based memory managers often use compaction to reduce fragmentation, leading to **faster allocati
@hackermondev
hackermondev / zendesk.md
Last active May 3, 2025 05:23
1 bug, $50,000+ in bounties, how Zendesk intentionally left a backdoor in hundreds of Fortune 500 companies

hi, i'm daniel. i'm a 15-year-old with some programming experience and i do a little bug hunting in my free time. here's the insane story of how I found a single bug that affected over half of all Fortune 500 companies:

say hello to zendesk

If you've spent some time online, you’ve probably come across Zendesk.

Zendesk is a customer service tool used by some of the world’s top companies. It’s easy to set up: you link it to your company’s support email (like [email protected]), and Zendesk starts managing incoming emails and creating tickets. You can handle these tickets yourself or have a support team do it for you. Zendesk is a billion-dollar company, trusted by big names like Cloudflare.

Personally, I’ve always found it surprising that these massive companies, worth billions, rely on third-party tools like Zendesk instead of building their own in-house ticketing systems.

your weakest link

@VictorTaelin
VictorTaelin / ai_reasoning_challenge_v2.md
Last active April 17, 2025 08:38
INVERT A BINARY TREE - $10k AI REASONING CHALLENGE (v2)

THE PROBLEM

🌲 Invert a binary tree! 🌲

Except with 3 catches:

  1. It must invert the keys ("bit-reversal permutation")
  2. It must be a dependency-free, pure recursive function
  3. It must have type Bit -> Tree -> Tree (i.e., a direct recursion with max 1 bit state)
@fightbulc
fightbulc / bun-parallel-server.ts
Last active October 13, 2024 05:42
Bun and Deno Bench (Ubuntu 24.04, AMD Ryzen™ 9 7900X × 24, 64GB RAM)
// will be called via bun-parallel-setup.ts
let i = 0;
Bun.serve({
port: process.env.PORT || 8000,
development: false,
// Share the same port across multiple processes
// This is the important part!
WITH RECURSIVE transitive_dependencies AS (
SELECT package_id AS dependency_id, package_id AS root_id
FROM dependencies
WHERE kind = 'runtime'
UNION ALL
SELECT d.package_id, td.root_id
FROM dependencies d
JOIN transitive_dependencies td ON td.dependency_id = d.package_id AND td.dependency_id <> td.root_id -- Avoid self-joins
WHERE d.kind = 'runtime'
),
@stenuto
stenuto / timelapse.sh
Created June 18, 2024 20:56
Timelapse script
#!/bin/bash
# Check if interval argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 -int <interval_in_seconds>"
exit 1
fi
# Extract the interval value
interval=$2
@velzie
velzie / manifest-v2-chrome.md
Last active May 8, 2025 12:53
How to keep using adblockers on chrome and chromium

How to keep using adblockers on chrome and chromium

  1. google's manifest v3 has no analouge to the webRequestBlocking API, which is neccesary for (effective) adblockers to work
  2. starting in chrome version 127, the transition to mv3 will start cutting off the use of mv2 extensions alltogether
  3. this will inevitably piss of enterprises when their extensions don't work, so the ExtensionManifestV2Availability key was added and will presumably stay forever after enterprises complain enough

You can use this as a regular user, which will let you keep your mv2 extensions even after they're supposed to stop working

Linux

In a terminal, run: