Skip to content

Instantly share code, notes, and snippets.

module main
/*
In-memory blob service.
PUT /path/to/file save a blob under the given path
will overwrite any previously stored blob
GET /path/to/file load a blob from the given path
import os
#include <unistd.h> // Necessary for the C.isatty function
fn main() {
// Define ANSI color codes
// mut ansi_codes := map[string]string
mut ansi_codes := {
'reset': '\x1b[0m'
'red': '\x1b[31m'
const std = @import("std");
pub fn main() !void {
// const allocator = std.heap.page_allocator;
const listen_address = try std.net.Address.parseIp4("127.0.0.1", 1337);
var socket = std.net.StreamServer.init(.{});
defer socket.deinit();
// Start listening for connections
@hholst80
hholst80 / diag.v
Last active December 24, 2023 00:59
import strconv
import math { max, min }
// m-by-n matrix of float 64
// assume C storage (row-major)
pub fn diag(m i64, n i64, lda i64, mut arr []f64, k i64) {
// zero the matrix; potentially faster with vmemset if lda=n
assert lda >= n
zero := i64(0)
for i := zero; i < m; i++ {
@hholst80
hholst80 / README.md
Created May 18, 2023 09:09
ChatGPT learned from the finest security cargo cults

Question 1: In Wayland Sway, how do I handle the bootup to login process?

Response 1: Sway is a window manager, not a display manager, and so doesn't handle the login process directly. You can start Sway directly from the console by typing sway, or automate this process by adding the start command to your shell's profile file. Alternatively, you can use a display manager that supports Wayland, such as GDM, SDDM, or Ly, which can be installed and enabled to start at boot using systemctl.


Question 2: Why would I like to use Void Linux?

Response 2: Void Linux is a rolling release, independent distribution. It uses runit as its init system, xbps as its package manager, and LibreSSL instead of OpenSSL. It offers glibc and musl libc variants, has a minimalist base install, supports non-free packages, and offers good documentation.

@hholst80
hholst80 / README.md
Created May 15, 2023 20:03
Cargo cult GTP

why should imports be top level and not in the function body where the functions are used?

ChatGTP 4

There are several reasons why it is typically recommended to place import statements at the top of your Python files:

  1. Readability and maintainability: Placing all imports at the top of the file makes it easy to see all of the file's dependencies in one place. This makes it easier to understand the context in which the code is running.

  2. Performance: Importing a module has some overhead. If you import it inside a function that's called many times, you'll pay that overhead each time the function is called. In contrast, if you import the module at the top level, the import happens just once, no matter how many times functions in the module are called. Note that Python is smart enough not to reload the entire module each time it's imported, but there's still some overhead to checking whether the module needs to be updated.

@hholst80
hholst80 / README.md
Last active August 14, 2022 10:33
crystal dreams 2 - see inside a cube effect

Crystal Dreams 2 - View the inside of a cube through a magic block

The effect

There is a rotating cube on the screen. There is also a magic block that enables us to view inside the Cube. The block is a plane with a thickness that always cuts through the center of the Cube. The two shapes rotates around a fixed center point during the entire effect (although the view frustum movies up and beyond). There are some of the usual pixel dust on screen as well, that interacts with the alpha channel but besides that nothing special. The focus of my analysis is of course on the magic block itself.

# This is how we usually do things.
FROM alpine:latest AS t1
RUN <<EOF
find /var/cache/apk
apk add --no-cache build-base
find /var/cache/apk
EOF
# This won't actually do anything. Cache needs to be enabled.
@hholst80
hholst80 / README.md
Created January 8, 2022 11:18
why I run my shit in containers
6  ⌘ ✔  sudo dnf upgrade azure-cli                                                                                                                                                                                                 30s  ~ 
Last metadata expiration check: 0:28:42 ago on lör  8 jan 2022 11:47:32.
Dependencies resolved.

 Problem: problem with installed package python3-azure-cli-telemetry-2.30.0-5.fc35.noarch
  - package python3-azure-cli-telemetry-2.30.0-5.fc35.noarch requires azure-cli = 2.30.0-5.fc35, but none of the providers can be installed
  - cannot install both azure-cli-2.32.0-1.el7.x86_64 and azure-cli-2.30.0-5.fc35.noarch
  - cannot install both azure-cli-2.30.0-5.fc35.noarch and azure-cli-2.32.0-1.el7.x86_64
@hholst80
hholst80 / acryonyms.md
Last active June 7, 2021 12:37
Business acronyms

Marketing

CBM - Community-Based Marketing B2B - Business To Business B2C - Business To Consumer ROI - Return On Investment CMS - Content Management System LMS - Learning Management System ILT - Instructor-Led Training LSP - Logistics Service Provider