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 April 24, 2024 19:53
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 March 28, 2024 01:45
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 = () => {
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'),
@Gazzell
Gazzell / pre-commit
Created January 31, 2018 09:09
pre-commit. Only commit if pass tests and there are not leftovers (.only and .skip)
branch=`git symbolic-ref HEAD`
if [ "$branch" = "refs/heads/master" ]; then
echo "Direct commits to the branch master are not allowed"
exit 1
fi
testLeftOvers=`git diff --staged test/**/* | grep '^+' | grep '.only\|.skip'`
if [ -n "$testLeftOvers" ]; then