Skip to content

Instantly share code, notes, and snippets.

@matthewpenkala
matthewpenkala / colliding.js
Created March 6, 2022 14:07 — forked from jtsternberg/colliding.js
Detect if two elements are colliding/overlapping
/**
* Detects if two elements are colliding
*
* Credit goes to BC on Stack Overflow, cleaned up a little bit
*
* @link http://stackoverflow.com/questions/5419134/how-to-detect-if-two-divs-touch-with-jquery
* @param $div1
* @param $div2
* @returns {boolean}
*/
@matthewpenkala
matthewpenkala / docin-dl.py
Created October 16, 2022 21:59 — forked from nazarovsky/docin-dl.py
Docin document downloader
###############################################################################
#
# Docin document downloader
#
# Valid as of 2022-16-08
#
###############################################################################
import argparse
import os
from types import SimpleNamespace
@matthewpenkala
matthewpenkala / svg2icns.sh
Last active January 20, 2023 10:05 — forked from jesusmaloQ/svg2icns.sh
Convert SVG file to macOS icon (icns) format
#!/bin/sh -x
set -e
SIZES="
16,16x16
32,32x32
64,64x64
128,128x128
256,256x256
// Vanilla JavaScript - trim Leading and Trailing - ES5
function TrimVanilla(str) {
return str.trim();
}
// Older browsers - IE8 and before - using Polyfill. Call trim() method after running this.
function TrimPolyfill() {
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g, '');
@matthewpenkala
matthewpenkala / reenable-right-click.js
Created March 6, 2023 08:44 — forked from ahmadmysra/reenable-right-click.js
re-enable right click (bookmarklet)
javascript:(function(w){
var arr = ['contextmenu','copy','cut','paste','mousedown','mouseup','beforeunload','beforeprint'];
for(var i = 0, x; x = arr[i]; i++){
if(w['on' + x])w['on' + x] = null;
w.addEventListener(x, function(e){e.stopPropagation()}, true);
};
for(var j = 0, f; f = w.frames[j]; j++){try{arguments.callee(f)}catch(e){}}})(window);
@matthewpenkala
matthewpenkala / jquery.isOver.js
Created July 26, 2023 14:17 — forked from UziTech/jquery.isOver.js
jQuery plugin to check if a point on the page is within an element.
/*
* DWTFYW License
*
* Author: Tony Brix, http://tonybrix.info
*
* Check if a point is within an element.
* Useful for mouseover on absolutely positioned overlapping elements.
*
* Example:
* $(document).mousemove(function(e){
@matthewpenkala
matthewpenkala / calculateZIndex.js
Last active September 28, 2023 11:09
This calculates the z-index of a given HTML element by traversing its parents and checking the computed z-index values. The function ensures an accurate determination of the z-index even if the z-index value is specified using different units or if it's inherited from parent elements.
/**
* @author Matthew Penkala <hello@matthewpenkala.com>
* @website https://matthewpenkala.com/
* @version 1.0.0
* @description This JavaScript file contains a function named `calculateZIndex`
* which, quite evidently, calculates the z-index (CSS) of a given
* HTML element by traversing its parents and checking the computed
* z-index values. The function ensures an accurate determination of
* the z-index even if the z-index value is specified using different
* units or if it's inherited from parent elements.*/
@matthewpenkala
matthewpenkala / reducedMotion.js
Created September 30, 2023 14:58
Reduced Motion (Webflow-Specific JS)
// Cancel Webflow animations for users who prefer reduced motion
if (window.matchMedia("(prefers-reduced-motion)").matches) {
const cancelAnimationsInterval = setInterval(function() {
if (typeof Webflow == "undefined" || typeof Webflow.require == "undefined") {
return;
}
clearInterval(cancelAnimationsInterval);
// Get the interactions data from Webflow's state
@matthewpenkala
matthewpenkala / OldBrowser.js
Last active November 20, 2023 09:26 — forked from gerbenvandijk/OldBrowser.js
Detect if the user has an old browser and if so, it inserts a friendly notification that not all features on the site will work, and that an upgrade is recommended.
// The code - first bit is all the UserAgent library.
(function(wndw) {
var Browsers, OS, Platform, Versions, browser_name, browser_version, os, platform;
Versions = {
Firefox: /firefox\/([\d\w\.\-]+)/i,
IE: /msie\s([\d\.]+[\d])/i,
Chrome: /chrome\/([\d\w\.\-]+)/i,
Safari: /version\/([\d\w\.\-]+)/i,
Ps3: /([\d\w\.\-]+)\)\s*$/i,
Psp: /([\d\w\.\-]+)\)?\s*$/i
@matthewpenkala
matthewpenkala / browser_detect.js
Created December 27, 2023 00:29 — forked from dks50217/browser_detect.js
JavaScript: Detect Browser
// browser detect
var BrowserDetect = {
init: function(userAgent, appVersion) {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(userAgent) || this.searchVersion(appVersion) || "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function(data) {
for (var i = 0; i < data.length; i++) {
var dataString = data[i].string;