Skip to content

Instantly share code, notes, and snippets.

View sjgknight's full-sized avatar

Simon Knight sjgknight

View GitHub Profile
@sjgknight
sjgknight / tablefilter.html
Last active August 26, 2024 06:23
Interface to reorder a table based on the sum of matches from applied rules. Here, dynamic table for matching synthesis methods based on user-defined rules. Generated with assistance from ChatGPT.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="Interface to reorder a table based on the sum of matches from applied rules. Here, dynamic table for matching synthesis methods based on user-defined rules. Generated with assistance from ChatGPT.">
<meta name="author" content="sjgknight with prompting of ChatGPT and customisation">
<meta name="keywords" content="HTML, JavaScript, Dynamic Table, Matching Logic">
<title>Method Match Example</title>
<style>
table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
@sjgknight
sjgknight / csv_to_mermaid.html
Created August 26, 2024 03:50
Single page tool to take CSVs and map across columns into an LR mermaid flowchart.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="Tool to take CSVs and map across columns into an LR mermaid flowchart.">
<meta name="author" content="sjgknight with prompting of ChatGPT and customisation">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSV to Mermaid Converter</title>
<!-- Load Mermaid.js -->
<script type="module">
@sjgknight
sjgknight / cv-presentations.csl
Last active December 7, 2023 03:29
APAish style for exporting personal talks.run regex search (- .*,)(.*)(thatsallfolks) to replace with - With:\2\. and then a find-replace on your own name.
<?xml version="1.0" encoding="utf-8"?>
<style class="in-text" version="1.0" name-delimiter=", " delimiter-precedes-et-al="never" delimiter-precedes-last="never" et-al-min="3" initialize-with="" demote-non-dropping-particle="sort-only" default-locale="en-US" xmlns="http://purl.org/net/xbiblio/csl">
<info>
<title>APAish style for CV styled presentations only</title>
<title-short>cv-presentations</title-short>
<id>http://www.zotero.org/styles/apaish-style-for-cv-styled-presentations-only</id>
<link rel="self" href="http://www.zotero.org/styles/apaish-style-for-cv-styled-presentations-only"/>
<author>
<name>Simon Knight</name>
</author>
@sjgknight
sjgknight / Nature - humanities and social sciences communications (author-date).csl
Last active February 14, 2025 14:55
Nature - humanities and social sciences communications (author-date).csl
<?xml version="1.0" encoding="utf-8"?>
<style class="in-text" version="1.0" name-delimiter=", " delimiter-precedes-et-al="never" delimiter-precedes-last="never" et-al-min="3" initialize-with="" demote-non-dropping-particle="sort-only" default-locale="en-US" xmlns="http://purl.org/net/xbiblio/csl">
<info>
<title>Nature - humanities and social sciences communications (author-date)</title>
<title-short>palcomms</title-short>
<id>http://www.zotero.org/styles/nature-humanities-and-social-sciences-communications</id>
<link href="http://www.zotero.org/styles/nature-humanities-and-social-sciences-communications" rel="self"/>
<link href="https://www.nature.com/palcomms/author-instructions/submission-instructions#References%20and%20endnotes" rel="documentation"/>
<author>
<name>Simon Knight</name>
@sjgknight
sjgknight / batch_names_twofields.js
Created November 15, 2023 00:56
A javascript snippet to be used in zotero js developer interface, batch select in the UI and it will convert '1 field' names into '2 field' names. Likely to be quite imperfect...
var newFieldMode = 0; // 0: two-field, 1: one-field (with empty first name)
const zoteroPane = Zotero.getActiveZoteroPane();
const selected = zoteroPane.getSelectedItems();
for (const item of selected) {
let creators = item.getCreators();
let newCreators = []; // Initialize newCreators array
for (let creator of creators) {
if(creator.fieldMode == 1){
@sjgknight
sjgknight / apa-single-spaced-citekey.csl
Last active October 31, 2023 04:27
A csl citation style for use with zotero. It takes the APA single space bibliography and prepends a citekey for export to markdown with citekey headings. Revision 1 creates its own citation key. Revision 2 uses the citation-key field which matches BBT
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never" page-range-format="expanded">
<info>
<title>American Psychological Association 7th edition (single-spaced bibliography) w/citekey</title>
<title-short>APA (single-spaced) + citekey</title-short>
<id>http://www.zotero.org/styles/apa-single-spaced-citekey</id>
<link href="http://www.zotero.org/styles/apa-single-spaced-citekey" rel="self"/>
<link href="http://www.zotero.org/styles/apa" rel="template"/>
<link href="https://apastyle.apa.org/style-grammar-guidelines/references/examples" rel="documentation"/>
<author>
// with thanks to http://wafflebytes.blogspot.com/2018/12/google-script-revisiting-making-form.html and http://wafflebytes.blogspot.com/2016/10/google-script-create-drop-down-list.html
// that script has some minor errors, notably asMultipleChoiceItem should be asCheckboxItem
// to find the question ID open the form in preview, and inspect element on the question. Scroll up the divs and you should see something like data-params='%.@.[ - the ID should be in that (and then the question text)
// In the googlesheet you can use the following formula to pull from the relevant column in FormResponses1 AND prepopulate this with your own responses (E2:E20) in GSOptions sheet
// =unique(query({GSOptions!E2:E20;'FormResponses1'!G2:G}))
// In the googlesheet if you want to concatenate two fields for question options you can do this
// =transpose(query(transpose(UNIQUE(query('Form Responses 1'!A2:C, "select C,A order by C asc",1))),,COLUMNS(UNIQUE(query('Form Responses 1'!A2:C, "select C,A order by C asc",1)))))
// w/
@sjgknight
sjgknight / google_forms_to_github_discussions.gs
Created June 14, 2022 02:09
A google apps script that can be setup (on trigger) to send form responses to github discussions. Useful if e.g. you want to track them elsewhere without users having to interact with github
// thanks to https://medium.com/@01010111/using-google-forms-to-submit-github-issues-efdb5f876b
// and https://gist.github.com/bmcbride/62600e48274961819084
// this first version uses the REST API and issues (not discussions)
/*
var token = "your_github_token_here";
var handle = "sjgknight";
var repo = "DSI_collection_sheets";
function onFormSubmit(e)
{
var title = e.values[2];
@sjgknight
sjgknight / who.Rmd
Created June 10, 2022 04:31
some very preliminary notes for a function to create a personal visualisation for students (and they can pick which one they like) based on name, etc. inputs (which, note, makes them opaque but reidentifiable)
---
title: "Who are you?"
output: html_notebook
editor_options:
chunk_output_type: inline
---
Takes as input name, etc.
Outputs visualisations