Skip to content

Instantly share code, notes, and snippets.

@johnghill
johnghill / base.yml
Last active July 26, 2023 20:18
[espanso] [zotero] [logseq] Reads path from clipboard and converts it to relative markdown link compatible with Logseq's internal PDF viewer
matches:
# Reads path from clipboard and converts it to relative markdown link compatible with Logseq's internal PDF viewer
# Note: parent directory wildcards ../../ are URL-encoded: %2e%2e/%2e%2e/
# Note: amend line 18; check that expanso service is running; tigger using :xpdf keystrokes
# Bug: Espanso reads ! from ![]() as a negation. My workaround is to add !! which you'll need to trim in Logseq
- trigger: ":xpdf"
replace: "!![~/Zotero/storage/{{alphanumeric}}/{{filename}}](%2e%2e/%2e%2e/%2e%2e/Zotero/storage/{{alphanumeric}}/{{filename}})"
vars:
@johnghill
johnghill / count_pdf_pages_recursively.sh
Last active July 6, 2023 19:13
[bash] Count pages in all PDFs in current folder and its sub folders
#!/bin/bash
# Based on https://gist.github.com/pmalek/8521413
sum_pages=0
while IFS= read -r file; do
cur_pages=$(pdfinfo "$file" | awk '/Pages/{print $2}')
echo "pdf: $file has $cur_pages pages."
sum_pages=$(( sum_pages + cur_pages))
@johnghill
johnghill / add-mathjax-to-articulate-SCORM.html
Last active January 29, 2021 18:19
Add MathJax to Articulate SCORM
<!--
Author: Zachary Daily
Source: https://community.articulate.com/discussions/rise-360/how-to-add-accessible-mathematics-to-your-rise-course-including-super-and-sub-scripts-and-formulas
Instructions:
- export SCORM 2004v4 from rise.articulate.com
- unzip
- locate ./scormcontent/index.html
- insert these scripts between the <head></head> tags of index.html
- zip
- Inline ($$) and display ($$ $$) LaTeX equations should render in your LMS

Keybase proof

I hereby claim:

  • I am johnghill on github.
  • I am johnhill (https://keybase.io/johnhill) on keybase.
  • I have a public key ASAWpW-lStXD1eEgMwJkJdw7PWTg3-56utGJk0dkgJJcxQo

To claim this, I am signing this object:

@johnghill
johnghill / stata-curl-SMS.do
Created May 7, 2017 18:32
[Stata] [curl] [SMS] Get a text from Stata using ! curl
* Append to any time consuming operation e.g. -mi impute-
* Receive 1 free generic SMS per day, or buy a personal API key at https://textbelt.com
! curl -X POST https://textbelt.com/text --data-urlencode phone='+44xxxxxxxxxx' --data-urlencode message='Yo! Get back here' -d key=textbelt
@johnghill
johnghill / compare-local-remote.sh
Created December 10, 2016 18:40
[git] Assert local HEAD and remote ORIGIN on same commit
#!/bin/bash
#
# Asserts that local HEAD and remote ORIGIN are at same commit i.e. avoids a mess
# Based on CodeGnome @ http://stackoverflow.com/a/11181747
#
remote=$(
git ls-remote -h origin master |
awk '{print $1}'
)
local=$(git rev-parse HEAD)
@johnghill
johnghill / gist:1da3f3747bc8d1c82284
Created December 8, 2015 08:39
[git] [config] git config --list
user.name=John Hill
user.email=*
diff.external=git-meld
diff.tool=meld
merge.tool=git-meld
color.ui=auto
core.editor=subl -n -w
@johnghill
johnghill / .gitignore
Created December 8, 2015 08:32
[stata] [LaTeX] [thesis] gitignore for a thesis project
## Loosely based on: https://gist.github.com/kogakure/149016
## Alternative everything-but-kitchen-sink version: https://github.com/github/gitignore/blob/master/TeX.gitignore
latex/*.aux
latex/*.glo
latex/*.idx
latex/*.log
latex/*.toc
latex/*.ist
latex/*.acn
latex/*.acr
@johnghill
johnghill / key-switch.sh
Last active November 4, 2019 15:02
[BibTeX] [JabRef] [keys] Replace citation keys in existing TeX document after globally altering key generation pattern in JabRef
#!/bin/sh
### STEPS
# JabRef: Back-up original bibtex keys to new var called Orig_bibtexkey
# JabRef: Amend key pattern (as you do...)
# JabRef: Create custom export.layout file below
# echo '\format[GetOpenOfficeType]{\bibtextype},"\bibtexkey","\Orig_bibtexkey",' > jabref-export-keysonly.layout
# JabRef: Exprt to .csv, then to .txt file
# One line per pair of citations, each pair separated by [space]
# Execute this bash script on target .tex file: sh ./key-switch.sh
@johnghill
johnghill / stb
Last active January 26, 2019 20:49
[stata] [make] Wrapper to execute Stata batch files on Linux (stata -b), greps for do file errors and passes appropriate exit code to e.g. make
#!/bin/sh
# Author: Brendan Halpin
# Forked from: http://teaching.sociology.ul.ie/bhalpin/wordpress/?p=122
# Nov 7 2001 21:05:17
# A wrapper for running Stata in batch mode.
# Main purpose is to catch errors and pass them to the calling
# process, typically "make". To do this it catches a couple of