Skip to content

Instantly share code, notes, and snippets.

View stevenkuipers's full-sized avatar
🌍
Working from home - stay safe

Steven Kuipers stevenkuipers

🌍
Working from home - stay safe
View GitHub Profile
@stevenkuipers
stevenkuipers / ID.js
Created March 4, 2019 22:14
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@stevenkuipers
stevenkuipers / placeholder.json
Last active January 26, 2019 11:35
placeholder data
[
{
"id": 1,
"type": "collection",
"placeholder_title": "Some title",
"title": "The Fox Inn",
"image": "-r5KSMkyoSc",
"rating": 6.7
},
{
{
"esversion" : 6
}
@stevenkuipers
stevenkuipers / time.js
Last active October 31, 2018 13:13
Time string format
// @Param integer - Takes an integer as input
// integer from parameter n, where n represents number of seconds
// Returns a string in the format HH:MM:SS
// @Return string
// from this SO post https://stackoverflow.com/a/25279399/7384523
function createTimeString(n){
var date = new Date(null);
@stevenkuipers
stevenkuipers / _spacing-helpers.scss
Created October 29, 2018 20:57 — forked from jacurtis/_spacing-helpers.scss
SASS Margin and Padding Helpers Loop. Generates .m-t-10 type helper classes.
/*
This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects.
It will generate several classes such as:
.m-r-10 which gives margin-right 10 pixels.
.m-r-15 gives MARGIN to the RIGHT 15 pixels.
.m-t-15 gives MARGIN to the TOP 15 pixels and so on.
.p-b-5 gives PADDING to the BOTTOM of 5 pixels
.p-l-40 gives PADDING to the LEFT of 40 pixels
@stevenkuipers
stevenkuipers / date.js
Created August 22, 2018 13:02
js function that returns a date string dd-mm-yyyy and a function to compare two of these strings
// returns a date string in format dd/mm/yyyy
function dateOfToday(){
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){
dd='0'+dd;
@stevenkuipers
stevenkuipers / action-script-google.js
Last active October 25, 2019 08:56 — forked from mhawksey/gist:1276293
Google App Script to insert data to a google spreadsheet via POST or GET
/*
Version adjusted and updated October 2018 - Steven Kuipers
* Removed some unnecessary variables and updated some obsolete methods (serviceLock)
* Updated Usage to better reflect need to manage versions before each deployment.
-----
Copyright 2011 Martin Hawksey
Original post - https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
Licensed under the Apache License, Version 2.0 (the "License");
@stevenkuipers
stevenkuipers / html-advanced.cson
Last active August 2, 2018 13:26
Atom snippet for more advanced HTML boilerplate
# A snippet for ATOM editor
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# One of the packages that come with ATOM is language-html, this package provides snippets
# for a most HTML-tags, including <html>
# I find it lacking in some places so I extended it.
#
# * Copy the following code into snippets.cson in you ATOM editor.
@stevenkuipers
stevenkuipers / high-dpi-media.css
Created July 27, 2018 12:41 — forked from marcedwards/high-dpi-media.css
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
@stevenkuipers
stevenkuipers / wrapText.js
Created May 23, 2018 09:51
A textwrapper for canvas text, specify a maximum width and it will break sentences into different lines.
// @Params Object - CanvasRenderingContext2D
// String
// Integer - X coordinate
// Integer - Y Coordinate
// Integer - Maxwidth of textBox
// Integer - Lineheight
// function will split words and add linebreaks if sentences are longer than specified max width,
// if sentence is rearranged it will return an object with the new line, x and y coordinates.
// @Returns Object