Skip to content

Instantly share code, notes, and snippets.

@ChadSki
ChadSki / conda-cuda-fhs-nix-flake-shell.md
Last active December 26, 2023 07:43
Nix flake shell with conda and cuda in an FHS user environment

Run NIXPKGS_ALLOW_UNFREE=1 nix develop --impure to enter the shell, then conda update conda.

@ChadSki
ChadSki / cross-build-nix-ppc64le.bash
Created March 8, 2023 05:52
Steps for cross-compiling Nix 2.8 for ppc64le
# Get a ppc64le-compatible branch and build cross (this takes a long time)
git clone https://github.com/ChadSki/nixpkgs.git -b nixos-22.05-small-ppc64le
nix-build './nixpkgs' -A pkgsCross.powernv.nix
# Get a donor copy of the installer
wget https://releases.nixos.org/nix/nix-2.8.1/nix-2.8.1-x86_64-linux.tar.xz
tar xf nix-2.8.1-x86_64-linux.tar.xz
# Copy the cert package to our new installer
mkdir -p nix-2.8.1-ppc64le-linux/store
@ChadSki
ChadSki / build_deb.sh
Created November 28, 2022 17:55
build_deb
#!/usr/bin/env bash
# Toggle for debug echoing
# set -x
# Turn some bugs into errors
set -o errexit -o pipefail -o noclobber -o nounset
# Shellcheck is a utility which checks bash scripts for common errors and weak
# points in the language. If you need to suppress an error, put a suppression
while [ true ]; do
while [ $(jobs | wc -l) -ge 4 ]; do
echo sleep
sleep 2
done
echo "smoke"
(sleep 10; echo "fire") &
done
@ChadSki
ChadSki / alloc_test.fs
Created July 6, 2019 00:03
allocation test
open System
// returns: median value of a list
let inline median input =
let sorted = input |> Seq.toArray |> Array.sort
let m1,m2 =
let len = sorted.Length-1 |> float
len/2. |> floor |> int, len/2. |> ceil |> int
(sorted.[m1] + sorted.[m2] |> float)/2.
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
open System
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Graphics
type Tile = Grass | Rock | Sand
type GameState = {
@ChadSki
ChadSki / mywindow.py
Created April 8, 2017 02:11
Python 3 WndClass example
import win32api
import win32con
import win32gui
from ctypes import windll, pointer
from ctypes.wintypes import MSG
class MyWindow:
@ChadSki
ChadSki / winapp.py
Created April 7, 2017 08:11 — forked from mouseroot/winapp.py
Win32 CreateWindow example in python
from ctypes import *
from ctypes.wintypes import *
WNDPROCTYPE = WINFUNCTYPE(c_int, HWND, c_uint, WPARAM, LPARAM)
WS_EX_APPWINDOW = 0x40000
WS_OVERLAPPEDWINDOW = 0xcf0000
WS_CAPTION = 0xc00000
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import (
QTreeView, QListView, QFileSystemModel, QApplication)
class Main(QTreeView):
def __init__(self):
QTreeView.__init__(self)
# self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
model = QFileSystemModel()
model.setRootPath('C:\\')
Red/System [
Title: "Hello"
File: %messagebox.reds
]
; --- lib imports -----
#import [
"user32.dll" stdcall [
MessageBox: "MessageBoxA" [