Skip to content

Instantly share code, notes, and snippets.

View spencermountain's full-sized avatar

spencer kelly spencermountain

View GitHub Profile
#!/bin/bash
# 0 * * * * /Users/imiell/git/work/bin/home/slack_start_stop.sh start
# 3-59 * * * * /Users/imiell/git/work/bin/home/slack_start_stop.sh stop
DO_START=0
DO_STOP=0
while [ "$1" != "" ]; do
case $1 in
@talkingmoose
talkingmoose / New Daily Note.applescript
Last active April 23, 2022 02:33
Begins a new daily note for today in Bear. Adds a "Daily Notes" tag, events for today from Outlook 2016 for Mac calendar and a "Notes" header. Save this AppleScript to the Scripts folder for Bear at ~/Library/Scripts/Applications/Bear and call it using the system-wide AppleScript menu.
(*
----------------------------------------------------------------------------------
ABOUT THIS SCRIPT
Written by:William Smith
Professional Services Engineer
Jamf
bill@talkingmoose.net
@buzamahmooza
buzamahmooza / Add video keyboard shortcuts.user.js
Last active May 14, 2024 02:54
Adds keyboard shortcuts to HTML5 videos.
// ==UserScript==
// @name Video keyboard shortcuts
// @namespace https://github.com/buzamahmooza
// @version 0.5
// @description Adds keyboard shortcuts to HTML5 videos.
// Left Click: Toggle Pause/Play
// F or dblClk: Toggle Fullscreen
// SpaceBar: Toggle Pause/Play
// Left/Right: Navigate back/forward
// -,[ / =,]: - / + Playback speed
'use strict';
const puppeteer = require('puppeteer');
(async () => {
/* PRECONDITION:
0. download ublock, I used https://github.com/gorhill/uBlock/releases/download/1.14.19b5/uBlock0.chromium.zip
1. run $PATH_TO_CHROME --user-data-dir=/some/empty/directory --load-extension=/location/of/ublock
2. enable block lists you want to use
*/
@digiter
digiter / FixCommandForMacKeyboard.md
Last active December 2, 2022 19:48
Map Command Key to Control For ubuntu + mac keyboard

For each machine running xmodmap will give you the mapping and keycode, take a look first then write the script. I use ubuntu and mac keyboard. The below maps both left and right control and super.

Create an .Xmodmap file in your Linux home directory, with the following contents, then execute xmodmap .Xmodmap

clear control
clear mod4

keycode 37 = Super_L
keycode 105 = Super_R
@mobz
mobz / getTimeZone.js
Last active February 26, 2020 09:08
You can scrape the timezone database in javascript using the Intl object [ licensed CC0 ]
function getTimeZone( tz_str, date ) {
const utc_c = {
timeZone: "UTC",
hour12: false,
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "numeric",
@johndyer
johndyer / easter.js
Last active April 9, 2024 16:28
Calculate Easter in JavaScript
/**
* Calculates Easter in the Gregorian/Western (Catholic and Protestant) calendar
* based on the algorithm by Oudin (1940) from http://www.tondering.dk/claus/cal/easter.php
* @returns {array} [int month, int day]
*/
function getEaster(year) {
var f = Math.floor,
// Golden Number - 1
G = year % 19,
C = f(year / 100),
@paulirish
paulirish / what-forces-layout.md
Last active May 17, 2024 18:01
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/