Skip to content

Instantly share code, notes, and snippets.

davidsheardown / script.babel
Created Apr 15, 2022
Simple Draggable Canvas Circle - 39 Characters in ZIMjs
View script.babel
const frame = new Frame("fit", 800, 600, "#EEE", "#555");
frame.on("ready", ()=>{
zog("ready from ZIM Frame"); // logs in console (F12 - choose console)
// often need below - so consider it part of the template
const stage = frame.stage;
const stageW = frame.width;
const stageH = frame.height;
davidsheardown / javascript-live.js
Created Dec 26, 2021
Javascript version of jQuery live (dynamic element) binding
View javascript-live.js
function jslive(eventType, elementId, cb) {
document.addEventListener(eventType, function (event) {
if ( === elementId) {, event);
// Params are: event type (click, mouseover etc), element to look for (id or class etc), callback function
jslive("click", ".my-class", function (event) {
davidsheardown / sp_add_image_to_SQL
Created Nov 2, 2021
Add image to SQL encoded it Base64
View sp_add_image_to_SQL
CREATE PROCEDURE [dbo].[sp_add_image_to_SQL]
@ImageId int,
@ImageFilePath nvarchar(255)
DECLARE @sql_string nvarchar(max) =
davidsheardown / ReturnISOdate.sql
Created Oct 5, 2020
Return ISO date the easy way!
View ReturnISOdate.sql
Replace "getdate()" with whatever date you need i.e. a field
select convert(nvarchar(17),getdate(),127)+'00.00Z' as myISOdate
davidsheardown / jQuery DIV Toggle.html
Created Jul 30, 2020
Simple example of a div toggle (visible/in-visible) for quick ref
View jQuery DIV Toggle.html
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<meta charset="utf-8">
View MS SQL Get Date as Monday of Current week.sql
Get date as Monday of current week.. just change the "0" in the last param to whichever day you need
i.e. SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 2) would return date as Wednesday of current week
Handy to do date between or greater than checks
View CTE Recursive Running Total.sql
Using a CTE, we can iterate through to get the previous row in order to calculate and keep
a running total
WITH PrevRow
AS (SELECT Acolumn,
HoldingColumn = Bcolumn,
RunningTotal = HoldingColumn
FROM Atable
davidsheardown / HeaderAndLinesCountCompare.sql
Created May 4, 2020
Compare Row Count of Lines to Batch Header Count
View HeaderAndLinesCountCompare.sql
Quick query to compare a count total at header level to line count of successful rows i.e. 1 -> Many integrity check
to ensure the correct row count of lines matches header
davidsheardown / ms-sql-calendar-working-days.sql
Created Mar 9, 2020
MS-SQL Work out next working day accounting for weekends and public holidays
View ms-sql-calendar-working-days.sql
This was from another source, probably good old Stackoverflow! but capturing here for quick reference
This script will create a calendar table, generate a stored proc to populate it working out weekends and also if you provide
a set of holiday dates, it will add those too.
The end result is a couple of select statements that allows you to pass a date (todays date as default), then add/subtract
number of days to calculate the next working date based on the above weekends and/or holidays
CREATE TABLE [dbo].[Calendar](