Skip to content

Instantly share code, notes, and snippets.

View mbwatson's full-sized avatar
☠️

Matt Watson mbwatson

☠️
  • RENCI
  • Raleigh, NC USA
View GitHub Profile
@mbwatson
mbwatson / gist:ffeb58bdc06cf8c9cf0e55ecebb7f476
Last active February 9, 2024 22:02
prev website staff scraper
// 2004
const staffHeading = [...document.querySelectorAll('h2')].find(el => el.innerText === 'Staff')
const staff = [...staffHeading.nextElementSibling.querySelectorAll('tr')]
.map(row => row.querySelector('td:nth-child(2)'))
.map(cell => {
const name = cell.querySelector('b').innerText
const title = cell.querySelector('i').innerText
return { name, title }
})
@mbwatson
mbwatson / touchscreen-toggle.sh
Last active August 28, 2022 17:15
Script to toggle the touchscreen in (at least) Ubuntu 22.04 on Lenovo X1 Carbon
#!/bin/bash
input_id=$(xinput --list | grep Touch | awk -F' ' '{print $8}' | awk -F'=' '{print $2}') || 0
# check argument is either "on" or "off".
# bounce out if it is neither.
if [[ "$1" != "on" ]] && [[ "$1" != "off" ]]; then
echo "Usage: ./touchscreen-toggle.sh [on|off]"
exit
@mbwatson
mbwatson / freshdesk-scrape-contacts.js
Last active June 17, 2022 14:05
Freshdesk Scrape Contacts
// paste and run this chunk first
contacts = []
rows = Array.from(document.querySelectorAll('.body-row'))
// then paste and run this chunk
rows.forEach(row => {
const nameDiv = row.querySelector('div[data-test-id^="contact-name-"]')
name = nameDiv.getAttribute('data-test-id').replace(/^contact-name-/, '')
email = row.innerHTML.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi)[0]
contacts.push({ name, email })
###########################################
# Set Docker Image Timezone at Build Time #
###########################################
FROM ubuntu:18.04
# install tzdata
RUN apt-get update && apt-get install -y tzdata
# set time zone environment variable
const D3Node = require('d3-node')
const d3 = require('d3')
const fs = require('fs')
//
const styles = `
svg {
width: 100%;
height: 50vw;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>nc cities</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://d3js.org/d3-hexbin.v0.2.min.js"></script>
<script src="https://d3js.org/d3-scale.v3.min.js"></script>
<style>
body {
/*
Automating gathering of submissions from Gravity Form entries within WordPress
Execute the following in the dev console of your browser when viewing the paginated entries to extract.
Obviously, this can be modified to suit whatever form fields exist,
but the below code will dump csv lines consisting of
submission date, last name, first name, school, filename
(which we're building on the fly from the first and last names),
and it also opens dialog boxes to download the submitted PDFs renamed last-name_first-name.pdf
so that sorting/joining in order is easy.
*/
@mbwatson
mbwatson / columns.html
Last active October 16, 2019 18:56
List, fill columns first
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Columns</title>
<style>
.columns-container {
border: 1px solid #f99;
padding: 1rem;
columns: 4 300px;
matt@carbon:~/dev/fabric-netlify (xenial) $ ./test-tools/start-image.sh ./fabric/
buildbot@6a0c28096f4b:/$ build npm run build
Cloning into '/opt/buildhome/repo'...
done.
Installing dependencies
Downloading and installing node v10.16.3...
Downloading https://nodejs.org/dist/v10.16.3/node-v10.16.3-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
@mbwatson
mbwatson / dirTree.js
Last active October 8, 2019 13:21
Node script to return an array of a directory's contents, with subdirectories as objects, e.g., [ 'file1', 'file2', { 'dirName': [contents] }]
/*
# dirTree.js
## Usage
Execute this in your terminal by passing the directory
to scan as a parameter to this script like:
$ node dirTree.js path/to/some/directory