diff options
Diffstat (limited to 'fun')
-rw-r--r-- | fun/avatar.jpeg | bin | 0 -> 38763 bytes | |||
-rw-r--r-- | fun/best-tools/README.md | 156 | ||||
-rw-r--r-- | fun/gemma/README.md (renamed from fun/gemma/README.markdown) | 0 | ||||
-rw-r--r-- | fun/gemma/build.lisp | 5 | ||||
-rw-r--r-- | fun/gemma/default.nix | 71 | ||||
-rw-r--r-- | fun/gemma/gemma.asd | 33 | ||||
-rw-r--r-- | fun/gemma/src/gemma.lisp | 32 | ||||
-rw-r--r-- | fun/wcl/default.nix | 14 | ||||
-rw-r--r-- | fun/wcl/wc.lisp | 34 |
9 files changed, 94 insertions, 251 deletions
diff --git a/fun/avatar.jpeg b/fun/avatar.jpeg new file mode 100644 index 000000000000..f38f05657840 --- /dev/null +++ b/fun/avatar.jpeg Binary files differdiff --git a/fun/best-tools/README.md b/fun/best-tools/README.md deleted file mode 100644 index e17052467a6a..000000000000 --- a/fun/best-tools/README.md +++ /dev/null @@ -1,156 +0,0 @@ -tazjin's best tools -=================== - -In the spirit of various other "Which X do you use?"-pages I thought it would be -fun to have a little document here that describes which tools I've found to work -well for myself. - -When I say "tools" here, it's not about software - it's about real, physical -tools! - -If something goes on this list that's because I think it's seriously a -best-in-class type of product. - -<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> -- [Media & Tech](#media--tech) - - [Keyboard](#keyboard) - - [Speakers](#speakers) - - [Headphones](#headphones) - - [Earphones](#earphones) - - [Phone](#phone) -- [Other stuff](#other-stuff) - - [Toothbrush](#toothbrush) - - [Shavers](#shavers) - - [Shoulder bag](#shoulder-bag) - - [Wallet](#wallet) -<!-- markdown-toc end --> - ---------- - -# Media & Tech - -## Keyboard - -The best keyboard that money will buy you at the moment is the [Kinesis -Advantage][advantage]. There's a variety of contoured & similarly shaped -keyboards on the market, but the Kinesis is the only one I've tried that has -properly implemented the keywell concept. - -I struggle with RSI issues and the Kinesis actually makes it possible for me to -type for longer periods of time, which always leads to extra discomfort on -laptop keyboards and such. - -Honestly, the Kinesis is probably the best piece of equipment on this entire -list. I own several of them and there will probably be more in the future. They -last forever and your wrists will thank you in the future, even if you do not -suffer from RSI yet. - -[advantage]: https://kinesis-ergo.com/shop/advantage2/ - -## Speakers - -The speakers that I've hooked up to my audio setup (including both record player -& Chromecast / TV) are the [Teufel Motiv 2][motiv-2]. I've had these for over a -decade and they're incredibly good, but unfortunately Teufel no longer makes -them. - -It's possible to grab a pair on eBay occasionally, so keep an eye out if you're -interested! - -[motiv-2]: https://www.teufelaudio.com/uk/pc/motiv-2-p167.html - -## Headphones - -I use the [Bose QC35][qc35] (note: link goes to a newer generation than the one -I own) for their outstanding noise cancelling functionality and decent sound. - -When I first bought them I didn't expect them to end up on this list as the -firmware had issues that made them only barely usable, but Bose has managed to -iron these problems out over time. - -I avoid using Bluetooth when outside and fortunately the QC35 come with an -optional cable that you can plug into any good old 3.5mm jack. - -[qc35]: https://www.bose.co.uk/en_gb/products/headphones/over_ear_headphones/quietcomfort-35-wireless-ii.html - -### Earphones - -Actually, to follow up on the above - most of the time I'm not using (over-ear) -headphones, but (in-ear) earphones - specifically the (**wired!!!**) [Apple -EarPods][earpods]. - -Apple will probably stop selling these soon because they've gotten into the -habit of cancelling all of their good products, so I have a stash of these -around. You will usually find no fewer than 3-4 of them lying around in my -flat. - -[earpods]: https://www.apple.com/uk/shop/product/MNHF2ZM/A/earpods-with-35mm-headphone-plug - -## Phone - -The best phone that's on the market at the moment is the [iPhone SE][se]. It's -as far as I am aware the *only* phone that has a reasonable size (up to 4") -*and* a 3.5mm headphone jack. - -These two are the make-it-or-break-it requirements for me. Despite iOS being an -annoying system to use there is nothing better available at the moment. - -This is the only item on this list for which I am actively seeking a -replacement, so if you have any tips about new phones that might fit these -criteria that I've missed please let me know. - -[se]: https://en.wikipedia.org/wiki/IPhone_SE - -# Other stuff - -## Toothbrush - -The [Philips Sonicare][sonicare] (note: link goes to a newer generation than -mine) is excellent and well worth its money. - -I've had it for a few years and whereas I occasionally had minor teeth issues -before, they seem to be mostly gone now. According to my dentist the state of my -teeth is now usually pretty good and I draw a direct correlation back to this -thing. - -The newer generations come with flashy features like apps and probably more -LEDs, but I suspect that those can just be ignored. - -[sonicare]: https://www.philips.co.uk/c-m-pe/electric-toothbrushes - -## Shavers - -The [Philipps SensoTouch 3D][sensotouch] is excellent. Super-comfortable close -face shave in no time and leaves absolutely no mess around, as far as I can -tell! I've had this for ~5 years and it's not showing any signs of aging yet. - -Another bonus is that its battery time is effectively infinite. I've never had -to worry when bringing it on a longer trip! - -[sensotouch]: https://www.philips.co.uk/c-p/1250X_40/norelco-sensotouch-3d-wet-and-dry-electric-razor-with-precision-trimmer - -## Shoulder bag - -When I moved to London I wanted to stop using backpacks most of the time, as -those are just annoying to deal with when commuting on the tube. - -To work around this I wanted a good shoulder bag with a vertical format (to save -space), but it turned out that there's very few of those around that reach any -kind of quality standard. - -The one I settled on is the [Waterfield Muzetto][muzetto] leather bag. It's one -of those things that comes with a bit of a price tag attached, but it's well -worth it! - -[muzetto]: https://www.sfbags.com/collections/shoulder-messenger-bags/products/muzetto-leather-bag - -## Wallet - -My wallet is the [Bellroy Slim Sleeve][slim-sleeve]. I don't carry cash unless -I'm attending an event in Germany and this wallet fits that lifestyle perfectly. - -It's near indestructible, looks great, is very slim and fits a ton of cards, -business cards, receipts and whatever else you want to be lugging around with -you! - -[slim-sleeve]: https://bellroy.com/products/slim-sleeve-wallet/default/charcoal diff --git a/fun/gemma/README.markdown b/fun/gemma/README.md index 064742c0091f..064742c0091f 100644 --- a/fun/gemma/README.markdown +++ b/fun/gemma/README.md diff --git a/fun/gemma/build.lisp b/fun/gemma/build.lisp deleted file mode 100644 index e935ce25fde4..000000000000 --- a/fun/gemma/build.lisp +++ /dev/null @@ -1,5 +0,0 @@ -(require :asdf) -(require :sb-posix) - -(push (format nil "~A/" (sb-posix:getcwd)) asdf:*central-registry*) -(asdf:operate 'asdf:program-op :gemma) diff --git a/fun/gemma/default.nix b/fun/gemma/default.nix index f48af489217a..cecf8bb751ee 100644 --- a/fun/gemma/default.nix +++ b/fun/gemma/default.nix @@ -1,61 +1,50 @@ { pkgs, ... }: let - inherit (pkgs) elmPackages lispPackages; - inherit (pkgs.third_party) stdenv sbcl makeWrapper openssl; + inherit (pkgs) elmPackages; + inherit (pkgs.third_party) cacert iana-etc libredirect stdenv runCommandNoCC; frontend = stdenv.mkDerivation { - name = "gemma-frontend"; + name = "gemma-frontend.html"; src = ./frontend; - buildInputs = [ elmPackages.elm ]; + buildInputs = [ cacert iana-etc elmPackages.elm ]; + + # The individual Elm packages this requires are not packaged and I + # can't be bothered to do that now, so lets open the escape hatch: + outputHashAlgo = "sha256"; + outputHash = "000xhds5bsig3kbi7dhgbv9h7myacf34bqvw7avvz7m5mwnqlqg7"; phases = [ "unpackPhase" "buildPhase" ]; buildPhase = '' + export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols \ + LD_PRELOAD=${libredirect}/lib/libredirect.so + + export SYSTEM_CERTIFICATE_PATH=${cacert}/etc/ssl/certs + mkdir .home && export HOME="$PWD/.home" - mkdir -p $out - elm-make --yes Main.elm --output $out/index.html + elm-make --yes Main.elm --output $out ''; }; -in stdenv.mkDerivation rec { + + injectFrontend = pkgs.writeText "gemma-frontend.lisp" '' + (in-package :gemma) + (setq *static-file-location* "${runCommandNoCC "frontend" {} '' + mkdir -p $out + cp ${frontend} $out/index.html + ''}/") + ''; +in pkgs.nix.buildLisp.program { name = "gemma"; - src = ./.; - nativeBuildInputs = with lispPackages; [ - sbcl - hunchentoot + deps = with pkgs.third_party.lisp; [ cl-json - cffi cl-prevalence + hunchentoot local-time - makeWrapper ]; - buildPhase = '' - mkdir -p $out/share/gemma $out/bin - - # Build Lisp using the Nix-provided wrapper which sets the load - # paths correctly. - cd $src - env GEMMA_BIN_TARGET=$out/bin/gemma common-lisp.sh --load build.lisp - - # Wrap gemma to find OpenSSL at runtime: - wrapProgram $out/bin/gemma --prefix LD_LIBRARY_PATH : "${openssl.out}/lib" - - # and finally copy the frontend to the appropriate spot - cp ${frontend}/index.html $out/share/gemma/index.html - ''; - - installPhase = "true"; - - # Stripping an SBCL executable removes the application, which is unfortunate. - dontStrip = true; - - meta = with stdenv.lib; { - description = "Tool for tracking recurring tasks"; - homepage = "https://github.com/tazjin/gemma"; - license = licenses.gpl3; - - # Lisp builds are broken for some reason (2019-09-22) - broken = true; - }; + srcs = [ + ./src/gemma.lisp + injectFrontend + ]; } diff --git a/fun/gemma/gemma.asd b/fun/gemma/gemma.asd deleted file mode 100644 index 0aea9c95ff92..000000000000 --- a/fun/gemma/gemma.asd +++ /dev/null @@ -1,33 +0,0 @@ -#| - This file is part of Gemma. - - Gemma is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Copyright (c) 2017 Vincent Ambo -|# - -(require 'sb-posix) - -(defsystem "gemma" - :version "0.1.0" - :author "Vincent Ambo" - :license "GPLv3" - :depends-on (local-time - hunchentoot - cl-json - cl-prevalence) - :components ((:module "src" - :components - ((:file "gemma")))) - :build-operation program-op - :build-pathname #.(or (pathname (sb-posix:getenv "GEMMA_BIN_TARGET")) - "gemma") - :entry-point "gemma::entrypoint" - :description "Gemma is a household task management system" - :long-description - #.(read-file-string - (subpathname *load-pathname* "README.markdown")) - :in-order-to ((test-op (test-op "gemma-test")))) diff --git a/fun/gemma/src/gemma.lisp b/fun/gemma/src/gemma.lisp index b8a20addd907..20a76caae629 100644 --- a/fun/gemma/src/gemma.lisp +++ b/fun/gemma/src/gemma.lisp @@ -1,4 +1,4 @@ -;; Copyright (C) 2016-2017 Vincent Ambo <mail@tazj.in> +;; Copyright (C) 2016-2020 Vincent Ambo <mail@tazj.in> ;; ;; This file is part of Gemma. ;; @@ -13,7 +13,7 @@ :cl-json) (:import-from :sb-posix :getenv) (:shadowing-import-from :sb-posix :getcwd) - (:export :start-gemma :config :entrypoint)) + (:export :start-gemma :config :main)) (in-package :gemma) ;; TODO: Store an average of how many days it was between task @@ -29,19 +29,19 @@ (defvar *gemma-port* 4242 "Port on which the Gemma web server listens.") -(defvar *static-file-location* - (or (in-case-of (sb-posix:getenv "out") - (concatenate 'string it "/share/gemma/")) - "frontend/") +(defvar *gemma-acceptor* nil + "Hunchentoot acceptor for Gemma's web server.") + +(defvar *static-file-location* "frontend/" "Folder from which to serve static assets. If built inside of Nix, - the folder is concatenated with the output path at which the files - are expected to be.") + the path is injected during the build.") -(defun initialise-persistence (data-dir) - (defvar *p-tasks* - (cl-prevalence:make-prevalence-system data-dir) +(defvar *p-tasks* nil "All tasks registered in this Gemma instance.") +(defun initialise-persistence (data-dir) + (setq *p-tasks* (cl-prevalence:make-prevalence-system data-dir)) + ;; Initialise database ID counter (or (> (length (cl-prevalence:find-all-objects *p-tasks* 'task)) 0) (cl-prevalence:tx-create-id-counter *p-tasks*))) @@ -137,10 +137,10 @@ maximum interval." "/etc/gemma/config.lisp"))) ;; Set up web server - (hunchentoot:start - (make-instance 'hunchentoot:easy-acceptor - :port *gemma-port* - :document-root *static-file-location*)) + (setq *gemma-acceptor* (make-instance 'hunchentoot:easy-acceptor + :port *gemma-port* + :document-root *static-file-location*)) + (hunchentoot:start *gemma-acceptor*) ;; Task listing handler (hunchentoot:define-easy-handler @@ -161,7 +161,7 @@ maximum interval." (complete-task key) (encode-json-to-string (response-for (get-task key)))))) -(defun entrypoint () +(defun main () "This function serves as the entrypoint for ASDF-built executables. It joins the Hunchentoot server thread to keep the process running for as long as the server is alive." diff --git a/fun/wcl/default.nix b/fun/wcl/default.nix new file mode 100644 index 000000000000..ca1cbb80589a --- /dev/null +++ b/fun/wcl/default.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: + +pkgs.nix.buildLisp.program { + name = "wc"; + + srcs = [ + ./wc.lisp + ]; + + deps = with pkgs.third_party.lisp; [ + unix-opts + iterate + ]; +} diff --git a/fun/wcl/wc.lisp b/fun/wcl/wc.lisp new file mode 100644 index 000000000000..83c7e8c4f1cc --- /dev/null +++ b/fun/wcl/wc.lisp @@ -0,0 +1,34 @@ +(defpackage wc + (:use #:cl #:iterate) + (:export :main)) +(in-package :wc) +(declaim (optimize (speed 3) (safety 0))) + +(defun main () + (let ((filename (cadr (opts:argv))) + (space (char-code #\Space)) + (newline (char-code #\Newline))) + (with-open-file (file-stream filename :element-type '(unsigned-byte 8)) + (iter + (for byte in-stream file-stream using #'read-byte) + (for previous-byte previous byte) + (for is-newline = (eql newline byte)) + + ;; Count each byte + (sum 1 into bytes) + + ;; Count every newline + (counting is-newline into newlines) + + ;; Count every "word", unless the preceding character already + ;; was a space or we are at the beginning of the file. + (when (or (eql space previous-byte) + (eql newline previous-byte) + (not previous-byte)) + (next-iteration)) + + (counting (or is-newline (eql space byte)) + into words) + + (declare (fixnum bytes newlines words)) + (finally (format t " ~A ~A ~A ~A~%" newlines words bytes filename)))))) |