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 / 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 *
@Willshaw
Willshaw / query-to-excel.cfm
Last active Nov 21, 2017
coldfusion query to excel
View query-to-excel.cfm
<cfscript>
obj_query = new core.utility.queryWrapper();
lst_columns = 'id,email';
lst_columns_for_sql = listQualify(lst_columns, "`" );
str_select = '
SELECT #lst_columns_for_sql#
FROM `allcars`.`users`
@Willshaw
Willshaw / coldfusion-datasource-setup
Created Mar 31, 2017
Simple Script for Local Development to setup coldfusion datasources
View coldfusion-datasource-setup
<cfscript>
writeOutput('starting db source installation...<br/ >');
function createDSN( name ) {
// Login is always required. This example uses two lines of code.
adminObj = createObject("component","cfide.adminapi.administrator");
adminObj.login("pete", "admin");
// Instantiate the data source object.
myObj = createObject("component","cfide.adminapi.datasource");
// Create a DSN.
@Willshaw
Willshaw / download-files-push-to-s3
Last active Apr 12, 2016
Download a load of files from the web and push to an s3 bucket
View download-files-push-to-s3
#!/bin/bash
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
You can’t perform that action at this time.