Skip to content

Instantly share code, notes, and snippets.

@UInIQ
UInIQ / supplant.sh
Created May 14, 2018 16:47
Replaces one branch w/ another entirely
#!/bin/bash
bgBlack=$(tput setab 0) # black
bgRed=$(tput setab 1) # red
txBold=$(tput bold) # bold
txReset=$(tput sgr0) # reset attributes
txStandout=$(tput smso) # standout
txEndStand=$(tput rmso) # exit standout
echo "${bgBlack}${fgRed}${txBold}
+==============================================================+
@UInIQ
UInIQ / DeDupeLines.js
Last active August 15, 2023 17:42
JS + REGEX: Remove duplicate lines
function dedupe(strToDedupe, caseSensitive=false){
let rpl = (caseSensitive) ? /^(.*)(\r?\n\1)+$/gm : /^(.*)(\r?\n\1)+$/gim
return(strToDedupe.replace(rpl, ""));
}
@UInIQ
UInIQ / domain.sh
Created April 17, 2018 16:06
Multi-threaded checker for domain availability in BASH
#!/usr/bin/env bash
##################################################################################################################
DOMAINSAVE=""
function domain(){
read -rp "Enter JUST THE DOMAIN portion you wish to check (omitting the subdomain and TLD) . > " domainToCheck;
read -rp "Utilize custom DNS? (enter DNS or Enter to skip) > " dns;
#read -rp "Enter JUST THE DOMAIN portion you wish to check. > " domainToCheck;
@UInIQ
UInIQ / cardInfo() Determines if a credit card number is valid and returns the name of the issuing network.
// cardInfo()
//
// Determines if a credit card number is valid and returns the name of the issuing network. When
// passed a purported card number as a candidate if the card number is valid, the cardInfo()
// function returns a boolean flag ('isValid') indicating if the card is a valid number and a
// string ('network') containing the name of the issuing network. Card validity is determined
// based upon the card number length and Luhn check digit value. Valid card lengths are based
// upon the card lengths valid for a given issuing network. The Luhn check digit is calculated
// using the Luhn algorithm. The function contains a static table ('IINData') that defines the
// supported issuing network. The table is not a complete list--it is only meant to contain
@UInIQ
UInIQ / gittyup.sh
Last active March 14, 2018 21:51
Makes a trivial alteration to the final line of a file to ensure github flags it as changed
#!/bin/bash
# Usage:
# gig path_to_file path_to_other_file
function gittyup(){
# Iterate the function arguments
for item in "$@"; do
# Append a block comment to the end of the specified file.
echo " /**/ " >> $item;
done
@UInIQ
UInIQ / gitignore.sh
Created March 10, 2018 22:05
Add indeterminate number of files to .gitignore at specific hierarchy, then condense and purge duplicates.
#!/bin/bash
# Usage:
# gig path_to_file path_to_other_file
function gig(){
# Iterate the function arguments
for item in "$@"; do
# Append each to .gitignore at current folder level
echo "$item" >> .gitignore;
done
@UInIQ
UInIQ / AEM.getParentProps
Created March 8, 2018 18:34
HTL Getting Property value from parent component
//https://forums.adobe.com/message/9552896#9552896
"use strict";
use(function () {
var parent = resource.getParent();
var props = parent.adaptTo(Packages.org.apache.sling.api.resource.ValueMap);
return props.get("jcr:createdBy","");
});
@UInIQ
UInIQ / <[JS] element.AddEventListener
Created March 2, 2018 08:50
Check event bindings on every object (appended at the prototyppe level)
[Element].forEach(function(self){
self.prototype.activeListeners = {};
self.prototype._addEventListener = self.prototype.addEventListener;
self.prototype.addEventListener = function(type, handle, useCapture) {
useCapture = useCapture || false;
node._addEventListener(type, handle, useCapture);
var node = this;
@UInIQ
UInIQ / background.js
Created February 20, 2018 19:00
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});