Initial commit
This commit is contained in:
commit
dc3eab173c
5 changed files with 1559 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
||||||
42
flake.lock
generated
Normal file
42
flake.lock
generated
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1654931879,
|
||||||
|
"narHash": "sha256-OyKm0DPMaHdRcZ8c+jaXmecEeSe3Fd1K+yirg7zDsys=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "c0d782e7b7b81174e056f7dbc991e82314488239",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"utils": "utils"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1653893745,
|
||||||
|
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
30
flake.nix
Normal file
30
flake.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
description = "A very basic flake";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = github:NixOS/nixpkgs;
|
||||||
|
utils.url = github:numtide/flake-utils;
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem(system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
lib = pkgs.lib;
|
||||||
|
# FIXME: Lua is borked at the moment :(
|
||||||
|
# lua = pkgs.lua5_3.withPackages(ps: with ps; [
|
||||||
|
# readline
|
||||||
|
# # cjson
|
||||||
|
# # http
|
||||||
|
# luarocks
|
||||||
|
# ]);
|
||||||
|
# fennel = pkgs.fennel.override { lua = lua; };
|
||||||
|
in {
|
||||||
|
devShells.default = pkgs.mkShell rec {
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.chicken
|
||||||
|
# pkgs.guile_3_0
|
||||||
|
];
|
||||||
|
# LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
31
main.scm
Normal file
31
main.scm
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
(import (chicken io)
|
||||||
|
(chicken process-context)
|
||||||
|
(chicken random))
|
||||||
|
|
||||||
|
(define *api-url* (get-environment-variable "MASTODON_API_URL"))
|
||||||
|
(define *access-tolen* (get-environment-variable "MASTODON_ACCESS_TOKEN"))
|
||||||
|
|
||||||
|
(define (file-lines file-path)
|
||||||
|
(let ((file (open-input-file file-path)))
|
||||||
|
(let loop ((lines '())
|
||||||
|
(cur (read-line file)))
|
||||||
|
(if (eof-object? cur)
|
||||||
|
(begin (close-input-port file)
|
||||||
|
(reverse lines))
|
||||||
|
(loop (cons cur lines)
|
||||||
|
(read-line file))))))
|
||||||
|
|
||||||
|
(define lines (file-lines "./words.txt"))
|
||||||
|
|
||||||
|
(define (list-nth ls n)
|
||||||
|
(if (zero? n)
|
||||||
|
(car ls)
|
||||||
|
(list-nth (cdr ls) (- n 1))))
|
||||||
|
|
||||||
|
(define (list-remove-nth ls n)
|
||||||
|
(if (zero? n)
|
||||||
|
(cdr ls)
|
||||||
|
(cons (car ls) (list-remove-nth (cdr ls) (- n 1)))))
|
||||||
|
|
||||||
|
(let ((nth (pseudo-random-integer (length lines))))
|
||||||
|
(display (list-nth lines nth)))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue