Skip to content

Instantly share code, notes, and snippets.

@bashbunni
bashbunni / .zshrc
Created October 27, 2022 21:41
CLI Pomodoro for Mac
# I'll be doing another one for Linux, but this one will give you
# a pop up notification and sound alert (using the built-in sounds for macOS)
# Requires https://github.com/caarlos0/timer to be installed
# Mac setup for pomo
alias work="timer 60m && terminal-notifier -message 'Pomodoro'\
-title 'Work Timer is up! Take a Break 😊'\
-appIcon '~/Pictures/pumpkin.png'\
-sound Crystal"
@myogeshchavan97
myogeshchavan97 / trap_focus.js
Last active November 26, 2022 08:46
Code for trapping focus inside modal
// add all the elements inside modal which you want to make focusable
const focusableElements =
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
const modal = document.querySelector('#exampleModal'); // select the modal by it's id
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
const focusableContent = modal.querySelectorAll(focusableElements);
const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
@theodorosploumis
theodorosploumis / Nework_throttling_profiles.md
Last active November 8, 2024 12:01
Web development - Custom network throttling profiles
Profile download (kb/s) upload (kb/s) latency (ms)
Native 0 0 0
GPRS 50 20 500
56K Dial-up 50 30 120
Mobile EDGE 240 200 840
2G Regular 250 50 300
2G Good 450 150 150
3G Slow 780 330 200
// Object.prototype.toString.call() will check the type of any primitive or object in JavaScript:
console.log(Object.prototype.toString.call(new Date())) // [object Date]
console.log(Object.prototype.toString.call([])) // [object Array]
console.log(Object.prototype.toString.call(true)) // [object Boolean]
console.log(Object.prototype.toString.call(function () {})) // [object Function]
console.log(Object.prototype.toString.call((x => x))) // [object Function]
console.log(Object.prototype.toString.call(null)) // [object Null]
console.log(Object.prototype.toString.call(37)) // [object Number]
console.log(Object.prototype.toString.call(NaN)) // [object Number]
console.log(Object.prototype.toString.call(Infinity)) // [object Number]
{
"globals": {
"jQuery": true,
"$": true
},
"env": {
"browser": true,
"node": true
},
"rules": {
@andrew-serrano
andrew-serrano / miva_order_template_email.xml
Last active April 28, 2020 17:44
Manually trigger a preexisting email
<mvt:comment>
Overrides if needed
</mvt:comment>
<mvt:assign name="l.run:override_from" value="''" />
<mvt:assign name="l.run:override_reply_to" value="''" />
<mvt:assign name="l.run:override_to" value="''" />
<mvt:assign name="l.run:override_cc" value="''" />
<mvt:assign name="l.run:override_bcc" value="''" />
<mvt:assign name="l.run:override_subject" value="''" />
@tessguefen
tessguefen / Code to call template.xml
Created May 8, 2019 03:11
Components & Layouts - v1.012
<mvt:assign name="l.settings:layout_code" value="'sfnt_layout'" />
<mvt:item name="readytheme" param="contentsection( 'components_and_layouts' )" />
<mvt:eval expr="l.settings:final_output" />
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active October 24, 2024 18:10
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@franktopel
franktopel / HTMLBaseElement.md
Last active September 27, 2024 18:22
HTMLBaseElement class solving the problem of connectedCallback being called before children are parsed

There is a huge practical problem with web components spec v1:

In certain cases connectedCallback is being called when the element's child nodes are not yet available.

This makes web components dysfunctional in those cases where they rely on their children for setup.

See WICG/webcomponents#551 for reference.

To solve this, we have created a HTMLBaseElement class in our team which serves as the new class to extend autonomous custom elements from.

const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: path.resolve(__dirname, 'src/index.js'),
plugins: [
new webpack.HashedModuleIdsPlugin(), // so that file hashes don't change unexpectedly
],
output: {
path: path.resolve(__dirname, 'dist'),