Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
ArangoDB is kinda cool

Paceaux paceaux

💭
ArangoDB is kinda cool
View GitHub Profile
@paceaux
paceaux / classname.regex.js
Created Jan 5, 2021
A Regex for finding a class name in html
View classname.regex.js
/*
where "title" is the full class name
/class=(.*[ "]title[ "].*)/g
*/
const className = 'title';
const regex = new RegExp(`/class=(.*[ "]${className}[ "].*)/g`);
@paceaux
paceaux / jscss.js
Last active Oct 29, 2020
JSCSS, The quick and easy way to do CSS in the DOM
View jscss.js
/**
* Class for adding CSS with JavaScript that relies on the CSSOM
*/
class JSCSS {
/**
* @param {string} cssText Text for a stylesheet. Rulesets, queries, and all
*/
constructor(cssText = '') {
const sheet = JSCSS.addStyleSheet();
this.stylesheet = JSCSS.getStyleSheet(sheet.title);
@paceaux
paceaux / queryCSSProperty
Last active Oct 19, 2020
Get all CSS selectors containing a particular CSS property
View queryCSSProperty
/** queryCSSByPropertyName
* queries the CSSOM looking for CSS rulesets containing a particular CSS property.
* @param {string} queryPropName CSS property name
* @param {string} queryPropValue value of CSS property
* @returns Map with key as CSS selector, value as CSS properties.
*/
function queryCSSByProperty(queryPropName, queryPropValue) {
const styleSheets= document.styleSheets; // get all the stylesheets
const properties = new Map(); // set up the variable that'll store our result
@paceaux
paceaux / tinyRules.css.md
Last active Aug 23, 2020
Tiny rules for how to name things in CSS and JS
View tinyRules.css.md

Tiny rules for how to name stuff

CSS

How to name CSS classes

Stateful Class names

Is it a state that is only one of two conditions? (i.e. a boolean)

@paceaux
paceaux / debug.css
Last active Aug 5, 2020
A Sass/SCSS debug mixin
View debug.css
.isDebugging .debug {
outline: 1px solid rgba(200, 100, 50, 0.9);
}
.isDebugging .debug * {
outline: 1px solid rgba(200, 100, 50, 0.9);
}
@paceaux
paceaux / graphicEQUrl.js
Last active Jun 28, 2020
Graphic EQ in a url
View graphicEQUrl.js
/* Courtesy of Jake Albaugh: https://twitter.com/jake_albaugh/status/1118611365508337665 */
const bars = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"];
const ctx = new AudioContext();
const analyser = ctx.createAnalyser();
analyser.fftSize = 32;
const uIntArray = new Uint8Array(16);
navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
ctx.createMediaStreamSource(stream).connect(analyser);
updateUrl();
@paceaux
paceaux / SearchMap.js
Last active Jun 5, 2020
SearchMap: A JavaScript Map with searchable keys
View SearchMap.js
/** Evaluates an array, makes the key lowercasee and makes the value an object with original keyname
* @param {Array} iterable=[] an array of arrays:[[key,val],[key,val]]
* @returns Array
*/
function LowercaseIterable(iterable = []) {
if (iterable.length === 0) return [];
const newIterable = iterable.map(([key, val]) => {
const entry = [
key.toLowerCase(),
View this.js
const these = _itshelf = itshelf = _shelf = shelf = _itself = itself =_self = self = _me = me = _that = that = _this = this;
@paceaux
paceaux / sorter.py
Last active Feb 19, 2020
Camera Phone Image Sorter
View sorter.py
# Description:
# Sorts files created with a date and time in the file name, puts them in their respective folders
# This was created to sort images taken with a Samsung Galaxy phone
# Expected file naming convention is
# "year-month-day hour.minute.second.fileextension"
# "2017-7-5 18.23.45.jpg"
#
#
# requires Pillow:
# pip install Pillow
View iterators.arrays.js
/** Creates an array that, when iterated, only returns ruthy items
* @param {array} iterable
*
* @example const mixedBag = new TruthyArray(1, 0, 'foo', '', true, false, undefined, null, 'three'])
* for (item of mixedBag) {
* console.log(item);
* }
*
*/