Skip to content

Instantly share code, notes, and snippets.

@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.*/
@bnnk
bnnk / OldBrowser.js
Last active November 20, 2023 09:20 — forked from gerbenvandijk/OldBrowser.js
Browser UA String parser.
// The code - first bit is all the UserAgent library.
(function(scope) {
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
@iceiix
iceiix / window.js
Created January 15, 2019 01:04
window.js:7196 missing function: emscripten_set_mousemove_callback - emscripten 1.38.22 + winit issue, https://github.com/kripken/emscripten/issues/7525 https://github.com/tomaka/winit/issues/760
// Copyright 2010 The Emscripten Authors. All rights reserved.
// Emscripten is available under two separate licenses, the MIT license and the
// University of Illinois/NCSA Open Source License. Both these licenses can be
// found in the LICENSE file.
// The Module object: Our interface to the outside world. We import
// and export values on it. There are various ways Module can be used:
// 1. Not defined. We create it here
// 2. A function parameter, function(Module) { ..generated code.. }
// 3. pre-run appended it, var Module = {}; ..generated code..
@simonw
simonw / remove-message.js
Last active March 6, 2023 08:40
JavaScript one-liner for removing a ?message=... parameter from the visible URL in the browser
history.replaceState && history.replaceState(
null, '', location.pathname + location.search.replace(/[\?&]message=[^&]+/, '').replace(/^&/, '?')
);
@SergeyAxenov
SergeyAxenov / batchTee.bat
Created May 10, 2015 09:23
Windows batch: 'tee' command
:: #cmd #bat #tee #redirect #output
:: Author: http://stackoverflow.com/users/1012053/dbenham
:: http://stackoverflow.com/questions/11239924/windows-batch-tee-command
::
:: batchTee.bat OutputFile [+]
::
:: Write each line of stdin to both stdout and outputFile.
:: The default behavior is to overwrite any existing outputFile.
:: If the 2nd argument is + then the content is appended to any existing
:: outputFile.
@yuval-a
yuval-a / js-micro.js
Last active May 16, 2024 21:01
Javascript micro-optimizations
NOTE: This document is OLD - and most of the tips here are probably outdated, since newer versions of Javascript have been
released over the years - with newer optimizations and more emphasis on optimizing newly supported syntax.
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
@2107
2107 / browser_detect.js
Last active November 20, 2023 11:54 — forked from ideefixe/browser_detect.js
JavaScript: Detect Browser
// browser detect
var BrowserDetect = {
init: function() {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.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;
@surjikal
surjikal / jquery.getstyleobject.js
Created June 27, 2012 21:57
jQuery - Get styles of an element
// Taken from http://upshots.org/javascript/jquery-copy-style-copycss
(function($) {
$.fn.getStyleObject = function() {
var dom = this.get(0);
var style;
var returns = {};