Skip to content

Instantly share code, notes, and snippets.

@diogoos
diogoos / server.mjs
Created January 16, 2026 01:17
Sample HTTP Server using Node
// server.mjs
import { createServer } from 'node:http';
const server = createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
const quotes = [
{ text: "Simplicity is the ultimate sophistication.", author: "Leonardo da Vinci" },
{ text: "Make it work, make it right, make it fast.", author: "Kent Beck" },
{ text: "What you do every day matters more than what you do once in a while.", author: "Gretchen Rubin" },
from queue import Queue
from concurrent.futures import ThreadPoolExecutor
import threading
def worker(data):
# Pre-process text, create embeddings, or do another compute-intensive tasks
def writer():
while True:
item = queue.get()
#!/bin/bash
# run-valgrind.sh - run program under valgrind with custom glibc loader
# Usage:
# ./run-valgrind.sh [valgrind options] -- ./your_program [program args]
GLIBC_DIR="/opt/glibc-debug/lib"
LOADER="$GLIBC_DIR/ld-linux-aarch64.so.1"
if [ ! -x "$LOADER" ]; then
echo "Error: loader $LOADER not found or not executable"
@diogoos
diogoos / ThumbnailCarouselView.swift
Created April 1, 2021 09:59
A mini image carousel to display thumbnails
struct ThumbnailSlideView: View {
// parameters
@Binding var images: [UIImage]
// element sizing
var size: CGFloat = 100
var spacing: CGFloat = 16
private var pageSize: CGFloat { size + spacing }
private var marginAdjust: CGFloat { pageSize / 2 }
@diogoos
diogoos / SnapCarousel.swift
Last active March 25, 2024 15:40 — forked from xtabbas/SnapCarousel.swift
A carousel that snap items in place built on SwiftUI
//
// CarouselView.swift
//
// Created by xtabbas on 5/7/20.
// Copyright © 2020 xtadevs. All rights reserved.
// Original source available at
// https://gist.github.com/xtabbas/97b44b854e1315384b7d1d5ccce20623
//
// Modified by Diogo Silva on 30/03/21
// Modified source available at
@diogoos
diogoos / DynamicTextView.swift
Created December 21, 2020 16:12
MacOS SwiftUI textfield that autoresizes to fit the content (like iMessage bubble)
//
// DynamicTextView.swift
// Originally for "Issuing"
//
// Created by Diogo Silva on 12/21/20.
//
import AppKit
import SwiftUI