Skip to content

Instantly share code, notes, and snippets.

View scagood's full-sized avatar

Sebastian Good scagood

  • Hartley Wintney, UK
  • 16:44 (UTC)
View GitHub Profile

Execute using:

curl -Ss https://gist.githubusercontent.com/scagood/427950961eaa1e23a86cb25557427c8a/raw/systemd-networkd.sh | sudo sh

Example:

$ curl -Ss https://gist.githubusercontent.com/scagood/427950961eaa1e23a86cb25557427c8a/raw/e6e5c79d3931e7e7a88427a4e0c48fe463876c46/systemd-networkd.sh | sudo sh
[sudo: authenticate] Password: 
Writing systemd-networkd-wait-online override
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"declarationDir": "./types"
},
"files": [
"./src/index.js"
],
"include": [
@scagood
scagood / spectacle.sh
Created October 17, 2024 12:34
My screenshot shortcuts for spectacle
# All
spectacle -f -b -n -c -o "$HOME/Pictures/Screenshots/Desktop/$(TZ=UTC date +%Y-%m-%dT%H:%M:%SZ).jpg"
# Monitor
spectacle -m -b -n -c -o "$HOME/Pictures/Screenshots/Monitor/$(TZ=UTC date +%Y-%m-%dT%H:%M:%SZ).jpg"
# Window
spectacle -m -b -n -c -o "$HOME/Pictures/Screenshots/Window/$(TZ=UTC date +%Y-%m-%dT%H:%M:%SZ).jpg"
# Area
@scagood
scagood / find-executing-file.js
Created August 28, 2024 21:14
Find the file that was executed in a node program
const { normalize, join } = require('node:path');
/**
* @returns {string}
*/
function findExecutingFile() {
// This is covered in the 'package-eval' tests. Jest just does not know that...
/* istanbul ignore next */
return normalize(
// This is present for `type: commonjs` after startup

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,