Skip to content

Instantly share code, notes, and snippets.

@woodwardtw
woodwardtw / french_time_dropdowns.js
Created April 23, 2024 13:12
A Google script to dynamically change the data validation rules based on the selection from another cell.
function onEdit(){
const ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const entries = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("entries");
const dropDowns = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("dropdowns");
const activeCell = entries.getCurrentCell();
const activity = activeCell.getValue();
if(activeCell.getColumn() == 3 && activeCell.getRow() > 1){
activeCell.offset(0,1).clearContent().clearDataValidations();
@woodwardtw
woodwardtw / index.php
Created January 26, 2024 15:19
example helper plugin for Skidmore
<?php
/*
Plugin Name: Skidmore Multisite Helpers
Plugin URI: https://github.com/
Description: A network activated plugin used to house small functions that apply to all sites.
Version: 1.0
Author: Tom Woodward et al.
Author URI: https://tomwoodward.us
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
section.part header h1,
section.chapter header h1,
.front-matter h5,
.part h5,
.chapter h5,
.back-matter h5,
body#tinymce.wp-editor h5,
.front-matter h2,
.part h2,
.chapter h2,
<?php
class td_block1_widget extends td_block_widget {
var $td_block_id = 'td_block_1'; // change only the block id, the rest is autogenerated
}
add_action('widgets_init', function (){
register_widget("td_block1_widget");
}
@woodwardtw
woodwardtw / config.json
Last active August 16, 2023 12:37
IIIF manifest in themes > theme name > asset > universal viewer - update on Aug 16 to hide top bar tools (which failed)
{
"options": {
"bookmarkThumbHeight": 150,
"bookmarkThumbWidth": 90,
"leftPanelEnabled": true,
"limitLocales": true,
"minWidthBreakPoint": 610,
"navigatorEnabled": true,
"openTemplate": "http://universalviewer.io?manifest={0}",
"overrideFullScreen": false,
@woodwardtw
woodwardtw / tellmeyoursecrets.js
Last active June 9, 2023 02:40
google script that lists a lot of info about the files in a particular folder/sub folder structure including viewers, editors, and sharing permissions
function listFolders(folder) {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "Sharing Access", "Sharing Permission", "Get Editors", "Get Viewers", "Date", "Size", "URL", "Download", "Description", "Type"]); //writes the headers
var folder = DriveApp.getFolderById("YOUR_FOLDER_ID");//that long chunk of random numbers/letters in the URL when you navigate to the folder
var files = folder.getFiles();//initial loop on loose files w/in the folder
var cnt = 0;
var file;
@woodwardtw
woodwardtw / Google Map Marker LatLong
Last active April 25, 2023 13:16
A draggable Google Map marker that auto locates and updates on maker drag
<!DOCTYPE html>
<html>
<head>
<title>Geolocation</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0px;
@woodwardtw
woodwardtw / import_pressbooks_glossary.php
Created April 18, 2023 12:19
Import Pressbooks Glossary Items from CSV. Doesn't do location currently, but could if the data structure gets shared.
function pb_add_glossary_item(){
if (($handle = fopen(plugin_dir_path(__FILE__) . "test.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) {
ini_set('auto_detect_line_endings',TRUE);
foreach ($data as $key => $line) {
// code...
$data_array = explode(",", $line);
$args = array(
'post_title' => $data_array[0],
'post_content' => $data_array[1],
@woodwardtw
woodwardtw / gdp.py
Created March 31, 2023 13:37
China vs US GDP comparison from 2016-2020 generated by free version of ChatGPT in March 2023
import pandas as pd
import matplotlib.pyplot as plt
# Create a dictionary of GDP data for the USA and China from 2016 to 2020
data = {
'Country': ['USA', 'China'],
'2016': [18624475, 11233273],
'2017': [19542968, 12408149],
'2018': [20580518, 13608152],
'2019': [21433226, 14271038],
@woodwardtw
woodwardtw / wp-options-page-count-snippet.php
Last active February 23, 2023 17:45
set the page count in wp_options
<?php
//UPDATE wp_options with page count
function wmps_page_count(){
$page_count = wp_count_posts('page')->publish;
if ( get_option( 'wpms_data_pages_count' ) !== false ) {
update_option('wpms_data_pages_count', $page_count);
} else {
add_option('wpms_data_pages_count', $page_count);
}
}