Skip to content

Instantly share code, notes, and snippets.

@Jach
Jach / EasyMail.php
Created July 1, 2023 19:10
Companion to the local script over at https://gist.github.com/Jach/41082f105f5779531e041a6d3afb21db which talks to this PHP service when a new community post has been made
<?php
/* USAGE:
* $send = array();
* $send['to'] = 'to@d.com';
* $send['from'] = 'from@d.com'; // defaults to 'admin@thisdomain.com'
* $send['subject'] = 'Sub';
* $send['html'] = '<a href="site">click me</a>'; // newlines == <br /> automagically
*
* $mail = new EasyMail($send);
;;;; For years I had a script that used the twitter free API to get my account's (@jachy) likes, and if they were
;;;; images or videos, download a local copy of them because I was sick of accounts being suspended and losing some memes/art
;;;; forever.
;;;; Anyway, because the free tier is no more, here is a very dirty Common Lisp script to replace it.
;;;; It requires Selenium (expected to be running before this script, e.g. with `java -jar selenium-server-4.1.2.jar standalone`
;;;; and I'm assuming Firefox rather than Chrome is being used) to load up the likes page and continue to scroll down the page
;;;; for a fixed duration of time, frequently polling the page source and extracting media URLs from it. It handles pictures,
;;;; mp4 videos, and gifs. It uses `yt-dlp` (fork of youtube-dl) to get the mp4 URLs, uses `ls` to check for already-downloaded
;;;; existence (needed for lazy glob patterns), and `wget` to do the actual download.
;;;; By default it runs for 5 minutes, my cronjob is setup to run the sc
@Jach
Jach / coyo_yt_posts.lisp
Last active August 28, 2023 12:28
Quick and dirty webdriver script to run at whatever cadence and get notifications that Coyo (or some other youtube channel) wrote something new in the Community tab, because Youtube's native notifications suck
; before running, run java -jar selenium-server-4.1.2.jar standalone
(defpackage #:coyo-yt-posts
(:use #:cl))
(in-package :coyo-yt-posts)
(ql:quickload :cl-webdriver-client)
(ql:quickload :dexador)
(use-package :webdriver-client)

Similar to my Book Reading List Queue or my Anime Notes, this will track some thoughts on some past games I've played or beaten. I've been tracking my beaten games with play time for some time at How Long To Beat, but I haven't given them ratings or post-play thoughts, and I thought it might be a good idea to start doing that and go back and do it for some old plays (and maybe discover for some that I have very little memory of what actually happened). List is for my own benefit so I'm not going to be careful around spoiler topics, but I'm also lazy and don't want to write that much to justify a review score... I wouldn't mind chatting in the comments if there's a game where my rating is quite different and some discussion around it would be interesting.

There are some games that are more 'ongoing' or never-ending in some sense like being meant to be played and replayed over and over, maybe they're arcade style or MMOs or games-as-service things, in any case they

A bit similar to my Book Reading List Queue, but not as complete or detailed. I've been tracking the anime I've been watching on MAL for a while and in case anyone is interested that is the definitive spot for dates / scores. Over time I'd like to maybe comment on everything here to some extent, even just a few words' remark on my thoughts or feelings, and maybe justify my score slightly. Mostly just one-two sentence things though I'm sure some will expand. The reason to do this is sometimes I forget why I judged something a particular way and only remember the judgement or feeling, keeping even a minor note should help recall fuller details even if I don't write the fuller ones here. Rating wise, I'd happily rewatch anything 8 or above.

Order here will also be most recent at the top. List started with Haruhi Suzumiya, so unfortunately everything prior that is backwards memory-filling, not fresh thoughts after just finishing.

Note that I di

@Jach
Jach / matrixquerything.lisp
Created February 16, 2022 07:17
I hate it...
(defstruct cell
color
value
i
j)
(defun create-cells (matrix)
(let ((cells (list))
(color :white))
(loop for i below (array-dimension matrix 0) do
@Jach
Jach / bodyweight.lisp
Last active June 8, 2021 05:54 — forked from stucchio/gist:1403042
Graphs of bodyweight vs time, Lisp version
; quick and dirty adaptation from https://gist.github.com/stucchio/1403042
(ql:quickload :numcl)
(ql:quickload :vgplot)
(defparameter *exercise-level* 1.5)
(defparameter *height-inches* (* 6 12))
(defparameter *a* (/ (* *exercise-level* (+ 66 (* 12.7 *height-inches*)))
3500.0))
(defparameter *b* (/ (* *exercise-level* 6.23)
3500))
// ==UserScript==
// @name Twitter Selected Users
// @version 1
// @grant none
// @namespace local
// @include https://twitter.com/*
// ==/UserScript==
// Brittle bare-minimum works-for-me code ahead!
// License: Public Domain (see bottom)
@Jach
Jach / sdl-intro.lisp
Last active August 8, 2021 03:20
Hello world with SDL2 and Common Lisp. Somewhat explanatory blog post here https://www.thejach.com/view/2020/11/hello_world_to_get_with_the_times_using_sdl2_and_common_lisp
#|Public domain. Does not unwind-protect errors like it should.|#
(in-package #:cl-user)
(defpackage #:sdl-intro
(:use #:common-lisp))
(in-package #:sdl-intro)
(ql:quickload "sdl2")
(defun null-ptr? (alien-val)
(cffi:null-pointer-p (autowrap:ptr alien-val)))
;(ql:quickload :cl-ppcre)
;(ql:quickload :cl-interpol)
;(named-readtables:in-readtable :interpol-syntax)
(defun full-match (pattern string)
"Something like Python's re.fullmatch.
Example (with cl-interpol):
(full-match #?/\s/ #?' ') -> T
(full-match #?/\s/ #?'') -> nil"
(equal string (cl-ppcre:scan-to-strings pattern string)))