Skip to content

Instantly share code, notes, and snippets.

View alt-romes's full-sized avatar
🦖

Rodrigo Mesquita alt-romes

🦖
View GitHub Profile
@alt-romes
alt-romes / Main.hs
Created March 9, 2026 16:09
Running C debugger on extra C sources in Haskell program
module Main where
foreign import ccall unsafe "do_c_thing" do_c_thing :: Int -> IO ()
main = do
do_c_thing 5
@alt-romes
alt-romes / Main.hs
Created March 9, 2026 15:57
Allocating Maybe in Cmm foreign import Haskell
{-# LANGUAGE GHCForeignImportPrim, MagicHash, UnliftedFFITypes, UnboxedTuples #-}
import GHC.Exts
foreign import prim "test" tt :: Word# -> Addr#
main = do
case addrToAny# (tt 0##) of
(# mb #) -> print (mb :: Maybe (Maybe ()))
@alt-romes
alt-romes / gist:76064e26557fd6ec2b565272a4fb0964
Last active November 21, 2025 18:19
On running the Haskell debugger

Install GHC 9.14.1-rc2 (using GHCup)

ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/refs/heads/develop/ghcup-prereleases-0.0.9.yaml
ghcup install ghc 9.14.0.20251104
ghcup set ghc 9.14.0.20251104

Install haskell-debugger

@alt-romes
alt-romes / UnsureCalculator.hs
Created April 24, 2025 23:38
Unsure Calculator in exactly 100 lines of Haskell
{- cabal:
build-depends: base, random, containers
-}
{-# LANGUAGE GADTs, ViewPatterns, GHC2021 #-}
import Text.Printf
import Control.Monad (liftM, ap)
import Data.Function (on)
import Data.List (sort, minimumBy)
import System.Random
import qualified Data.Map as M
@alt-romes
alt-romes / srcpkgs-picom-template
Last active September 18, 2021 19:53
xbps-src package to install latest non-numerical release (vNext) of the yshui/picom compositor -- see void-linux/void-packages
# Template file for 'picom'
pkgname=picom
version=9
revision=1
build_style=meson
configure_args="-Dwith_docs=true"
hostmakedepends="pkg-config asciidoc"
makedepends="MesaLib-devel dbus-devel libconfig-devel libev-devel pcre-devel
pixman-devel xcb-util-image-devel xcb-util-renderutil-devel
libxdg-basedir-devel uthash"
@alt-romes
alt-romes / (errors workaround) wal.vim
Last active August 29, 2021 10:11
lightline wal colorscheme -- errors workaround
" =============================================================================
" Filename: autoload/lightline/colorscheme/wal.vim
" Author: Dylan Araps
" License: MIT License
" Last Change: 2017/10/28 12:21:04.
" =============================================================================
source $HOME/.cache/wal/colors-wal.vim
let s:black = [ color0, 232 ]
@alt-romes
alt-romes / system-zero-setup.sh
Last active September 18, 2021 00:50
Mirrors system-zero-setup private file to a public gist
#!/usr/bin/env bash
# ----- --- -----
echo "Installing developer command line tools..."
xcode-select --install
echo "Installing Homebrew..."
if ! command -v brew >/dev/null 2>&1; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)";
@alt-romes
alt-romes / pointers.c
Created March 9, 2021 20:12
Example program to explain pointers to a friend
#include <stdio.h>
int main(int argc, char *argv[]) {
int arr[10];
int * arrptr;
int x;
int * xptr;
@alt-romes
alt-romes / logtime.sh
Last active March 8, 2021 10:52
Simple program to count and log work time to a time log
#!/usr/bin/env python3
# Log Time:
# logtime.sh work 1h30m
# This will add an entry to the file in $logfilename of type "work: 1h30m" under the header for the day
#
# Usage suggestion:
# Dependencies: termdown @ https://github.com/trehn/termdown
# Bash Function:
# tasktimer(){
@alt-romes
alt-romes / getminecraftitemsdata.py
Created May 18, 2020 12:01
Script to get all items from minecraft and print them as SQL insert commands
import requests
allitemsHTML = requests.get('https://minecraft-ids.grahamedgecombe.com/').text
import re
items = re.findall('class="name">(.*?)<.*?class="text-id">\((.*?)\)</', allitemsHTML)
for i in range(len(items)):
print('item id {}, item name {}, item type {}'.format(i, items[i][0], items[i][1]))