Skip to content

Instantly share code, notes, and snippets.

@FlantasticDan
FlantasticDan / global-search.js
Created July 1, 2024 18:47 — forked from stracker-phil/global-search.js
Recursively searches the entire object tree for a given value
/**
* Recursively searches the startObject for the given value.
*
* All matches are displayed in the browser console and stored in the global variable "gsResults"
* The function tries to simplify DOM element names by using their ID, when possible.
*
* Usage samples:
*
* globalSearch( document, 'someValue' ); // Search entire DOM document for the string value.
* globalSearch( document, '^start' ); // Simple regex search (function recognizes prefix/suffix patterns: "^..." or "...$").
CHARACTERS = {
' ': [
[0, 0, 0], # Blank
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
],
'0': [
[1, 1, 1], # 0
ACTION=="add", KERNEL=="gpiochip[0-1]*", MODE="0666"
ACTION=="add", KERNEL=="gpiomem", MODE="0666"
ACTION=="add", KERNEL=="spidev0.[0-1]*", MODE="0666"
[Unit]
Description=
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=ubuntu
function clearClass(className) {
let elements = document.getElementsByClassName(className)
for (let item of elements) {
item.classList.remove(className)
}
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="">
# Adapted from https://stackoverflow.com/questions/1095543/get-name-of-calling-functions-module-in-python
import inspect
def get_calling_module_name(depth: int = 1) -> str:
'''Check the module name of depth calls up the stack.'''
stack = inspect.stack()[depth]
caller = inspect.getmodule(stack[0])
return caller.__name__
@FlantasticDan
FlantasticDan / get_ordinal.py
Created March 2, 2021 09:37
Simple python method to get a number's ordinal ('st', 'nd', or 'th')
SUFFIXES = {1: 'st', 2: 'nd', 3: 'rd'}
def get_ordinal(i):
# Adapted from https://codereview.stackexchange.com/questions/41298/producing-ordinal-numbers
if 10 <= i % 100 <= 20:
return 'th'
else:
return SUFFIXES.get(i % 10, 'th')
@FlantasticDan
FlantasticDan / LowerThirdGenerator.jsx
Created November 3, 2020 08:37
Photoshop script that uses a .txt file to modify a text layer and export copies automatically.
#target photoshop
/*
Code for Import https://scriptui.joonas.me — (Triple click to select):
{"activeId":33,"items":{"item-0":{"id":0,"type":"Dialog","parentId":false,"style":{"enabled":true,"varName":null,"windowType":"Dialog","creationProps":{"su1PanelCoordinates":false,"maximizeButton":false,"minimizeButton":false,"independent":false,"closeButton":true,"borderless":false,"resizeable":false},"text":"Lower Third Generator","preferredSize":[350,0],"margins":16,"orientation":"column","spacing":10,"alignChildren":["center","top"]}},"item-1":{"id":1,"type":"Panel","parentId":0,"style":{"enabled":true,"varName":"sourceText","creationProps":{"borderStyle":"etched","su1PanelCoordinates":false},"text":"Source Text","preferredSize":[350,0],"margins":10,"orientation":"column","spacing":10,"alignChildren":["left","top"],"alignment":null}},"item-2":{"id":2,"type":"StaticText","parentId":1,"style":{"enabled":true,"varName":"sourceTextHelp","creationProps":{"truncate":"none","multiline":false,"scrolling":false},"softWrap