Skip to content

Instantly share code, notes, and snippets.

View timtomch's full-sized avatar

Thomas Guignard timtomch

View GitHub Profile
@timtomch
timtomch / patente-cnc-grbl-settings.txt
Created March 9, 2024 22:00
Réglages par défaut des contrôleurs GRBL des CNC de la Patente
$0=10 (Step pulse time, microseconds)
$1=25 (Step idle delay, milliseconds)
$2=0 (Step pulse invert, mask)
$3=0 (Step direction invert, mask)
$4=0 (Invert step enable pin, boolean)
$5=0 (Invert limit pins, boolean)
$6=0 (Invert probe pin, boolean)
$10=1 (Status report options, mask)
$11=0.010 (Junction deviation, millimeters)
$12=0.002 (Arc tolerance, millimeters)
@timtomch
timtomch / count-objects-types.sh
Last active July 3, 2023 18:35
Break down media objects by type for Smithsonian elements
#!/bin/zsh
setopt extendedglob
echo "\nMedia type breakdown for CC0 objects:\n"
for file in ^index.txt
do
cat $file |jq -c '. | select((.type=="edanmdm") and (.content.descriptiveNonRepeating.online_media.mediaCount>0) and (.content.descriptiveNonRepeating.online_media.media[].usage.access=="CC0")) | .content.descriptiveNonRepeating.online_media.media[].type'
done | sort | uniq -c
@timtomch
timtomch / si-count-objects.sh
Last active July 3, 2023 18:27
Count Smithsonian objects and list rights available in freetext element
#!/bin/zsh
# This script needs to be run inside the Smithsonian institution folder (where all the 00.txt, 01.txt, ... files are)
setopt extendedglob
echo "Records of type ead_component: "
for file in ^index.txt
do
cat $file |jq -c '. | select(.type=="ead_component") | .id' | wc -l
done | awk '{sum += $1} END {print sum}'
echo "\nRecords of type edanmdm with images: "
@timtomch
timtomch / rightscounter.jq
Created November 17, 2021 22:21
Count DPLA objects by rights status
def counter(stream):
reduce stream as $s ({}; .[$s|tostring] += 1);
counter(.[] | select(."_source".sourceResource.type) | select(."_source".sourceResource.type[] | test("^image|physical object")) | ."_source".rights)
[
{
"op": "core/column-addition",
"description": "Create column query string at index 5 based on column NOTICE - PUB using expression grel:join(with(value.split(\" \"),a,forEach(a,v,v.chomp(\",\").match(/([a-zA-Z\\u00C0-\\u017F-']{4,}|\\d{4})/)[0])),\" \")+\" \"+forNonBlank(cells[\"NOTICE - AUT\"],v,v.value.match(/(.* |)(\\w{2,})/)[1],\" \")",
"engineConfig": {
"mode": "row-based",
"facets": [
{
"mode": "text",
"caseSensitive": false,
@timtomch
timtomch / GetPrice.json
Last active June 7, 2021 14:10
OpenRefine operations to get minimum price data from ISBNdb.com -- Edit: no longer working due to ISBNdb API changes
[
{
"op": "core/column-addition-by-fetching-urls",
"description": "Create column ISBNdb Price at index 2 by fetching URLs based on column pISBN using expression grel:\"http://isbndb.com/api/v2/json/YOURKEY/prices/\"+toString(floor(value))",
"engineConfig": {
"mode": "row-based",
"facets": []
},
"newColumnName": "ISBNdb Price",
"columnInsertIndex": 2,
@timtomch
timtomch / weather-int.py
Last active August 29, 2015 14:18
Sample Python script to use with the Hello World Code4Lib code club
# weather-int.py - get average temperature data from the World Bank ClimateWeb API
#
# Usage: python weather-int.py XXX where XXX is a ISO 3-letter country code
# e.g. CAN, USA, GBR
#
# Collectively written during the Feb 5-6 Software Carpentry workshop
# at the University of Toronto iSchool.
# https://swcarpentry.github.io/2015-02-05-toronto
# Edited by Thomas Guignard <tom@timtom.ca> for the Code4Lib Monday Night code club
# Version: March 30, 2015
@timtomch
timtomch / backup-web.sh
Last active August 29, 2015 14:09
Backup home directory on web server (cron task)
#!/bin/bash
tar czf path/to/backup/dir/webbackup_`date +%Y_%m_%d`.tgz -X backup-exclude.txt -C path/to/public_html public_html/
@timtomch
timtomch / AACtoMP3.sh
Last active August 29, 2015 14:08
Batch AAC to MP3 convert
export PATH=/usr/local/bin:$PATH
# for use within Automator, the path to usr/local/bin has to be added
# so that faad and lame can be used
# last argument is the output path - add a trailing slash
outputpath=${@:$#}"/"
# start numbering depending on the # of files already in that directory
count=$(ls -1 $outputpath | wc -l)