Skip to content

Instantly share code, notes, and snippets.

@magthe
magthe / funcs.el
Created Nov 21, 2020
JSON execution in orgmode's babel
View funcs.el
(defun org-babel-execute:json (body params)
body)
View test-01.hs
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad (unless, void)
import Control.Monad.IO.Class
import Data.Aeson
import qualified Data.Map as M
import Data.Maybe (isJust)
import Data.Text (Text)
import Hedgehog
View test-01.hs
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad (unless, void)
import Control.Monad.IO.Class
import Data.Aeson
import qualified Data.Map as M
import Data.Maybe (isJust)
import Data.Text (Text)
import Hedgehog
@magthe
magthe / Part1.hs
Created Dec 18, 2017
AoC 2017, day 16
View Part1.hs
import Control.Applicative
import Data.Monoid
import Data.Vector as V
import Prelude as P
import Text.ParserCombinators.ReadP
spinList :: Int -> Vector Char -> Vector Char
spinList n xs = let (h, t) = V.splitAt (l - n) xs
l = V.length xs
in t <> h
View keybase.md

Keybase proof

I hereby claim:

  • I am magthe on github.
  • I am magthe (https://keybase.io/magthe) on keybase.
  • I have a public key ASCF3PyaMhJU-BVsk0bF9gjQ7DSJv5NYmbYFRvBjwJtWlgo

To claim this, I am signing this object:

View Free1.hs
{-# LANGUAGE DeriveFunctor#-}
-- Simple example of using Free with a single algebra/API.
module Free1 where
import Control.Monad.Free
data SimpleFileF a
= LoadFile FilePath (String -> a)
@magthe
magthe / core.cljs
Created Apr 11, 2016
Quil load-image failing
View core.cljs
(ns bg.core
(:require [quil.core :as q :include-macros true]
[quil.middleware :as m]
[bg.image :as i]))
(enable-console-print!)
(println "bg.core loaded")
(defn setup []
(let [img (q/load-image i/img)]
@magthe
magthe / CMakeLists.txt
Last active Dec 13, 2020
Complete example of D-BUS client and server using Qt5 and CMake.
View CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(DBusTest)
find_package(Qt5 CONFIG REQUIRED Core DBus)
set(prog_SRCS my.test.Calculator.xml)
qt5_generate_dbus_interface(Calc.hh
my.test.Calculator.xml
OPTIONS -A
)
@magthe
magthe / nooo
Created May 21, 2015
Not Only OO
View nooo
Vi upptäcker bättre sätt att utveckla mjukvara genom att göra det och genom
att hjälpa andra att göra det. Genom detta arbete har vi lärt oss värdesätta:
* *Funktioner och Typer* mer än klasser
* *Renhet* mer än mutation
* *Komposition* mer än arv
* *Högre ordningens funktioner* mer än metodbindning
* *Options* mer än nulls
Det betyder att det finns värde i sakerna till höger (förutom null), men vi
@magthe
magthe / bbwp.hs
Last active Aug 29, 2015
Bye bye WordPress
View bbwp.hs
#! /usr/bin/env runhaskell
-- {{{1 imports
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Time.Format
import Data.Time.LocalTime
import System.Directory
import System.Environment