Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Saleeba tomsaleeba

View GitHub Profile
@tomsaleeba
tomsaleeba / README.md
Last active Nov 24, 2020
Pollin8 model tuning
View README.md

Note: make sure you view this page on this URL with a trailing slash otherwise images won't work. More info.

What is this?

An attempt to get the model reporting the kinds of numbers that we'd expect to see based on expert opinion.

All of these runs are done including the "children inherit parent

@tomsaleeba
tomsaleeba / README.md
Created Jul 9, 2020
Test if we can modify IndexedDB records (not upgrade the DB version) in one connection while another connection is open. Spoiler, we can!
View README.md

To run this test, copy and paste the script into the JS console of your browser (or use Snippets in Chrome devtools).

The output is:

starting
upgrading
opened1
req1 success
req2 success
req3 success
View tail-recursion.js
// the non-tail-recursive way
;(() => {
function fac(n) {
if (n === 1) {
return 1
}
const nextFac = fac(n - 1)
return n * nextFac // last thing we do it multiply
}
@tomsaleeba
tomsaleeba / can-js-promises-be-cancelled.js
Created Apr 29, 2020
A test to see if you can truly cancel JS promises. Spoiler: you can't.
View can-js-promises-be-cancelled.js
// Question: does calling reject on a running promise cut it short?
// Answer: sort of. It returns to the caller early but it keep running behind
// the scenes. So more of a short-circuit than really being cancelled.
const printFrequency = 500
const printRounds = 10
const cancelPoint = 7
let someOtherState = 'untouched'
@tomsaleeba
tomsaleeba / imagemagick-watermark-readme.md
Created Apr 16, 2020
How to add watermarks with ImageMagick
View imagemagick-watermark-readme.md
$ magick --version
Version: ImageMagick 7.0.10-3 Q16 x86_64 2020-03-28 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib cairo fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png raqm raw rsvg tiff webp wmf x xml zlib

The command

@tomsaleeba
tomsaleeba / puzzle.jpg
Last active Apr 15, 2020
Kimmy's "dress the man" puzzle
@tomsaleeba
tomsaleeba / README.md
Last active Dec 11, 2019
iNat bulk upload instructions
View README.md

Which method is for me?

If you have a bunch of photos to upload, and they have location information embedded in the photo, then you have a few options.

  1. If they're on your phone, you can use our app (at the time of writing our app doesn't yet support reading the location information from photos, but it will)
  2. Use the "regular" upload method for iNat via their website

If you have observations that do not have a photo, or do have a photo but the photo does not have location information embedded in it, then the CSV based bulk upload if the best choice.

@tomsaleeba
tomsaleeba / README.md
Last active Feb 20, 2019
FISH shell VI keybindings with ctrl-<arrow> word navigation
View README.md
  1. enable VI mode
    fish_vi_key_bindings
    
  2. restore the word navigation keys I'm used to in insert mode
    cat << EOF > ~/.config/fish/functions/fish_user_key_bindings.fish
    function fish_user_key_bindings
      bind -M insert \e\[1\;5C nextd-or-forward-word   # ctrl-right
      bind -M insert \e\[1\;5D prevd-or-backward-word  # ctrl-left
    
@tomsaleeba
tomsaleeba / README.md
Last active Jul 13, 2021
Debugging HTTP traffic with mitmproxy
View README.md

This will let you see the request and response headers for traffic going through.

We're going to run this as a reverse proxy, rather than a usual proxy, so you don't get completely flooded with traffic.

Start the proxy

  1. create a new VM
  2. expose port 8080 to the public internet
  3. SSH to the VM
  4. make sure you have at least python 3.6
@tomsaleeba
tomsaleeba / extract-subgraph-3levels.rq
Last active Oct 23, 2018
Extracting RDF subgraphs using SPARQL
View extract-subgraph-3levels.rq
# this query extracts a subgraph from the selected subject (level 1) and two child levels
PREFIX aekos: <http://www.aekos.org.au/ontology/1.0.0#>
PREFIX some_dataset: <http://www.aekos.org.au/ontology/1.0.0/some_dataset#>
CONSTRUCT {
?s1 ?p1 ?o1 .
?s1 ?pv1 ?v1 .
?s2 ?p2 ?o2 .
?s2 ?pv2 ?v2 .
?s3 ?p3 ?o3 .