Skip to content

Instantly share code, notes, and snippets.

View scagood's full-sized avatar

Sebastian Good scagood

  • Hartley Wintney, UK
  • 18:54 (UTC +01:00)
View GitHub Profile

Hover-highlight-selectors

This will script will do a few things

  1. It will create a toggle able transparent box around the element you're hovering over.
  2. When control is held (with /flamencist/SelectorGenerator included) and an element is clicked a pop-up of the CSS-selector of the element you clicked on will show.
  3. This hover outline effect can be toggled using scroll lock on your keyboard.

Running

Simply include:

@scagood
scagood / domMonitor.js
Created January 29, 2018 16:43
Monitor the DOM for the creation of specific tags (Not sure what this can be used for... but hey!)
const domMonitor = function (tagname, eventname, options) {
tagname = tagname.trim().toLowerCase();
eventname = eventname.trim();
options = options || {};
const property = options.property || 'outline-color';
const propertyFrom = options.property || '#fff';
const propertyTo = options.property || '#000';
const evn = new Event(eventname, {
@scagood
scagood / 1.iFrame.Relative.Messages.md
Created January 29, 2018 16:18
iframe message events attached to the iframe, not the window

Attach message events to iframe elements

Usage

Very simply copy/download and include iframe.message.js into your document, then start attatching event listeners.

Example inclusions:

<script src="iframe.message.js"></script>

Or:

@scagood
scagood / getArgs.js
Created January 26, 2018 12:10
Provides a simple function to get the arguments of a function
function getArgs(func) {
/**
* Basic function regex
* - /^function\s*\w*\(([\w\W]*?)\)\s*{/
*
* Arrow function regex
* - /^([^()]*)\s*=>/
* - /^\(([\w\W]*?)\)\s*=>/
* */
@scagood
scagood / cssPath.js
Created January 25, 2018 12:55
A simple function to get the CSS style path of an element.
const cssPath = (function () {
function tagUnique(l) {
const es = [].filter.call(
l.parentElement.children,
e => e !== l
);
return -1 === []
.map.call(es, e => e.tagName)
.indexOf(l.tagName);
}
@scagood
scagood / Escaped Quote Matcher.md
Last active January 17, 2018 10:00
Match quotes inside strings. Images generated with (https://jex.im/regulex)

Escaped Quote Matcher

This is a javascript function that matches quotes while disregarding all escaped quotes.

Calling

outputArray = matchQuotes(
  inputString,
  chars,
 lengths,
@scagood
scagood / Node Version Manager for Windows .md
Last active January 17, 2018 10:01
A basic node version manager for windows

NVM windows ish

This will download and symlink to a specified nodejs version.

Installing

The batch file is dependent on both 7zip and curl, these are automatically downloaded (regardless of if they're already installed).

To install simply download the batch file, and add the NodeJS and nvm 'directories' to the %path% enviromnment variable. In my case my path became: %path%;%appdata%\nodejs;%appdata%\nvm

"use strict";
var Shape = function (el, colour) {
var color, shape,
that = this;
shape = el.getAttribute("shape-type") || "square";
change();
this.newColor = function (color) {
el.setAttribute("shape-color", color);
change();
@scagood
scagood / readme.md
Last active November 7, 2018 19:31
Simple markdown to html in javscript

Supported markdown:

Headers

# Header 1 => <h1>Header 1</h1>
## Header 2 => <h2>Header 2</h2>
### Header 3 => <h3>Header 3</h3>
#### Header 4 => <h4>Header 4</h4>
##### Header 5 => <h5>Header 5</h5>
###### Header 6 => <h6>Header 6</h6>