Skip to content

Instantly share code, notes, and snippets.

View corpix's full-sized avatar
👹
Fighting demons

corpix corpix

👹
Fighting demons
View GitHub Profile
@corpix
corpix / numbers.nix
Last active February 7, 2024 01:42
pow, decimal to hex, hex to decimal in nix language
{ lib }:
with lib; rec {
pow =
let
pow' = base: exponent: value:
# FIXME: It will silently overflow on values > 2**62 :(
# The value will become negative or zero in this case
if exponent == 0
then 1
else if exponent <= 1
@corpix
corpix / Makefile
Last active October 25, 2023 18:25
prepare host for nixos
latest-nixos-minimal-x86_64-linux.iso:
wget https://channels.nixos.org/nixos-20.03/latest-nixos-minimal-x86_64-linux.iso
curl -Ls https://channels.nixos.org/nixos-20.03/latest-nixos-minimal-x86_64-linux.iso.sha256 \
| grep -F .iso | head -n1 \
| sed 's|nixos-minimal-.\+|latest-nixos-minimal-x86_64-linux.iso|' \
| sha256sum -c -
root.img:
qemu-img create root.img 10G
±²³SolveSpaceREVa
Group.h.v=00000001
Group.type=5000
Group.name=#references
Group.color=ff000000
Group.skipFirst=0
Group.predef.swapUV=0
Group.predef.negateU=0
(defun use-ansi-process-filter (process)
(set-process-filter
process
(lambda (process string)
(internal-default-process-filter process string)
(with-current-buffer (process-buffer process)
(save-excursion
(goto-char (point-max))
(let ((previous-point-max (point-max)))
(insert string)
@corpix
corpix / ulisp.el
Last active June 22, 2023 14:50
Emacs Lisp runner to uLisp REPL
(defgroup ulisp-mode nil
"Settings for ulisp-mode Lisp source buffers."
:prefix "ulisp-"
:group 'ulisp)
(defcustom ulisp-port "/dev/ttyUSB0"
"uLisp serial port"
:type 'string
:group 'ulisp-mode)
(defcustom ulisp-port-speed 115200
"uLisp serial port speed bps"
@corpix
corpix / tarantool.nix
Last active August 21, 2022 04:21
Tarantool for NixOS
{ pkgs ? import <nixpkgs> {}, ... }: let
inherit (pkgs)
stdenv
fetchgit
;
tag = "2.10.1";
commit = "482d91c66";
# git describe --long ${version}
version = "${tag}-0-g${commit}";
{ pkgs ? import <nixpkgs> {}, ... }: pkgs.libsForQt5.callPackage ({ pkgs ? import <nixpkgs> {}
, lib
, stdenv
, fetchFromGitHub
, fetchpatch
, cmake
, ninja
, netcdf
, coin3d
, eigen
@corpix
corpix / agola.package.nix
Created July 5, 2022 18:07
AgolaCI Nix integration
{ pkgs ? import <nixpkgs> {} }:
pkgs.buildGoModule {
name = "agola";
src = pkgs.fetchFromGitHub {
owner = "agola-io";
repo = "agola";
rev = "v0.7.0";
sha256 = "sha256-AiD7mVogWk/TOYy7Ed1aT31h1kbrRwseue5qc3wLOCI=";
};
doCheck = false;
@corpix
corpix / luastatic.nix
Created April 24, 2022 13:40
Luastatic nix derivation
{ lua, luaPackages, fetchurl, fetchgit }:
luaPackages.buildLuarocksPackage rec {
pname = "luastatic";
version = "0.0.12";
knownRockspec = (fetchurl {
url = "https://luarocks.org/manifests/ers35/luastatic-${version}-1.rockspec";
sha256 = "sha256-jNxq4gyO+7kN7+Vpvq1iGFrIQ15x+HAkcqa3VqIhUVU=";
}).outPath;
src = fetchgit {
url = "https://github.com/ers35/luastatic";
@corpix
corpix / backbone-router-filter.js
Created March 4, 2012 13:00
Backbone router before,after,leave
(function(Backbone, _) {
var leave;
_.extend(Backbone.Router.prototype, Backbone.Events, {
route : function(route, name, callback) {
var before
, fn = callback
, after;
Backbone.history || (Backbone.history = new Backbone.History);