Skip to content

Instantly share code, notes, and snippets.

@lewiswalsh
lewiswalsh / submit-form.html
Last active May 27, 2022 18:57
Submit a form with a button outside the form #html
<form id="my-form">
<label for="name">Name:</label>
<input type="text" name="name"></input>
</form>
<button type="submit" form="my-form">Submit</button>
@lewiswalsh
lewiswalsh / windows-terminal-colours.json
Last active May 27, 2022 19:00
Amber, Green,and monochrome Blue (think WarGames) colour schemes for Windows Terminal
// Enable "experimental.retroTerminalEffect" and crank up the "fontSize"
// For that true WarGames look set "cursorShape" to "filledBox" and install this typeface:
// https://fontstruct.com/fontstructions/show/789830/wargames_2
{
"name" : "LW Amber CRT",
"foreground" : "#FFB000",
"background" : "#282828",
"cursorColor" : "#FFB000",
"black" : "#FFB000",
@lewiswalsh
lewiswalsh / insert_from_tables.sql
Created September 3, 2018 18:20
Insert into table from two other tables on common field
INSERT INTO ab_product_categories (category_id, product_id)
SELECT c.id AS category_id, p.id as product_id
FROM ab_products AS p, ab_categories AS c
WHERE c.old_id = p.old_cat_id;
@lewiswalsh
lewiswalsh / gist:1c54b213541e8f13e497f1e3a20e8e14
Created August 12, 2018 20:54
See time and other stats about a command
/usr/bin/time -v <your command or program with arguments>
@lewiswalsh
lewiswalsh / findpi.ps1
Created August 3, 2018 09:13
Find raspberry pi on the network
arp -a | findstr b8-27-eb
@lewiswalsh
lewiswalsh / vob2mp4.sh
Created July 24, 2018 11:53
Convert DVD VOB files to MP4
#!/bin/bash
ffmpeg -i "concat:VTS_01_1.VOB|VTS_01_2.VOB|VTS_01_3.VOB|VTS_01_4.VOB|VTS_01_5.VOB" -strict -2 outfile.mp4
@lewiswalsh
lewiswalsh / keybase.md
Created June 20, 2018 20:39
keybase.md

Keybase proof

I hereby claim:

  • I am lewiswalsh on github.
  • I am lewiswalsh (https://keybase.io/lewiswalsh) on keybase.
  • I have a public key ASCsSgDIC4Lp66CimJ8WmCzX70CIzBFMrsRhCx_Np_L4LAo

To claim this, I am signing this object:

@lewiswalsh
lewiswalsh / woocommerce_on_update.php
Last active May 27, 2022 19:06
Do something when a woocommerce product is updated #php #wordpress
<?php
add_action( 'added_post_meta', 'mp_sync_on_product_save', 10, 4 );
add_action( 'updated_post_meta', 'mp_sync_on_product_save', 10, 4 );
function mp_sync_on_product_save( $meta_id, $post_id, $meta_key, $meta_value ) {
if ( $meta_key == '_edit_lock' ) { // we've been editing the post
if ( get_post_type( $post_id ) == 'product' ) { // we've been editing a product
$product = wc_get_product( $post_id );
// do something with this product
}
}
@lewiswalsh
lewiswalsh / dodyndns.sh
Last active May 27, 2022 19:06
Update DigitalOcean domain record from bash #bash
#!/bin/bash
# Use CRON to regularly update for DIY DynDNS
PUBLIC_IPV4=$(curl ifconfig.co)
API_ACCESS_TOKEN=<your_access_token>
RECORD_ID=<your_record_id>
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer ${API_ACCESS_TOKEN}" -d '{"data":"'"${PUBLIC_IPV4}"'"}' "https://api.digitalocean.com/v2/domains/centralindustrial.co.uk/records/${RECORD_ID}"
@lewiswalsh
lewiswalsh / pi-camera-settings
Last active May 27, 2022 19:07
Octoprint mjpg-streamer Raspberry Pi camera settings #raspberrypi
camera_raspi_options="-x 1440 -y 1080 -fps 15 -quality 95 -sh 25 -br 60 -co 40 -sa 10 -awb fluorescent"