Skip to content

Instantly share code, notes, and snippets.

View ryanve's full-sized avatar
📶
stay free

deepskyblue ryanve

📶
stay free
View GitHub Profile
@ryanve
ryanve / .gitignore
Created May 22, 2020 20:45
ignore image file formats with .gitignore
.DS_Store
*.[gtGT][iI][fF]
*.[jJ][pP][gG]
*.[jJ][pP][eE][gG]
*.[hH][eE][iI][cfCF]
*.[pP][nN][gG]
*.[wW][eE][bB][pP]
@ryanve
ryanve / pure.js
Created April 19, 2020 05:17
Create fresh pure new array from the indexes of an array or object based on the length
function pure(like) {
var fresh = []
var i = ~~like.length
while (i-->0) fresh[i] = like[i]
return fresh
}
@ryanve
ryanve / classing.md
Last active December 31, 2017 23:21
Classing singleton interface example
const facade = Object.freeze({
  "Example": "inline-block p2",
});

const classing = function(name) {
  if (!facade.hasOwnProperty(name)) throw new Error("Unknown classing: " + name);
  return facade[name];
}
@ryanve
ryanve / data-compute.js
Last active December 26, 2017 17:20
[data-compute]
$(function() {
function report() {
$("[data-compute]").each(function() {
var element = $(this)
element.text(element.css(this.dataset.compute));
})
}
report()
$(window).resize(report)
@ryanve
ryanve / IIFE.md
Last active February 2, 2019 00:30
JavaScript closure patterns

IIFE (Immediately Invoked Function Expression)

!function() {
  // Code in here is encapsulated
}();

Note that ! or + is safer than () because () could invoke preceding code.

@ryanve
ryanve / box-shadow.md
Last active November 17, 2017 19:44
CSS box-shadow composition techniques
@ryanve
ryanve / useColor.js
Last active November 12, 2017 20:03
swap stylesheet via <select> and save choice in storage
!function() {
var handle = "useColor";
var storage = window.sessionStorage;
var href = storage && storage.getItem(handle) || "";
var control = document.getElementById(handle);
if (!control) throw new Error("Unused code.");
var head = document.head;
var link = document.createElement("link");
link.rel = "stylesheet";
control.value = link.href = href;
@ryanve
ryanve / test.js
Created November 11, 2017 02:28
Validate HTML file in node using html-validator
const fs = require("fs")
const validator = require("html-validator")
const validateFile = (file) => {
fs.readFile(file, "utf-8", (err, content) => {
if (err) throw err;
console.log("Validating:", file);
validator({
data: content,
format: "text",
}, (err, report) => {
@ryanve
ryanve / brad.md
Last active November 1, 2017 17:22
An Event Apart 2017 notes

brad frost let's business core values the culture engine com ubuntu design voice and tone special snowflake syndrone carbon design sys unity glue

@ryanve
ryanve / README.md
Created October 30, 2017 01:13 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version