Skip to content

Instantly share code, notes, and snippets.

View lukego's full-sized avatar

Luke Gorrie lukego

View GitHub Profile
@lukego
lukego / gist:a88764ea77637c747b6cc4b859f26856
Created December 10, 2023 10:53
KernelAbstractions.jl error with oneAPI / Thinkpad / NixOS
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.9.3 (2023-08-24)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using KernelAbstractions
@lukego
lukego / bm.jl
Last active November 1, 2023 15:33
Julia benchmark from slack
using Random: rand!
using LoopVectorization: @turbo
function test_fct(vec_, r1, r2)
xx = vec_
rand!(r1)
rand!(r2)
for j in 1:11
@turbo for i in eachindex(xx, r1, r2)
xx[i] = xx[i] < r1[i] ? r2[i] : xx[i]
@lukego
lukego / gist:4746bcc8cf5ec9409411e677808e9d0e
Created March 30, 2023 11:41
DEFMODEL line expansion
(defun line
(observations
&key (n-particles 100) (steps 100)
(jitter-scales '(0.01d0 0.35d0 1.0d0)))
"Linear relationship between X and Y with Gaussian noise of constant scale:
y ~ m*x + c + N(0,σ)
Infers parameters M (gradient), C (intercept), and σ (standard deviation.)"
(let ((#:m (init-parameter-vector n-particles -10.0d0 10.0d0))
(#:c (init-parameter-vector n-particles -10.0d0 10.0d0))
(#:σ (init-parameter-vector n-particles 1.1102230246251568d-16 5.0d0)))
{
description = "NuddyCAD";
inputs.nixpkgs.url = "nixpkgs";
inputs.nix-cl.url = "github:lukego/nix-cl/trial";
outputs = { self, nixpkgs, nix-cl }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
sbcl = nix-cl.packages.x86_64-linux.sbcl.withPackages (ps:
with ps; [
# Generic
#!/usr/bin/env -S awk -f
/BUILD FAILED: Error while trying to load definition for system/ { print("load-definition-for-system"); next }
/BUILD FAILED: Filesystem error with pathname/ { print("filesystem-error-with-pathname"); next }
/BUILD FAILED: Implementation not supported./ { print("implementation-not-supported"); next }
/BUILD FAILED: Java exception/ { print("java-exception"); next }
/BUILD FAILED: No specification defined for current paltform/ { print("no-specification"); next }
/BUILD FAILED: Permission denied/ { print("permission-denied"); next }
/BUILD FAILED: Subprocess/ { print("subprocess"); next }
/BUILD FAILED: Unable to determine Python include directory/ { print("python"); next }
(defpackage :nixpkgs-lisp-survey
(:nicknames :survey)
(:use :common-lisp :alexandria :serapeum))
(in-package :nixpkgs-lisp-survey)
;;;; Conditions
(define-condition build-error (error)
((transcript :initarg :transcript :accessor transcript)))
(define-condition library-load-error (build-error)
@lukego
lukego / hetzner-ex43-nixos.sh
Created October 14, 2022 07:20
Script to run on Hetzner rescue system to install NixOS (tested EX43)
#!/usr/bin/env bash
# Installs NixOS on a Hetzner server, wiping the server.
#
# This is for a specific server configuration; adjust where needed.
#
# When the script is done, make sure to boot the server from HD, not rescue mode again.
# Explanations:
#
@lukego
lukego / 0model.txt
Last active September 27, 2022 18:34
SMT-LIB model for chess board with dominos problem
;; Output after running with d30a/d30b removed i.e. one less domino.
;; Cleaned up slightly (whitespace and variable ordering)
sat
(
(define-fun d0a () Int 2)
(define-fun d0b () Int 3)
(define-fun d1a () Int 4)
(define-fun d1b () Int 5)
(define-fun d2a () Int 6)
(define-fun d2b () Int 7)
[luke@snowy:~/git/nixpkgs-lisp]$ nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
this path will be fetched (0.03 MiB download, 0.13 MiB unpacked):
/nix/store/q96f9vhis0xk06giw304f9r7hjasxrkw-nixpkgs-review-2.6.4
copying path '/nix/store/q96f9vhis0xk06giw304f9r7hjasxrkw-nixpkgs-review-2.6.4' from 'https://cache.nixos.org'...
$ git -c fetch.prune=false fetch --no-tags --force https://github.com/NixOS/nixpkgs master:refs/nixpkgs-review/0
remote: Enumerating objects: 2926, done.
remote: Counting objects: 100% (1511/1511), done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 2926 (delta 1471), reused 1495 (delta 1462), pack-reused 1415
Receiving objects: 100% (2926/2926), 10.42 MiB | 3.12 MiB/s, done.
{ stdenv
, lib
, cacert
, curl
, runCommandLocal
, targetPlatform
, unzip
, appimage-run
, addOpenGLRunpath
, libGLU