Skip to content

Instantly share code, notes, and snippets.

View aarroyoc's full-sized avatar

Adrián Arroyo Calle aarroyoc

View GitHub Profile
@aarroyoc
aarroyoc / alien.pl
Created January 27, 2022 12:43
Alien Puzzle
:- use_module(library(dcgs)).
:- use_module(library(clpz)).
hex_number(N) -->
hex(A),
hex(B),
{
N #= B + A*16
}.
@aarroyoc
aarroyoc / soccerdoku.pl
Created June 10, 2021 14:11
Soccerdoku
:- use_module(library(clpz)).
match(L, V, P) :-
L #> V,
P #= 3.
match(L, V, P) :-
L #= V,
P #= 1.
match(L, V, P) :-
L #< V,
@aarroyoc
aarroyoc / Cargo.toml
Created May 20, 2021 20:21
Raylib + Prolog (via Rust)
[package]
name = "gglog"
version = "0.1.0"
authors = ["Adrián Arroyo Calle"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib"]
@aarroyoc
aarroyoc / uuid.pl
Created February 18, 2021 16:53
UUID Prolog Library
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Written in February 2021 by Adrián Arroyo (adrian.arroyocalle@gmail.com)
This library provides reasoning about UUID (only version 4 right now).
There are two predicates:
* uuid/2, to generate a new UUID (only version 4 supported)
* uuid_string/2, to converte between UUID list of bytes and UUID hex representation
Also you have uuid/1, which generates a UUIDv4 as a list of bytes and uuid_string/1
which generates a random UUIDv4 as hex representation
I place this code in the public domain. Use it in any way you want.
@aarroyoc
aarroyoc / day1.pl
Created December 1, 2020 21:04
Advent of Prolog - Day 1
:- use_module(library(pure_input)).
:- use_module(library(dcg/basics)).
input([X|Data]) -->
integer(X),
"\n",
input(Data).
input([]) --> eos.
@aarroyoc
aarroyoc / interpreter.rs
Created August 27, 2014 10:43
interpreter.rs
pub fn interpreter(&mut self,bytecode: &'static str) -> (){
for execbyte in bytecode.chars() {
self.execute(execbyte as u8);
}
}
@aarroyoc
aarroyoc / sparky.py
Created January 19, 2020 22:24
PySpark example
# ~/spark-3.0xxxx/bin/spark-submit sparky.py
from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("test").getOrCreate()
sc = spark.sparkContext
# Word Count
inputfile = sc.textFile("input.txt")
counts = inputfile.flatMap(lambda x: x.split(" ")).map(lambda x: (x, 1)).reduceByKey(lambda x,y: x+y)
counts.saveAsTextFile("output")
@aarroyoc
aarroyoc / build-pcc-deb.sh
Created January 10, 2020 12:49
Debian package for PCC
#!/bin/bash
wget https://github.com/aarroyoc/pcc/archive/master.zip -O pcc.zip
unzip pcc.zip
mkdir -p pcc-master/debian
cp {compat,install,control,changelog,rules} pcc-master/debian/
cd pcc-master
dpkg-buildpackage -us -uc
@aarroyoc
aarroyoc / README.md
Created January 10, 2020 12:15
Nix package for PCC

Building

nix-build pcc.nix
nix-env -f pcc.nix -i pcc
@aarroyoc
aarroyoc / README.md
Created January 10, 2020 12:07
PCC Snap

Building

sudo snap install snapcraft --classic
snapcraft --use-lxd
sudo snap install --devmode --dangerous *.snap