Skip to content

Instantly share code, notes, and snippets.

:- encoding(utf8).
:- use_module(library(apply)).
:- use_module(library(clpfd)).
:- use_module(library(lists)).
:- use_module(library(pairs)).
/*
The Countdown numbers game, solved in Prolog.
https://en.wikipedia.org/wiki/Countdown_(game_show)#Numbers_round
:- encoding(utf8).
:- use_module(library(apply)).
:- use_module(library(lists)).
:- use_module(library(pairs)).
/*
The Countdown numbers game, solved in Prolog.
https://en.wikipedia.org/wiki/Countdown_(game_show)#Numbers_round
- Finds exact solutions only;
@carwash
carwash / miracle.pl
Last active September 5, 2020 18:33
Miracle Sudoku in Prolog
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Miracle Sudoku in Prolog
Marcus Smith
Base sudoku and PostScript animation code by Markus Triska:
https://www.metalevel.at/sudoku/
https://github.com/triska/clpfd
Addtional miracle sudoku constraints:
- Two cells separated by a knight's move or a king's move cannot contain the same digit.
@carwash
carwash / oai-pmh-test.sh
Last active August 5, 2020 09:04
Minimal OAI-PMH harvester, for testing in bash. Uses curl, tee, and xmlstarlet for resumption token support. Usage: `$ oai-pmh-test.sh example.com`
#/usr/bin/env bash
fetch_token() {
file=$1 ; count=$2
tee >(xmlstarlet fo - > "$file-$(printf "%04d" $count).xml") | xmlstarlet sel -N oai="http://www.openarchives.org/OAI/2.0/" --template --match "/oai:OAI-PMH/oai:ListRecords/oai:resumptionToken" --value-of "."
}
server=$1
file=$(echo $server | sed -E 's/^https?:\/\///; s/[\.:\/]/-/g')
count=1
@carwash
carwash / wetransfer.sh
Created August 7, 2019 16:47
Download WeTransfer files from the command line
#!/usr/bin/env bash
# Download WeTransfer files from the command line
# Click to start a download, but then stop it; copy the download URL and paste between 'non-interpolating quotes' as an argument to this script.
# MJS 190807
url=$1
output=$(ack -o '(?<=/)[^/\?]+(?=\?)' <(echo $url))
curl $url --location --output $output
@carwash
carwash / wordstar.pl
Last active August 2, 2018 15:55
Updated Wordstar converter from http://justsolve.archiveteam.org/wiki/WordStar to process all files in a directory.
#!/usr/bin/env perl
use strict;
use warnings;
use Cwd;
opendir(my $dir, $ARGV[0] || cwd);
for my $file (grep {/\.ws$/ && -e -f -s -r join('/', $path, $_)} readdir($dir)) {
my ($name) = $file =~ /^(.+)\.ws$/;
open(my $outfile, '>', "$name.txt");
@carwash
carwash / soch.js
Last active March 26, 2018 18:22 — forked from Abbe98/soch.js
Detta är ett ganska minimalt exempel på användning av SOCH
// Detta är ett ganska minimalt exempel på användning av SOCH
// Notera att det saknas felhantering vid HTTP fel
// Notera även att sochSearch() inte stödjer paginering och att den använder presentationsformatet
// Det går att klistra in detta exempel direkt i webbläsarens konsol
// Det går inte att göra frågor från andra HTTPS resurser
// API-nyckel
const apiKey = 'test';
// hjälp funktion för att göra http frågor och parsa JSON
@carwash
carwash / objekturi2samla.yml
Created December 10, 2017 12:54
URIs of Swedish runic inscriptions, with URIs of articles, monographs and reports in Samla describing/discussing them.
---
# Inscriptions and their litterature in Samla:
http://kulturarvsdata.se/GSM/objekt/513995:
- http://kulturarvsdata.se/raa/fornvannen/1986_073
http://kulturarvsdata.se/raa/bbr/21400000124923:
- http://kulturarvsdata.se/raa/fornvannen/1986_084
http://kulturarvsdata.se/raa/bbr/21400000426484:
- http://kulturarvsdata.se/raa/fornvannen/2007_037
- http://kulturarvsdata.se/raa/samla/6815
http://kulturarvsdata.se/raa/bbr/21400000439956:
@carwash
carwash / objekturi2fornvännen.json
Last active December 10, 2017 10:44
URIs of Swedish runic inscriptions, with URIs of articles in Fornvännen describing/discussing them.
{
"http://kulturarvsdata.se/raa/fmi/10008501120001" : [
"http://kulturarvsdata.se/raa/fornvannen/1953_262"
],
"http://kulturarvsdata.se/raa/fmi/10029300940001" : [
"http://kulturarvsdata.se/raa/fornvannen/1966_021"
],
"http://kulturarvsdata.se/raa/fmi/10038300710001" : [
"http://kulturarvsdata.se/raa/fornvannen/1993_223"
],
@carwash
carwash / keybase.md
Created December 7, 2014 14:17
Verification for keybase.io

Keybase proof

I hereby claim:

  • I am carwash on github.
  • I am carwash (https://keybase.io/carwash) on keybase.
  • I have a public key whose fingerprint is A977 F39E 1A54 16F9 B48B F0CD 2B19 BEAA 8045 BB97

To claim this, I am signing this object: