Skip to content

Instantly share code, notes, and snippets.

View VincentVToscano's full-sized avatar
💭
Leading the Production of Software Development Projects

Vincent V. Toscano VincentVToscano

💭
Leading the Production of Software Development Projects
View GitHub Profile
@VincentVToscano
VincentVToscano / convert_a_date_into_xml_schema_iso_8601_format.sh
Created July 27, 2023 17:47
Convert a Date into XML Schema (ISO 8601) format in bash
#Convert a Date into XML Schema (ISO 8601) format.
#2022-11-06T06:24:46-08:00
date -u +%FT%T%z
#2023-03-21T20:40:35+0000
date -u '+%Y-%m-%dT%k:%M:%S%z'
#2023-03-21T20:41:13+0000
@VincentVToscano
VincentVToscano / remove_undesired_characters_for_birthday_input_field.js
Created July 27, 2023 17:39
Remove undesired characters for birthday input field
const birthday_input = document.querySelector("#birthnumber");
const BIRTHNUMBER_ALLOWED_CHARS_REGEXP = /[A-Za-z0-9_-]+/;
birthday_input.addEventListener("beforeinput", e => {
if (!BIRTHNUMBER_ALLOWED_CHARS_REGEXP.test(e.data)) {
e.preventDefault();
}
});
@VincentVToscano
VincentVToscano / scroll_to_target_adjusted.js
Created July 27, 2023 17:37
Scroll to target (element) with an adjustment or offset
function scrollToTargetAdjusted(){
var element = document.getElementById('targetElement');
var headerOffset = 45;
var elementPosition = element.getBoundingClientRect().top;
var offsetPosition = elementPosition + window.pageYOffset - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: "smooth"
});
function getURLParameters() {
let urlString = window.location.href;
let paramString = urlString.split('?')[1];
let params_arr = paramString.split('&');
for (let i = 0; i < params_arr.length; i++) {
let pair = params_arr[i].split('=');
console.log("Key is:" + pair[0]);
console.log("Value is:" + pair[1]);
}
}
@VincentVToscano
VincentVToscano / query_or_search_nodelist_for_matches.js
Last active July 14, 2022 20:37
Search for Substring Matches within a NodeList
// Vars
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
const search_input = document.getElementById('product-search_input');
const search_products = document.querySelectorAll('data-product');
const searchVis = function (query, data) {
for (let i = 0; i < data.length; i++) {
if (!query || data[i].getAttribute('title').toLowerCase().indexOf(query) > -1) {
data[i].style['display'] = 'inline';
} else {
@VincentVToscano
VincentVToscano / homebrew_non-cask_top-level_formulas.sh
Created July 12, 2022 19:52
Listing all Installed Non-Cask Homebrew Formulas
#!/bin/bash
# Listing all Installed Non-Cask Homebrew Formulas
# If you are only looking to get all non-Cask top-level formulas and do not want to install
# a dependency just to obtain said list (e.g.: brew bundle dump). Use the following:
brew leaves | xargs -n1 brew desc
@VincentVToscano
VincentVToscano / get_estimated_reading_time.php
Last active October 20, 2020 16:31
Get the estimated reading time of an article, blog post, or custom post in WordPress
<?php
/**
* get_estimated_reading_time --- Get estimated reading time in minutes
* @author Vincent V. Toscano
* Created by Vincent on Oct. 19, 2020
* Updated Oct. 20, 2020
* Ref.: get_the_content https://developer.wordpress.org/reference/functions/get_the_content/
* Ref.: strip_shortcodes https://developer.wordpress.org/reference/functions/strip_shortcodes/
* Ref.: strip_tags https://www.php.net/manual/en/function.strip-tags.php
@VincentVToscano
VincentVToscano / getUsersLocalTimestamp.js
Created June 3, 2020 19:29
Get User’s local timestamp that can be utilized client or for inclusion on strings to be sent to backend.
/**
* getUsersLocalTimestamp --- Get User’s local timestamp for inclusion on strings sent to backend.
* @returns {string} "2020-06-03 @ 12:12:25"
* @usage getUsersLocalTimestamp()
*/
function getUsersLocalTimestamp() {
let date = new Date();
let yyyy = date.getFullYear().toString();
let mm = (date.getMonth() + 1).toString();
let dd = date.getDate().toString();
@VincentVToscano
VincentVToscano / animatedGradient.css
Last active May 9, 2020 00:01
Moves shades of blue across an element of choice
background: linear-gradient(307deg, #153cdb, #006aff, #06348a);
background-size: 600% 600%;
-webkit-animation: blueTide 17s ease infinite;
-moz-animation: blueTide 17s ease infinite;
-o-animation: blueTide 17s ease infinite;
animation: blueTide 17s ease infinite;
@-webkit-keyframes blueTide {
0%{background-position:0% 51%}
@VincentVToscano
VincentVToscano / SafariSVGBackgrounRedrawFix.js
Last active August 29, 2015 14:20
Safari 6 - 7.1.3 SVG Background Redraw Fix
/**
* Vincent V. Toscano
* Safari redraw fix --- Must be placed after the element is available.
* Notes:
* 1. Solution to the issue where Safari will not show animated SVG sprite sheet used as a background image of element until
* until the user interacts with the page/element.
* 2. This has been tested on Safari 6 - 7.1.3
* 3. Adjust timing to suite your needs
* 4. Enact this technique only once for any element that will not show/present on screen.
*/