View rps.pbl
% Rock, Paper, Scissors in problog. | |
% Editor URL: https://dtai.cs.kuleuven.be/problog/editor.html#task=prob&hash=462b1ed73475d1bbd67dbc1f6d503a4c | |
1/3::rock(X); 1/3::paper(X) ; 1/3::scissors(X) :- rps(X). | |
%1/5::rock(X); 1/5::paper(X) ; 1/5::scissors(X) ; 1/5::lizard(X); 1/5::spock(X) :- rpslk(X). | |
rps(X) :- between(1,11,X). | |
%rps(1). | |
%rps(2). | |
%rps(3). | |
View wormhole.jl
# Script to run magic-wormhole (see https://github.com/warner/magic-wormhole) from Julia repl | |
# Author: Dieter Castel | |
# Installing requirements once. | |
# Meanwhile refactored into: https://github.com/dietercastel/Wormhole.jl | |
]add Conda | |
]add PyCall | |
using Conda | |
using PyCall | |
Conda.add("magic-wormhole",channel="conda-forge") | |
# Good to go using PyCall. |
View osm_tiles_downloader
#!/usr/local/bin/python3 | |
# Initially converted with 2to3.py and then tweaked at bit | |
# from the original script by tonyrewin at https://gist.github.com/tonyrewin/9444410 | |
# Author: tonyrewin & Dieter Castel | |
from sys import argv | |
import os | |
import math | |
import urllib.request, urllib.error, urllib.parse | |
import random | |
import os.path |
View bw2NewColor.py
# This script coverts a black & white image to an image with new colors. | |
from PIL import ImageOps, Image | |
imgPath = "testImg.png" | |
blackColor = (255,0,0,0) | |
whiteColor = (0,0,0,255) | |
img = Image.open(imgPath).convert("L") | |
# Black pxl, white pxl | |
newImg = ImageOps.colorize(img,blackColor,whiteColor) | |
#ImageOps.crop(newImg,border=55).show() | |
newImg.show() |
View MoveScreenshots.jl
fromdir = "." # cd to e.g. the Desktop. | |
# Filters the read in directory | |
t = filter(x->startswith(x,"Screenshot"),readdir(fromdir)) | |
# Move every x in t to it's new location. | |
map(x->mv(x,"../screenshots/$x"),t) # x is replaced using string interpolation |
View ApproxBug.jl
using Test | |
alldigits = cat([[0.375297 0.624703]; [0.39924 0.60076]], [[0.664557 0.335443]; [0.664557 0.335443]], dims=3) | |
threedig = map(x -> round(x,digits=3), alldigits) | |
@testset "Testing" begin | |
@test size(alldigits) == size(threedig) | |
@test all(isapprox.(alldigits, threedig, atol=1e-3)) | |
#This one fails??? | |
@test isapprox(alldigits, threedig, atol=1e-3) | |
end |
View shufflefails.jl
#!/usr/local/bin/julia | |
# Author: Dieter Castel | |
# | |
using Match | |
using Random | |
using Distributions | |
using Test | |
# Recursive function generating random numbers that sum to value t. | |
function genRandTot(n,t) |
View findmasterkey.sh
#!/usr/local/bin/fish | |
# | |
# Finds masterkey files of Joplin. | |
echo "Searching: " $argv | |
find "$argv" -name "*.md" -print0 | xargs -0 grep -lrniE "content:|checksum:|encryption_method: 2" |
View logplotrps.jl
#Plot of calculating the win chance for g-player Rock, Paper, Scissors. | |
# A winning RPS game contains exactly two options. | |
#Total amount of options BigInt function | |
tot(g) = 3^BigInt(g) | |
#Winning options BigInt function | |
win(g) = 3*2*(2^(BigInt(g)-1)-1) | |
#Calculate the win chance | |
winchance(g) = win(g)//tot(g) | |
xto(n) = range(3,stop=n) |
View plotrps.jl
#Plot of calculating the win chance for g-player Rock, Paper, Scissors. | |
# A winning RPS game contains exactly two options. | |
#Total amount of options BigInt function | |
tot(g) = 3^BigInt(g) | |
#Winning options BigInt function | |
win(g) = 3*2*(2^(BigInt(g)-1)-1) | |
#Calculate the win chance | |
winchance(g) = win(g)//tot(g) | |
xto(n) = range(3,stop=n) |
NewerOlder