Skip to content

Instantly share code, notes, and snippets.

View 573's full-sized avatar

Daniel Kahlenberg 573

View GitHub Profile
@hofmannsven
hofmannsven / README.md
Last active November 22, 2025 10:31
Git CLI Cheatsheet
rainSolver = solve 0 . zipWithRightMax
zipWithRightMax xs = zip xs maxVals
where
rev = reverse xs
(maxVals, _) = foldl maxFold ([], head rev) rev
maxFold (acc, maxVal) x = (maxVal:acc,maxFromHere)
where
maxFromHere = max maxVal x
@pavelfatin
pavelfatin / README.md
Last active February 11, 2018 16:28
Solutions to the Twitter rain puzzle
@aaronsaunders
aaronsaunders / nix-cheat.sh
Last active January 25, 2021 06:54
Quick reference for nix command line commands that I can never remember...
# Unix shell
# run if zero exit
cd tmp/a/b/c && tar xvf ~/archive.tar # untar if dir exists
# run if non-zero exit
cd tmp/a/b/c || mkdir -p tmp/a/b/c
cd tmp/a/b/c || mkdir -p tmp/a/b/c && tar xvf -C tmp/a/b/c ~/archive.tar
which
whereis
@timyates
timyates / Currying.java
Last active March 7, 2020 07:11
Currying and composition in Java 8
package java8tests ;
import java.util.function.BiFunction ;
import java.util.function.Function ;
public class Currying {
public void currying() {
// Create a function that adds 2 integers
BiFunction<Integer,Integer,Integer> adder = ( a, b ) -> a + b ;
@NicolasT
NicolasT / dsl.hs
Last active December 30, 2015 12:59
Adding checked exceptions to a DSL based on a free monad using datatypes-a-la-carte
{-# LANGUAGE DeriveFunctor,
TypeOperators,
FlexibleContexts,
ScopedTypeVariables #-}
module Main where
import Control.Monad.Free
import Data.Comp
@edofic
edofic / Conway.hs
Last active December 31, 2015 10:09
conway's game of life in haskell. inspired by a coderetreat event
module Conway where
import qualified Data.Set as Set
import Control.Concurrent (threadDelay)
type Entry = (Integer, Integer)
newtype Field = Field { getField :: (Set.Set Entry) } deriving Eq
emptyField :: Field
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
@lukesampson
lukesampson / sudo_debug.ps1
Last active November 15, 2019 03:32
Debug script for sudo.ps1 (psutils)
# to debug sudo problems.
# to download:
# (new-object net.webclient).downloadfile('https://gist.githubusercontent.com/lukesampson/9130445/raw/sudo_debug.ps1', "$pwd/sudo_debug.ps1")
# to test:
# ./sudo_debug.ps1 echo hi
if(!$args) { "usage: sudo <cmd...>"; exit 1 }
function is_admin {
write-host "DEBUG: is_admin"
$id = [security.principal.windowsidentity]::getcurrent()
data Shape (rank :: Nat) a where
Nil :: Shape Z a
(:*) :: !(a) -> !(Shape r a ) -> Shape (S r) a
{-# INLINE reverseShape #-}
reverseShape :: Shape n a -> Shape n a
reverseShape Nil = Nil
reverseShape list = go SZero Nil list
where
go :: SNat n1 -> Shape n1 a-> Shape n2 a -> Shape (n1 + n2) a