Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
@J0J0
J0J0 / glue.sh
Created April 5, 2023 09:59
Script to join many mp3 files into fewer ones (without re-encoding)
#!/bin/zsh
# first argument: number of files to join into new one, default 5
num=${1:-5}
tmpdir=$(mktemp --directory)
outdir=$(date +"%Y-%m-%d_%H-%M")
mkdir $outdir
ls > $tmpdir/files
-- A simple whireshark dissector for GfxTablet's UDP packages, see
-- https://github.com/rfc2822/GfxTablet and
-- https://github.com/rfc2822/GfxTablet/blob/master/doc/protocol.txt
gfxtablet_proto = Proto("gfxtab", "GfxTablet protocol")
function gfxtablet_proto.dissector(buf, pinfo, tree)
pinfo.cols.protocol = "GFXTAB"
local t = tree:add(gfxtablet_proto, buf(), "GfxTablet Protocol Data")
@J0J0
J0J0 / example.tex
Last active November 18, 2016 18:42
\documentclass[11pt,a4paper,ngerman]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{scoretable}
\newcommand{\task}[1]{\section*{Aufgabe #1}\addscoretableentry{#1}}
\newcommand{\ctask}[2]{\section*{#1}\addscoretableentry{#2}}
\newcommand{\notask}{\addscoretableentrycrossed}
(****************************************)
(* datatypes and functional programming *)
(****************************************)
(* We can define (inductive) datatypes like in Haskell
(where 'Set' corresponds to Haskell's '*')
*)
Inductive mynat : Set
:= zero : mynat | plus1 : mynat -> mynat.
@J0J0
J0J0 / both.v
Last active January 20, 2016 08:10
Require Import List.
Import ListNotations.
Definition head := hd_error.
Definition tail := tl.
Definition len := length.
(* make the type parameter "invisible" to the user,
e.g. the type of 'len' is
list ?1 -> nat
@J0J0
J0J0 / foo.hs
Created September 22, 2014 12:53
fibs :: (Integral a) => [a]
fibs = 1 : 1 : zipWith (+) fibs (tail fibs)
--https://projecteuler.net/problem=2
problem2 :: (Integral a, Integral b) => a -> b
problem2 n
| n <= 1 = 0
| otherwise = sum (filter even (takeWhile (<= (fromIntegral n)) fibs))
answer = problem2 (4*10^6)
#!/usr/bin/env ruby
require 'yaml'
f = ARGV.shift || exit(1)
y = YAML.load_file(f)
def make_cmd(article_file, article_name, editor_name)
fields = [ "#{article_file}.tex".ljust(33),
@J0J0
J0J0 / main.hs
Last active August 29, 2015 14:02
import System.Environment (getArgs)
data Dir = U | R deriving(Show)
type Link = [Dir]
shuf :: Link -> Int -> Int -> [Link]
shuf ds 0 0 = [ds]
shuf ds 0 q = shuf (R:ds) 0 (q-1)
shuf ds p 0 = shuf (U:ds) (p-1) 0
shuf ds p q =
#!/usr/bin/env ruby
# encoding: utf-8
f = ARGV[0] || exit(1)
# get page count
n = `pdfinfo #{f} | grep Pages | cut -d":" -f2`.strip.to_i
# create empty page
`cd /tmp && convert -page A4 xc:white __blankpage.pdf`