Skip to content

Instantly share code, notes, and snippets.

Peter Williamson Willshaw

Block or report user

Report or block Willshaw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Willshaw
Willshaw / git_quick_commit.sh
Last active May 12, 2020
Short cut to git commit -m using folder path after httpdocs
View git_quick_commit.sh
# add this to your ~/.bashrc
# then as long as you're inside an httpdocs folder (e.g. /var/www/vhosts/example/httpdocs/my/awesome/tool)
# you can go like this:
# git add .
# git status (to be safe now)
# git_quick_commit I done some stuff
#
# and you'll get a commit message like:
# 45dcc35 my > awesome > tool: I done some stuff
#
@Willshaw
Willshaw / fixnetwork.bat
Created Mar 22, 2020
Quick batch file to disable/enable network adapter (mine is often slow on Windows 10 after waking from sleep)
View fixnetwork.bat
@rem save this file somewhere, then create shortcut like this
@rem C:\Windows\System32\cmd.exe /c "C:\path\to\fixnetwork.bat"
netsh interface show interface
@echo on
@rem Disable the adapter - make sure the quoted name matches your adapter name
netsh interface set interface "INSERT NETWORK ADAPTER NAME HERE" DISABLED
@rem Wait 2 seconds before re-enabling (again adapter names must be correct)
timeout /t 2
@Willshaw
Willshaw / random.js
Created Dec 31, 2019
Create a string of random numbers seperated by your mask
View random.js
// simply returns a single random number
const singleRandom = function singleRandom() {
return (Math.random() * 10).toFixed(0);
};
/*
accept a mask of seperators, e.g. / or //::
and return the mask strings surrounded by numbers.
- if the seperator changes, add a space
- / becomes X/Y
@Willshaw
Willshaw / truncate-vs-delete.sql
Last active Jan 30, 2019
Difference between TRUNCATE and DELETE
View truncate-vs-delete.sql
-- this was written for mysql to show how TRUNCATE does more than just DELETE all the rows
-- make sure you have a `test` database and a user with permissions to CREATE tables
DROP TABLE `test`.`test`;
CREATE TABLE `test`.`test`
(
`id` INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL,
`name` VARCHAR(32) NOT NULL
);
@Willshaw
Willshaw / plusplus-a-or-a-plusplus.js
Last active Jan 28, 2019
Show the difference between a++ and ++a
View plusplus-a-or-a-plusplus.js
/**
* update quantity based on button type
* make sure we don't go below zero
*/
if( action_type === 'minus' ) {
// this returned my value, then decremented it, so it never saved
// hitting the minus button always resulted in the same number
quantity = quantity ? quantity-- : 0;
@Willshaw
Willshaw / null-values-insert-select.sql
Created Jun 18, 2018
MySQL showing a NULL value converting to a 0 during an INSERT..SELECT...
View null-values-insert-select.sql
####################################
# #
# Example queries to demonsrate #
# how SELECTing a NULL value is #
# converting it into a 0 during a #
# INSERT...SELECT statement #
# #
####################################
# recreate an empty example price table
@Willshaw
Willshaw / gapps spreadsheet to pdf description
Created Mar 11, 2018
script to take text from a google spreadsheet and save it as the description on a pdf in google drive
View gapps spreadsheet to pdf description
/*
this script relies on a spreadsheet being called "test desc" and a pdf being called "test.pdf"
there needs to be a description in cell A1 of "test desc"
*/
function setNewDescription(file_id,description){
var file_by_id = DriveApp.getFileById(file_id);
Logger.log(file_by_id.getDescription());
@Willshaw
Willshaw / vue-counter.html
Last active Feb 20, 2018
Simple VueJS counter
View vue-counter.html
<!DOCTYPE html>
<html>
<head>
<title>Simple VueJS Counter</title>
</head>
<body>
<!-- we need the id of the element to attach to the vue application -->
<div id="app">
<!--
header tag for the page, will render "The value is: 0" on page load
@Willshaw
Willshaw / example.sh
Created Jan 4, 2018
simple start to a bash script
View example.sh
#!/bin/bash
################################
# to use the tracker:
# call the track script, using the full path to the script
# and also give it an action string, and a script string
#
# $REPO_PATH"bin/track.sh" "completed thing" $REPO_PATH"task_one"
#
# /path/to/script/bin/track.sh "action that happened" "script/that/is/doing/things"
@Willshaw
Willshaw / api.cfc
Last active Dec 20, 2017
auto reloading Vue/API table viewer
View api.cfc
/*
this file just needs to return an array of objects with key/value pairs
e.g. [{foo: 'bar', food: 'cheese'},{foo:'fighter',food:'jagermeister'}];
*/
component {
remote function load() {
var qry = new core.utility.queryWrapper();
var str_select = '
SELECT *
You can’t perform that action at this time.