Skip to content

Instantly share code, notes, and snippets.

View bynect's full-sized avatar

nect bynect

  • Laniakea Supercluster
  • 22:00 (UTC +02:00)
View GitHub Profile
@bynect
bynect / memfrob.cu
Created August 22, 2025 15:08
memfrob implementation in cuda
#include <cuda_runtime.h>
__global__ void frobnicator(unsigned char *dev, int n) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < n)
dev[tid] ^= 42;
}
void *cuda_memfrob(void *mem, size_t n)
{
@bynect
bynect / .zshenv
Last active August 21, 2025 22:18
.zshrc
ZDOTDIR=$HOME/.config/zsh
. $HOME/.local/share/cargo/env
@bynect
bynect / vect.hs
Created July 16, 2025 22:36
GADT shenanigans in Haskell
{-# LANGUAGE DataKinds, StandaloneKindSignatures, GADTs,
StandaloneDeriving, DerivingStrategies, ScopedTypeVariables,
TypeOperators, TypeFamilies, ConstraintKinds,
FlexibleInstances, MultiParamTypeClasses,
IncoherentInstances, UndecidableSuperClasses,
TypeApplications, AllowAmbiguousTypes,
ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wall -Wno-unticked-promoted-constructors -Wno-unused-imports #-}
module Main where
@bynect
bynect / oper.hs
Created July 16, 2025 22:12
Operator fixup (experimental)
{- vim: set sw=2 ts=2 et: -}
import qualified Data.Map as Map
import Data.Map (Map)
import Control.Monad.Fail
data Expr = Var String
| Infixes [String] Expr Expr
| Infix String Expr Expr
| Prefix String Expr
@bynect
bynect / proxy.rs
Created July 16, 2025 22:06
Basic async proxy in Rust
use std::time::Instant;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpListener;
use tokio::net::TcpStream;
#[tokio::main]
async fn main() {
let listener = TcpListener::bind("0.0.0.0:9000").await.unwrap();
loop {
let (mut client, addr) = listener.accept().await.unwrap();
@bynect
bynect / dwm-ipc-test.c
Created July 16, 2025 19:39
Test for interfacing with dwm-ipc protocol
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
@bynect
bynect / bar.c
Created July 16, 2025 19:14
Simple bar for Xorg
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_ewmh.h>
#include <cairo.h>
@bynect
bynect / topbit.c
Created February 15, 2025 01:31
topbit.c
#include <stdint.h>
#include <string.h>
//static_assert(sizeof(void *) == sizeof(uintptr_t), "Funky libc not allowed");
//static_assert(sizeof(void *) == sizeof(uint64_t), "Only works on amd64");
// We want to represent different values
//
diff --git a/data/autosuspend.hwdb b/data/autosuspend.hwdb
index 43e996d..b559632 100644
--- a/data/autosuspend.hwdb
+++ b/data/autosuspend.hwdb
@@ -163,6 +163,7 @@ usb:v04F3p0C99*
usb:v04F3p0C00*
usb:v04F3p0C4C*
usb:v04F3p0C5E*
+usb:v04F3p0C90*
ID_AUTOSUSPEND=1
@bynect
bynect / xrandr-multi-layout.sh
Created June 5, 2024 11:33
Xrandr multi screen auto setup
#!/bin/bash
#
# Layout and Resolution
# NOTE: Equivalent settings set in xorg.conf
# NOTE: Never mind, xorg.conf is way too convoluted
SCREEN_NO="$(xrandr --query | grep '\bconnected\b' | wc -l)"
echo "Setting up $SCREEN_NO screen(s) with xrandr"