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
@gdeest
gdeest / Main.hs
Created January 17, 2021 11:37
Example nested generic Servant API
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE RankNTypes #-}
@duairc
duairc / net.nix
Last active April 16, 2024 00:28
IP address arithmetic and validation in Nix
{ lib ? null, ... }:
let
net = {
ip = {
# add :: (ip | mac | integer) -> ip -> ip
#
# Examples:
@jkachmar
jkachmar / Main.hs
Last active May 19, 2022 13:20
"Simple" example for how to set up Servant to automatically retry its client requests
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
@domenkozar
domenkozar / kiosk-chromium.nix
Last active January 24, 2024 14:05
Boot NixOS into chromium kiosk (tested on NixOS 14.04)
services.xserver = {
enable = true;
monitorSection = ''
Option "NODPMS"
'';
serverLayoutSection = ''
Option "BlankTime" "0"
Option "DPMS" "false"
'';
displayManager.auto.user = "guest";
@jb55
jb55 / default.nix
Last active July 30, 2023 21:45
deploy dotnet core apps on nixos
{ stdenv, lib, bash, callPackage, writeText, makeWrapper, writeScript, dotnet-sdk,
patchelf, libunwind, coreclr, libuuid, curl, zlib, icu }:
let
config = "Staging";
project = "RazorCx.Api";
target = "linux-x64";
rpath = stdenv.lib.makeLibraryPath [ libunwind coreclr libuuid stdenv.cc.cc curl zlib icu ];
@clefru
clefru / etc-nixos-configuration.nix
Created January 10, 2018 12:07
my ZFS kernel overrides for nixos
boot.kernelPackages =
let origKernel = pkgs.linux_4_14;
k10temp = {
name = "k10temp restructure";
patch = ./k10temp.diff;
};
ryzenPatch = {
name = "Ryzen temperature support";
patch = ./ryzen-temp.diff;
};
@abhin4v
abhin4v / astar.hs
Last active November 24, 2022 06:36
A* (A star) search in haskell
import qualified Data.PQueue.Prio.Min as PQ
import qualified Data.HashSet as Set
import qualified Data.HashMap.Strict as Map
import Data.Hashable (Hashable)
import Data.List (foldl')
import Data.Maybe (fromJust)
astarSearch :: (Eq a, Hashable a) => a -> (a -> Bool) -> (a -> [(a, Int)]) -> (a -> Int) -> Maybe (Int, [a])
astarSearch startNode isGoalNode nextNodeFn heuristic =
astar (PQ.singleton (heuristic startNode) (startNode, 0))
@cincodenada
cincodenada / logsb
Created November 2, 2013 01:39
A quick alias in irssi to save the scrollback log to a file. I recently turned on logging (/set autolog ON), and wanted to save what scrollback I'd kept as well. After some reading up, this should add the /logsb command, which stores logs for the current channel in the same place as the default logging, in files tagged .scrollback.log. The alias…
/alias logsb lastlog -file ~/irclogs/${tag}/${C}.${F}_${Z}.scrollback.log
@misaelnieto
misaelnieto / live-mjpeg-stream.py
Last active April 25, 2024 03:22
Streaming MJPEG over HTTP with gstreamr and python - WSGI version
#!/usr/bin/python
#based on the ideas from http://synack.me/blog/implementing-http-live-streaming
# Updates:
# - 2024-04-24: Apply suggestions from @Pin80
# Run this script and then launch the following pipeline:
# gst-launch videotestsrc pattern=ball ! video/x-raw-rgb, framerate=15/1, width=640, height=480 ! jpegenc ! multipartmux boundary=spionisto ! tcpclientsink port=9999
#updated command line
#gst-launch-1.0 videotestsrc pattern=ball ! videoconvert ! video/x-raw, framerate=15/1, width=640, height=480 ! jpegenc ! multipartmux boundary=spionisto ! #tcpclientsink port=9999
from multiprocessing import Queue