Skip to content

Instantly share code, notes, and snippets.

View SteGriff's full-sized avatar
🪴
Springing

Stephen Griffiths SteGriff

🪴
Springing
View GitHub Profile
@SteGriff
SteGriff / Number.prototype.formatMoney.js
Created August 5, 2016 09:46
Adapted version of formatMoney
//From http://www.josscrowcroft.com/2011/code/format-unformat-money-currency-javascript/
// Extend the default Number object with a formatMoney() method:
// usage: someVar.formatMoney(decimalPlaces = 2)
Number.prototype.formatMoney = function (places) {
places = !isNaN(places = Math.abs(places)) ? places : 2;
thousand = ",";
decimal = ".";
var number = this,
i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
@SteGriff
SteGriff / SystemFonts.css
Created August 17, 2016 10:10
Universal System Font Family as used around the web
body
{
/* GitHub */
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
/* Zeit.co */
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;
/* Solid.systems */
/* Serif */
@SteGriff
SteGriff / colours.htm
Last active November 16, 2016 16:45
Experimenting with junk-data HTML colour names
<table>
<tr>
<td bgcolor="chucknorris" width="100" height="30"></td>
<td bgcolor="mrt" width="100"></td>
<td bgcolor="ninjaturtle" width="100"></td>
</tr>
<tr>
<td bgcolor="sick" width="100" height="30"></td>
<td bgcolor="crap" width="100"></td>
<td bgcolor="grass" width="100"></td>
@SteGriff
SteGriff / CallbackPuzzle.js
Created December 16, 2016 14:58
A javascript callback puzzle, or, why we prefer Promises to Callbacks
function a(callback)
{
console.log("a");
callback();
}
function b(callback)
{
console.log("b");
callback();
@SteGriff
SteGriff / ProcessReader.cs
Last active February 1, 2017 13:51
A tiny C# class to start a process and return its stdout text
using System;
using System.Diagnostics;
namespace SteGriff.Utilities
{
public class ProcessReader
{
public static string StartProcessAndGetOutput(string filename, string args = "")
{
ProcessStartInfo startInfo = new ProcessStartInfo()
@SteGriff
SteGriff / ProcessReader.vb
Last active February 1, 2017 14:02
A tiny VB module to start a process and return its stdout text
Public Module ProcessReader
Public Function StartProcessAndGetOutput(filename As String, Optional args As String = "") As String
Dim startInfo As New ProcessStartInfo() With { _
.CreateNoWindow = True, _
.RedirectStandardOutput = True, _
.RedirectStandardInput = True, _
.UseShellExecute = False, _
.Arguments = args, _
@SteGriff
SteGriff / SendPost.js
Created February 2, 2017 16:24
Send a POST request with Windows Script Host (when PowerShell is not available)
//Run me with cscript.exe
//Thanks https://gist.github.com/duncansmart/5821523
//Create easy reference to stdout for logging
var Console = WScript.StdOut;
//Create XHR object
var xhr = WSH.CreateObject("Microsoft.XMLHTTP");
var url = "http://www.some-url-to-ping/api/initialise";
@SteGriff
SteGriff / TinyAngularPangramApp.htm
Last active March 1, 2017 18:02
Tiny Angular Pangram App
<!DOCTYPE HTML>
<html ng-app>
<head>
<title>Tiny Angular Pangram App</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>
.spare{color:red;}
.used{text-decoration:line-through; color:blue;}
.w-100{width:100%;}
</style>
@SteGriff
SteGriff / add-if-not-exists.sql
Last active July 25, 2018 10:07
MS SQL cheat sheets for common tweaks
-- Add column to table
if not exists (
select *
from sys.columns
where object_id = OBJECT_ID('MyTable')
and name = 'MyNewColumn'
)
begin
alter table MyTable
add MyNewColumn nvarchar(20) null
@SteGriff
SteGriff / TruthyFalsyVBA.bas
Last active May 3, 2017 13:52
Test which values are truthy and falsy in VBA
'VBA
' Results:
' 1 is truthy but not equal to True
' -1 is truthy and == True
' 0 is falsy and == False
' "True" is truthy and == True
' "False" is falsy and == False
Public Sub Test()
If "True" Then