Skip to content

Instantly share code, notes, and snippets.

View britweb-tim's full-sized avatar

Tim Lockwood britweb-tim

View GitHub Profile
@britweb-tim
britweb-tim / wp-cli-wc-import-csv.php
Last active April 4, 2024 16:58
Add a WP CLI Command for importing woocommerce products from csv
<?php
// Add a WP CLI Command which allows import of CSV files from the command line.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once WP_PLUGIN_DIR . '/woocommerce/includes/import/class-wc-product-csv-importer.php';
// Maybe require and invoke any other filters you need here as theme/plugins may not be loaded at this point.
class WP_CLI_WC_Import_CSV {
@britweb-tim
britweb-tim / Contract Killer 3.md
Created December 4, 2019 13:34 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@britweb-tim
britweb-tim / snapshot.sh
Last active April 15, 2016 12:08
Snapshot all disks in current project with Google Cloud Console
#!/bin/bash
#
# Inspired by http://gcloud-script-disk-snapshot.blogspot.co.uk/2015/04/gcloud-snapshot-script.html
#
#Delete the snapshots older than 7 days
retention_preiod=7
removal_date=`date --date="$retention_preiod days ago" +%Y%m%d%H%M%S`
dt=`date +%Y%m%d%H%M%S`
echo $dt
#Delimiter to exclude is "\|"
@britweb-tim
britweb-tim / s3deleteold.sh
Last active April 11, 2016 12:28
Script to delete old files from amazon s3
#!/bin/bash
# Usage: ./deleteOld "bucketname" "30 days"
s3cmd ls $1 | while read -r line; do
createDate=`echo $line|awk {'print $1" "$2'}`
createDate=`date -d"$createDate" +%s`
olderThan=`date -d"-$2" +%s`
if [[ $createDate -lt $olderThan ]]
then
fileName=`echo $line|awk {'print $4'}`