Skip to content

Instantly share code, notes, and snippets.

View ners's full-sized avatar
❄️

ners ners

❄️
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ners on github.
  • I am ners (https://keybase.io/ners) on keybase.
  • I have a public key ASCQIaOM_M-oH7LHS-KjRX_g6GkkYGLyCgxljQYqcm060wo

To claim this, I am signing this object:

import Control.Parallel.Strategies ( parListChunk, rdeepseq, using )
import Data.List ( any, genericLength, group, sort, sortBy )
import Data.Set ( deleteFindMin, fromList, insert )
digits :: Integer -> [Integer]
digits 0 = [0]
digits n = (n `mod` 10) : if n > 9 then digits (n `div` 10) else []
nextTerm :: Integer -> Integer
nextTerm n = foldl (\acc (a, b) -> acc * 100 + a * 10 + b) 0 gs
I’ve come to realize that understanding pointers in C is not a skill, it’s an aptitude. In first year computer science classes, there are always about 200 kids at the beginning of the semester, all of whom wrote complex adventure games in BASIC for their PCs when they were 4 years old. They are having a good ol’ time learning C or Pascal in college, until one day the professor introduces pointers, and suddenly, they don’t get it. They just don’t understand anything any more. 90% of the class goes off and becomes Political Science majors, then they tell their friends that there weren’t enough good looking members of the appropriate sex in their CompSci classes, that’s why they switched. For some reason most people seem to be born without the part of the brain that understands pointers. Pointers require a complex form of doubly-indirected thinking that some people just can’t do, and it’s pretty crucial to good programming. A lot of the “script jocks” who started programming by copying JavaScript snippets into t
@ners
ners / setup.sh
Last active May 23, 2019 12:20
Better Shell 2019: Fedora Edition
# install zsh
sudo dnf install zsh zsh-syntax-highlighting
sudo chsh -s $(which zsh) $USER
# configure zsh
curl -sSL https://git.grml.org/f/grml-etc-core/etc/zsh/zshrc > ~/.zshrc
cat << EOF > ~/.zshrc.local
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ~/.profile
EOF
@ners
ners / PeanoPrimes.hs
Last active July 25, 2019 15:57
Type-checked prime numbers
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeInType #-}
import qualified Prelude as P
@ners
ners / Shake.hs
Last active October 19, 2020 12:11
Recursively look for FLAC files and convert them to AAC, retaining metadata.
import Control.Monad
import Control.Monad.Extra
import Development.Shake
import Development.Shake.Command
import Development.Shake.FilePath
import Development.Shake.Util
main :: IO ()
main = shakeArgs shakeOptions { shakeFiles = ".shake" } $ do
want ["aac"]
import System.Environment
data Token = Token
{ row :: Int
, col :: Int
, val :: Char
} deriving (Ord, Eq, Show)
tokenise :: String -> [Token]
tokenise = tok 1 1
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Arrow ( (&&&) )
import Data.Data
( ConstrRep (AlgConstr)
, Data
, cast
@ners
ners / Makefile
Created October 2, 2020 14:37
Create Fedora ARM VM
VM_NAME ?= fc32-arm-devel
VM_SIZE ?= 10G
all: run
run: prepare
virsh list | grep -q ${VM_NAME} || virsh start ${VM_NAME}
virsh console ${VM_NAME} --safe
prepare: Fedora-Minimal-armhfp-32-1.6-sda.qcow2 vmlinuz-5.6.6-300.fc32.armv7hl initramfs-5.6.6-300.fc32.armv7hl.img
New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation -Name RealTimeIsUniversal -PropertyType DWORD -Value 1
powerfcg -h off