Skip to content

Instantly share code, notes, and snippets.

@nickelca
nickelca / asm_dsl.zig
Last active January 21, 2025 03:12
x86 assembly dsl in zig
comptime {
const builtin = @import("builtin");
std.debug.assert(builtin.target.cpu.arch == .x86);
}
pub const Instruction = union(enum) {
mov_: Mov,
int_: Int,
ret_: Ret,
lea_: Lea,
@rguiscard
rguiscard / README.md
Created October 22, 2024 08:05
Make C library as zig package

It is quite often to include C library in Zig project. If it is a shared library, just link it in build.zig. But if it is not, it can be included as a dependency. Here I use tiny-regex-c as an example.

First, add the c libaray as a dependency.

$ zig fetch --save=tiny_regex_c https://github.com/shahar99s/tiny-regex-c/archive/refs/heads/master.zip

It will show up in the build.zig.zon file. Then include it in build.zig

Private Mode for In-Band Window Resize Notifications

Terminal emulators typically receive window resize events by installing a signal handler for the SIGWINCH signal. Handling of these signals can create challenges due to their inherently racy properties. Resize events must be synchronized with other application state in a safe manner.

Standard control sequences exist to query the current terminal size from the terminal and receive an in-band control sequence with the window size. However, this system requires polling - which is not ideal. Usually, SIGWINCH handling

@sebastiancarlos
sebastiancarlos / grepdist.sh
Last active August 5, 2023 13:57
Grepdist - Print the number of matches in each 10% section of a file
#!/usr/bin/env bash
# All my gist code is licensed under the terms of the MIT license.
# GREPDIST
# Print the number of matches in each 10% section of the file
#
# Example with grep:
# $ grep -c 'Napoleon' war_and_peace.txt
# 576
@adalinesimonian
adalinesimonian / block-the-blue.md
Last active December 27, 2024 22:02
Block all verified Twitter accounts on screen
@8KCoffeeWizard
8KCoffeeWizard / starship.toml
Created October 19, 2022 06:53
starship config
# Warning: This config does not include keys that have an unset value
# $all is shorthand for $username$hostname$localip$shlvl$singularity$kubernetes$directory$vcsh$git_branch$git_commit$git_state$git_metrics$git_status$hg_branch$docker_context$package$cmake$cobol$dart$deno$dotnet$elixir$elm$erlang$golang$haskell$helm$java$julia$kotlin$lua$nim$nodejs$ocaml$perl$php$pulumi$purescript$python$rlang$red$ruby$rust$scala$swift$terraform$vlang$vagrant$zig$buf$nix_shell$conda$memory_usage$aws$gcloud$openstack$azure$env_var$crystal$custom$sudo$cmd_duration$line_break$jobs$battery$time$status$container$shell$character
format = '$all'
right_format = ''
continuation_prompt = '[∙](bright-black) '
scan_timeout = 30
command_timeout = 500
add_newline = true
@morrolinux
morrolinux / linux-full-desktop-container.md
Last active January 23, 2025 10:59
Run a full linux desktop in a container

In the following gist I'm going to guide you through the process of installing and booting an entire linux distribution with full desktop environment just like you would have with a classical VM, but with much better performance and much worse isolation :)

The reason why I did this was mainly because it's cool, but also to test new distros with decent graphics performance without actually booting them on my PC.

If you "try this at home" just keep in mind a container is not as secure as a VM, and some of the option we're going to explore will weaken container isolation from "a bit risky" to "totally unsafe" depending on what you choose.

Also, we're going to use systemd-nspawn for containers as it's probably the best fit for our use case and can also boot any linux partition without needing to prepare an apposite container image.

Less go!

@exzork
exzork / GM Handbook.txt
Last active February 1, 2025 05:22
GM Handbook for Grasscutter
// Grasscutter 2.7.0 GM Handbook
// Created 2022/05/31 17:46:25
// Commands
sendmessage : Sends a message to a player as the server
setfetterlevel : Sets your fetter level for your current active character
setworldlevel : Sets your world level (Relog to see proper effects)
setstats : Sets fight property for your current active character
give : Gives an item to you or the specified player
@taskylizard
taskylizard / fmhy.md
Last active March 10, 2025 12:38
/r/freemediaheckyeah, in one single file (view raw)
@ssokolow
ssokolow / update_flatpak_cli.py
Last active February 28, 2025 20:20
Utility for making Flatpak-installed apps available in the terminal through their normal command names
#!/usr/bin/env python3
"""Flatpak CLI Shortcut Generator
A simple no-argument tool that generates launchers with traditional non-flatpak
command names for your installed Flatpak applications in ~/.local/bin/flatpak.
Does full collision detection and warns you if you forgot to add its output
directory to your PATH. Also overrules the command-line specified in the
``.desktop`` file if the Flatpak maintainer didn't include support for
command-line arguments.