Skip to content

Instantly share code, notes, and snippets.

View spacebat's full-sized avatar

Andy Kirkpatrick spacebat

  • Adelaide, South Australia
View GitHub Profile
@andreaseriksson
andreaseriksson / convert_to_verified_routes.ex
Last active March 31, 2024 12:29
This is a mix task for converting old Phoenix routes to new verified routes
defmodule Mix.Tasks.ConvertToVerifiedRoutes do
@shortdoc "Fix routes"
use Mix.Task
@regex ~r/(Routes\.)(.*)_(path|url)\(.*?\)/
@web_module MyAppWeb
def run(_) do
Path.wildcard("lib/**/*.*ex")
; John McCarthy. Puzzle Solving Program in LISP. Memo 20, Artificial Intelligence Project
; http://www.bitsavers.org/pdf/mit/ai/aim/AIM-020.pdf
; 1960
; Common Lisp translation: Rainer Joswig, 2016, joswig@lisp.de
; basically the code is unchanged, but using s-expression syntax in Common Lisp
(defparameter pzl
'((a1 (a2 a5) 7.5)
(a2 (a1 a5 a9 a3) 3.5)
@christhekeele
christhekeele / default_behaviour.ex
Last active April 22, 2024 02:05
Behaviours with Defaults for Elixir
defmodule Default.Behaviour do
@moduledoc """
Creates a behaviour that carries its own default implementation.
When used into a behaviour module, when that module in turn is used, all functions
defined on it are given to the using module.
This allows you to have concrete implementations of the behaviour's default functionality
for testing, unlike cramming them all into a __using__ macro.
@cbaggers
cbaggers / gist:7a0d432e45a71dd024af
Last active December 14, 2019 03:38
Literal HashTable syntax for common lisp
(defmacro hash ((&key (test #'eql) (size 10)
(rehash-size 1.5) (rehash-threshold 1)
(hash-function nil) (weakness nil) synchronized)
&rest keys-vals-plist)
(let ((h (gensym "new-hashmap")))
`(let ((,h (make-hash-table :test ,test :size ,size
:rehash-size ,rehash-size
:rehash-threshold ,rehash-threshold
:hash-function ,hash-function
:weakness ,weakness
@death
death / enamel.lisp
Created April 24, 2013 11:07
Old enamel hack
;;;; Enamel - Erik Naggum's Markup Language
;;;
;;; See http://xach.com/naggum/articles/3207626455633924@naggum.net.html
;;;
(define-condition malformed-enamel (error) ())
(defun parse-enamel (in &key (case :upcase) (strip-newlines t) (distinguish-attributes nil) (package *package*))
(let ((node '()))
(labels ((skip-ws () (peek-char t in nil))
@viktorklang
viktorklang / Actor.java
Last active February 13, 2023 12:13
Minimalist Java Actors
/*
Copyright 2012-2021 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@wki
wki / css_parser.pl
Created December 22, 2011 19:48
Sample CSS Parser using Marpa::XS
use strict;
use warnings;
use feature ':5.10';
use Marpa::XS;
use Data::Dumper;
#
# a simple CSS snippet for testing
#
my $text = q{