This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// With the help of Jeremy Keith, I was able to create a fully scalable code sample that you can copy-paste into your project. | |
// It will save the user input value on blur, this includes radio buttons, checkboxes and date inputs besides regular text/number inputs. | |
// The only condition is that you give the form element on your page a data-attribute of data-form-topic="foo". | |
// This code snippet saves the data-attribute as the key to the localStorage, and the value of it will be an object with key/value pairs of the respective inputs name and value. | |
// Please refer to this gist somewhere in your code if you use it :) | |
// Happy coding! | |
// VARIABLE DECLARATIONS | |
// objects | |
let savedData = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks. | |
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) | |
(() => { | |
const SHOW_SIDES = false; // color sides of DOM nodes? | |
const COLOR_SURFACE = true; // color tops of DOM nodes? | |
const COLOR_RANDOM = false; // randomise color? | |
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com) | |
const MAX_ROTATION = 180; // set to 360 to rotate all the way round | |
const THICKNESS = 20; // thickness of layers | |
const DISTANCE = 10000; // ¯\\_(ツ)_/¯ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This gist describes the process of making a self-hosted installation | |
of Wordpress run with SQLite as a backing store, rather than MySQL. | |
This is not a step-by-step guide, and will require some degree of | |
comfort with your filesystem, editors, and logging. This involves | |
both fighting with and lying to these systems, and consequently | |
comes with no guarantees whatsoever. | |
--------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Camera2D | |
# Courtesy of KidsCanCode: http://kidscancode.org/godot_recipes/3.x/2d/screen_shake/ (this may change in the near future, so it may require a search) | |
# If you intend to use this, don't forget to turn on camera rotation! And keep in mind that smaller numbers are often the most useful - huge numbers make this thing *really* shake | |
# 3.5.x | |
export var decay = 0.8 # How quickly the shaking stops [0, 1]. | |
export var max_offset = Vector2(100, 75) # Maximum hor/ver shake in pixels. | |
export var max_roll = 0.1 # Maximum rotation in radians (use sparingly). | |
export (NodePath) var target # Assign the node this camera will follow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication | |
// http://creativecommons.org/publicdomain/zero/1.0/ | |
(function (win,doc) { | |
'use strict'; | |
if (!win.FileReader || !win.addEventListener || !doc.querySelectorAll) { | |
// doesn't cut the mustard. | |
return; | |
} | |
doc.querySelectorAll('input[type="file"][accept="image/*"]').forEach( function (fileInput) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Core assets | |
let coreAssets = []; | |
// On install, cache core assets | |
self.addEventListener('install', function (event) { | |
// Cache core assets | |
event.waitUntil(caches.open('app').then(function (cache) { | |
for (let asset of coreAssets) { | |
cache.add(new Request(asset)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// static/scripts/fixedsearch/fixedsearch.js | |
/*-------------------------------------------------------------- | |
fixedsearch — Super fast, client side search for Hugo.io with Fusejs.io | |
based on https://gist.github.com/cmod/5410eae147e4318164258742dd053993 | |
--------------------------------------------------------------*/ | |
if (typeof variable !== 'undefined') { | |
console.log('fixedsearch.js already loaded'); | |
} else { | |
fixedsearch = function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file should be saved as code.py | |
# At MagTag startup (or at wakeup time), keep one one of the 4 button pressed. | |
# The MagTag will switch to the program you choose and remember that decision at each wakeup. | |
# The trick is to have for each button one CircuitPython program to import. | |
# You can customise the app_to_start list, here is the current setting: | |
# no button => magtag_weather | |
# 1 (D15) => magtag_showtimes | |
# 2 (D14) => magtag_tree | |
# 3 (D12) => magtag_spacex | |
# 4 (D11) => magtag_year_progress_percent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Embedded Youtube player that combines: | |
* https://jameshfisher.com/2017/08/30/how-do-i-make-a-full-width-iframe/ | |
* https://css-tricks.com/lazy-load-embedded-youtube-videos/ | |
* https://stackoverflow.com/a/42555610/3225372 | |
* https://web.dev/iframe-lazy-loading/ | |
* https://github.com/paulirish/lite-youtube-embed/blob/a927d63781883088c185cb69a0baade52732ab3e/src/lite-yt-embed.js#L28 | |
Other things I am still thinking of adding: | |
* https://www.maxlaumeister.com/articles/hide-related-videos-in-youtube-embeds/ | |
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication | |
// http://creativecommons.org/publicdomain/zero/1.0/ | |
(function (win, doc) { | |
// Cut the mustard. | |
if (!win.localStorage) return; | |
// You should probably use a more specific selector than this. | |
var textarea = doc.querySelector('textarea'); | |
// The key for the key/value pair in localStorage is the current URL. | |
var key = win.location.href; |
NewerOlder