This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Leftpad | |
| open FStar.List.Tot | |
| val replicate : #a:eqtype -> n:nat -> x:a -> out:list a{length out == n /\ count x out == length out} | |
| let rec replicate #a n x = | |
| if n = 0 then [] | |
| else x :: replicate (n - 1) x | |
| val leftpad : #a:eqtype -> n:nat -> x:a -> in_:list a -> out:list a{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module MergeSort | |
| type nat = n:int{n>=0} | |
| val length : l:list 'a -> nat | |
| let rec length l = match l with | |
| | [] -> 0 | |
| | hd :: tl -> 1 + length tl | |
| val count : #a:eqtype -> x:a -> l:list a -> res:nat{res <= length l} |
Nixos, ext4 under luks2 on lvm, luks encrypted boot [1], apparmor, sleep & hibernation support.
Monitor (primarily disk state) & send local mails & check up on zsh login.
Future: RAID 1, deniable encryption.
Daily used apps go through the global config. All the rest goes through nix-shell, zero nix-env -i. Screen locking. Apparmor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace ignore_access_rights { | |
| template<class Ptr, int Id> | |
| Ptr result = nullptr; | |
| template<class Ptr, Ptr Target, int Id> | |
| struct apply { | |
| struct exec { exec() { result<Ptr, Id> = Target; } }; | |
| static exec var; | |
| }; | |
| template<typename Ptr, Ptr Target, int Id> | |
| typename apply<Ptr, Target, Id>::exec apply<Ptr, Target, Id>::var; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE GADTs #-} | |
| import Control.Monad (replicateM, ap) | |
| import Data.List (minimumBy) | |
| import Data.Function (on) | |
| import Data.Monoid | |
| data Vec a where | |
| Vec :: Integral a => a -> a -> Vec a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE OverloadedStrings #-} | |
| import Text.Parsec hiding (token) | |
| import Options.Applicative hiding (many, (<|>), option) | |
| import Data.Monoid | |
| import Data.Maybe | |
| import Control.Monad | |
| import Data.Text.Lazy (unpack) | |
| import Formatting (format, (%), (%.)) | |
| import Formatting.Formatters (left, int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Data.Monoid ((<>)) | |
| import Data.Tuple (fst, snd, swap) | |
| import Data.List (splitAt, isPrefixOf) | |
| import Data.Char (isAlpha) | |
| import Data.Bifunctor (bimap) | |
| import Control.Monad ((=<<), join) | |
| import Control.Applicative (liftA2) | |
| -- Algorithmically, it's bad. | |
| -- It's more of a practice in writing point-free code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include "strhead.h" | |
| void print(const struct str_* s) { | |
| printf("i = %i\n" | |
| "d = %lf\n", s->i, s->d); | |
| } | |
| int main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <utility> | |
| template<class Integer> | |
| Integer nth_fib(const size_t n) { | |
| Integer prev = 1, cur = 1; | |
| if (n < 3) { | |
| cur = [&]() -> Integer { | |
| switch (n) { |