Skip to content

Instantly share code, notes, and snippets.

View simon-brooke's full-sized avatar
💭
Semper in faecibus sumus, sole profundam variat.

Simon Brooke simon-brooke

💭
Semper in faecibus sumus, sole profundam variat.
View GitHub Profile
@simon-brooke
simon-brooke / example-rss.html
Created July 16, 2023 10:48
Embed an RSS feed into a web page using only locally sourced JQuery
<script src="/blog/js/jquery-3.7.0.min.js" type="application/javascript"></script>
<div class="social-media">
<hr/>
<h4>Recent Mastodon posts</h4>
<ol id="mastodon"></ol>
<script type="text/javascript">
const RSS_URL = "https://mastodon.scot/@simon_brooke.rss";
function getRSSFeed(feed, target) {
@simon-brooke
simon-brooke / get_pid.clj
Created December 21, 2022 17:01
Getting the process id from Clojure
(def pid
"OK, this is hacky as fuck, but I hope it works. The problem is that the
way to get the process id has changed several times during the history
of Java development, and the code for one version of Java won't even compile
in a different version."
(let [java-version (read-string (apply str (take 2
(split
(System/getProperty "java.version")
#"[_\.]"))))
cmd (case java-version
@simon-brooke
simon-brooke / migrate.clj
Last active October 6, 2022 20:46
Convert leiningen project.clj into clojure.cli deps.edn
(ns migrate
"
## Leiningen to deps.edn migration tool
I'm as yet unpersuaded of the merits of `deps.edn` vis-a-vis leiningen.
Leiningen puts all the metadata about your project and how to build it
in one place in a clear, well understood and easily-extensible format.
The `deps.edn` format intentionally does not.
Worse, `clojure.cli` uses a subtly but significantly different algorithm
@simon-brooke
simon-brooke / bargraph.clj
Created January 26, 2022 15:51
Quick and dirty bargraph from Clojure frequencies
(defn bargraph
"Quick'n'dirty bargraph from these `freqs`, the output from the function
`clojure.core/frequencies`."
[freqs]
(let [u (/ (apply max (vals freqs)) 20)
p (/ (apply +' (vals freqs)) 100)]
(join "\n"
(map #(format "%7d : %s (%d %%)"
%
(apply str (take (/ (freqs %) u) (repeat "#")))
@simon-brooke
simon-brooke / COVID-19-geographic-disbtribution-worldwide.awk
Created July 28, 2020 21:23
Collect daily worldwide COVID 19 data from the European Centre for Disease Control, bung it into a local database, and report
#!/bin/awk -f
BEGIN {
FS=",";
OFS=", ";
print("delete from covid;");
}
NR > 1 {
$1 = gensub( /(.*)/, "'\\1'", 1, $1);
$7 = gensub( /(.*)/, "'\\1'", 1, $7);
@simon-brooke
simon-brooke / tag.clj
Created May 26, 2020 16:12
Tagging in Clojure
(ns walkmap.tag
"Code for tagging, untagging, and finding tags on objects. Note the use of
the namespaced keyword, `:walkmap.tag/tags`, denoted in this file `::tags`.
This is in an attempt to avoid name clashes with other uses of this key."
(:require [clojure.set :refer [difference union]]))
(defn tagged?
"True if this `object` is tagged with each of these `tags`."
[object & tags]
(if
@simon-brooke
simon-brooke / set-exif-date.sh
Created April 15, 2020 14:54
Set EXIF date of digital photographs to the current date
#!/bin/bash
# Set the timestamp of the JPEG files which are specified as arguments to the current
# date, if its timestamp is zero.
#
# Background: My Olympus E20p, which I like and still use, is so old that it has no
# clock, and doesn't timestamp photographs. In order that Shotwell should file them
# properly, I like them timestamped.
#
# Weirdly, although the timestamp appears in the EXIF as it comes off the camera as
@simon-brooke
simon-brooke / url-query.cljs
Created February 22, 2020 11:42
Returning the query part of the URL in a usable form in ClojureScript
(ns url-query.query
(:require [clojure.string :as cs]))
;; I wrote this function for a wee side project and ended up not using it - but it is quite a useful function.
;; Freeware, not copyrighted, no warranty. Use at your own risk.
(defn get-query-part-as-map
"Returns the query part of the current document URL as a keyword-string map."
[]
(let [query-nvs (map #(cs/split % "=") (cs/split (subs js/window.location.search 1) "&"))]
@simon-brooke
simon-brooke / my-cons.clj
Last active August 14, 2019 22:43 — forked from Solaxun/my-cons.clj
Clojure Cons Cell
(def NIL (symbol "NIL"))
(deftype ConsCell [CAR CDR]
clojure.lang.ISeq
(cons [this x] (ConsCell. x this))
(first [this] (.CAR this))
;; next and more must return ISeq:
;; https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ISeq.java
(more [this] (if
(= (.CDR this) NIL)

This is a list of domains currently on the email blocklist of the Virtual Steamie; I'll try to keep it up to date.

  • bacrko.fun
  • beioxaf.xyz
  • ceponla.eu
  • cerjoxa.pres
  • cerjoxa.press
  • dedanka.top
  • hoalqur.top
  • irewal.asia