Skip to content

Instantly share code, notes, and snippets.

View Lifelovinglight's full-sized avatar

Bo Victor Natanael Fors Lifelovinglight

  • Linköping, Sweden
View GitHub Profile
@Lifelovinglight
Lifelovinglight / game-of-life.lisp
Created April 22, 2020 18:20
John Conway's game of life
(declaim (optimize (debug 0) (safety 1) (speed 1)))
(defmacro aref-with-default (default array &rest subscripts)
`(if (array-in-bounds-p ,array ,@subscripts)
(aref ,array ,@subscripts)
,default))
(defmacro iterate-array (dimensions array &rest body)
(labels ((index-symbol (n)
(intern (concatenate 'string "V" (write-to-string n))))
@Lifelovinglight
Lifelovinglight / inotify.scm
Created April 5, 2020 21:56
Automatic binary file patcher.
(require-extension inotify)
(require-extension posix)
(require-extension srfi-37)
;;; Utility functions.
(define (negate fn)
(lambda (a)
(not (fn a))))
@Lifelovinglight
Lifelovinglight / battery.scm
Last active February 13, 2020 16:36
Battery monitoring script.
;;; Battery monitoring daemon script.
(require-extension shell)
(require-extension srfi-1)
;;; Constant values.
;;; Battery level control interval, in seconds.
@Lifelovinglight
Lifelovinglight / Main.frag
Last active March 1, 2020 17:11
work in progress
uniform vec2 resolution;
uniform float zoom, panx, pany;
uniform int depth;
void main(void)
{
// vec2 res = vec2(1366.0, 768.0);
vec2 uv = gl_FragCoord.xy / resolution.xy * zoom;
float scale = resolution.y / resolution.x;
uv=((uv-0.5)*5.5);
@Lifelovinglight
Lifelovinglight / substitution.pl
Created December 19, 2019 03:01
Descramble coded message found in Leather Goddesses of Phobos.
#!/usr/bin/perl -w
use strict;
use warnings;
sub phobosDecrypt {
reverse shift =~ tr/A-Z/X-ZA-W/r;
}
print "Enter encrypted message:\n";
@Lifelovinglight
Lifelovinglight / s4sfortune.pl
Created December 12, 2019 00:46
s4s fortunes for irssi
#!/usr/bin/perl -w
# USAGE:
#
# /FORTUNE
# - Outputs a random fortune.
use strict;
use vars qw($VERSION %IRSSI);
uniform vec2 resolution;
uniform float zoom, panx, pany;
void main(void)
{
// vec2 res = vec2(1366.0, 768.0);
vec2 uv = gl_FragCoord.xy / resolution.xy * zoom;
float scale = resolution.y / resolution.x;
uv=((uv-0.5)*5.5);
uv.y*=scale;
-- Requires installation of SDL2 https://github.com/haskell-game/sdl2
-- and possibly GLUT https://hackage.haskell.org/package/GLUT
-- Using graphics code from https://wiki.haskell.org/OpenGLTutorial1
module Main (main) where
import Control.Monad
import Linear
import Data.StateVar
import Foreign.C.Types (CInt)
unfold :: (a -> Bool) -> (a -> a) -> a -> [a]
unfold stop step init | stop init = []
| otherwise = init : unfold stop step (step init)
modulo = curry $ length . unfold (uncurry (>)) (\dn -> subtract (fst dn) <$> dn)
@Lifelovinglight
Lifelovinglight / kek.hs
Last active December 22, 2018 07:25
stupid juggling
import Control.Applicative
import Data.Monoid
import Control.Monad
import Control.Monad.Loops
main :: IO ()
main = putStrLn =<< intersperse ':' <$> getLines
-- | The class of types that support short-circuiting on e.g. empty, false, error - almost the same as but not quite Alternative
class Circuit a where