Skip to content

Instantly share code, notes, and snippets.

townivan / post-about-flexbox.txt
Last active Jul 27, 2022
Return to my post about Flexbox at
View post-about-flexbox.txt
See link above. Trying a goofy way to attach comments to a generic page.
townivan / getCurrentYear.html
Created Jan 4, 2022
Display the current year without having to manually update it each time.
View getCurrentYear.html
<span id="cdate"></span><script>document.getElementById("cdate").innerHTML = (new Date().getFullYear());</script>
townivan / a11y-tracking-pixels.js
Last active Jun 17, 2021
Those annoying tracking pixels mess up my a11y scan. This is an attempt to add alt, role, and aria attributes to these guys. Uses MutationObserver to immediately update the img tags when they are added to the DOM by the tracking snippet's action.
View a11y-tracking-pixels.js
// early in the head as possible
var observer = new MutationObserver(function(mutations){
for (var i=0; i < mutations.length; i++){
for (var j=0; j < mutations[i].addedNodes.length; j++){
observer.observe(document.documentElement, {
townivan / setAttrib.js
Created Oct 6, 2020
a function to set an attribute with JavaScript
View setAttrib.js
function sestAttrib(el_id, el_attr, el_value){
if (document.getElementById(el_id)){ // if element exists
document.getElementById(el_id)[el_attr] = el_value;
View dotNetCorePractice.cs
using System;
using System.Collections.Generic;
// test at
public class Program
public static void Main()
Console.WriteLine("List practice");
townivan / setup.js
Last active Dec 26, 2019
quick gulp4 project setup
View setup.js
npm i gulp -D
npm i browser-sync -D
npm i gulp-sass -D
// favicon fix for index.html
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
touch gulpfile.js
// This gulpfiles expect a 'dist' and 'src' folder (for easy ftp, less easy for github pages)
View ie11-DOM-looping.js
// converting nodelist to an array...for ie11:
// ie11 won't like [...nodelist] or Array.from(nodelist) so use:
let elements ='.things'));
// looping through the array....for ie11:
// ie11 won't like so use:
elements.forEach(function(el) {
console.log('el:', el);
View destructuring_useful.js
* Be amazed at this use for destructuring
* If you pass args as an obj instead of
* distinct values like f('red','male',23)
* You can use destructuring in the function
* to get what you want without needing to
* figure out which position it should be in!
function f( {name, age} = {}){ // destructure the received {} to name and age.
console.log('age:',age); // age: 23
townivan / local-php-on-mac.txt
Created Aug 22, 2019
Run php locally on mac
View local-php-on-mac.txt
php -S
townivan / find-that-object.js
Created Aug 16, 2019
Get a matching object from an array of objects with a specific value for a property
View find-that-object.js
thingArray.filter(thing => (thing.Name === "Larry"));