Skip to content

Instantly share code, notes, and snippets.

View sorki's full-sized avatar
🦊
Tying the Knots

Sorki sorki

🦊
Tying the Knots
View GitHub Profile
@sorki
sorki / Simple.hs
Created May 12, 2020 12:24
ircbot-simple
{-# LANGUAGE OverloadedStrings #-}
-- | Simple wrapper on top of simpleBot
-- adding applicative parser
-- and `runBotWithParts` shorthand.
--
-- `runBotWithParts` allows passing
-- initialization function that inits
-- all bot parts and returns them as list.
@sorki
sorki / overlay.nix
Last active May 12, 2020 09:20
ghcjs
self: super:
let src = "https://github.com/sorki/git-post-receive/archive/master.tar.gz";
ovr = (import "${builtins.fetchTarball src}/overlay.nix");
in {
haskellPackages = super.haskellPackages.override (old: {
overrides = super.lib.composeExtensions (old.overrides or (_: _: { }))
ovr;
});
ghcjs = super.haskell.packages.ghcjs.override {
overrides = helf: huper: (ovr helf huper // (with self.haskell.lib; {
@sorki
sorki / Chan.hs
Created May 10, 2020 10:16
zreChan
module Network.ZRE.Chan (
zreChan
) where
import Control.Monad.IO.Class (liftIO)
import Control.Concurrent.STM (TChan)
import Data.Serialize (Serialize)
import Data.ZRE (Group)
import qualified Control.Concurrent
@sorki
sorki / dctest.nix
Created May 1, 2020 07:40
Discourse test
{ config, pkgs, lib, ... }:
let
nixpkgs = /home/srk/git/nixpkgs;
in
{
imports =
[
"${nixpkgs}/nixos/modules/services/web-apps/discourse.nix"
];
@sorki
sorki / default.nix
Created April 8, 2020 17:43
static futhark
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc883" }:
let
futhark = nixpkgs.haskell.packages.${compiler}.futhark;
in
nixpkgs.haskell.lib.overrideCabal
futhark
( oldDrv: {
isLibrary = false;
enableSharedExecutables = false;
enableSharedLibraries = false;
@sorki
sorki / bin2elf.sh
Last active March 18, 2020 11:39
bin2elf
#!/usr/bin/env bash -x
CROSS_PREFIX=arm-none-eabi-
${CROSS_PREFIX}ld -b binary -r -o raw.elf DiscoveryAudioUSB.bin
${CROSS_PREFIX}objcopy --rename-section .data=.text \
--set-section-flags .data=alloc,code,load raw.elf
${CROSS_PREFIX}ld raw.elf -T stm32_flash.ld -o usbaudio.elf
${CROSS_PREFIX}strip -s usbaudio.elf
@sorki
sorki / Main.hs
Created March 4, 2020 18:38
cachix no clobber
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad
import qualified Data.ByteString.Char8 as BSC
import System.Nix.Internal.StorePath
import Network.HTTP.Client
@sorki
sorki / virt-manager-udev.nix
Created February 11, 2020 20:37
virt-manager udev
services.udev.extraRules = ''
# Access to /dev/bus/usb/* devices. Needed for virt-manager USB
# redirection.
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="wheel"
# fine grained
#SUBSYSTEM=="usb", ATTR{idVendor}=="0925", ATTR{idProduct}=="3881", GROUP="users", MODE="0777"
'';
@sorki
sorki / conf.nix
Last active February 7, 2020 13:42
overlays prototype
hardware.deviceTree.overlays = [
{ name = "spi"; dtsFile = ./dt/spi.dts; }
{ name = "pps";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "raspberrypi";
fragment@0 {
@sorki
sorki / Cidl.hs
Last active November 25, 2019 17:48
ReflowReg
reflowDict :: Dict
reflowDict = dict "reflow" $ do
at 0x6000 $ field "temperature" float & ro
at 0x6001 $ field "temperature_target" float
at 0x6002 $ field "control_effort" float & ro
at 0x6100 $ field "pid_p" float
at 0x6101 $ field "pid_i" float
at 0x6102 $ field "pid_d" float
at 0x61FF $ field "pid_reset" bool