Skip to content

Instantly share code, notes, and snippets.

View jackmcpickle's full-sized avatar

Jack McNicol jackmcpickle

View GitHub Profile
@adactio
adactio / updateDateTimes.js
Last active September 11, 2023 05:10
Periodically update the text of `datetime` elements with the relative time elapsed.
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.Intl || !win.Intl.RelativeTimeFormat) {
// doesn't cut the mustard.
return;
}
var rtf = new Intl.RelativeTimeFormat('en', {
localeMatcher: 'best fit',
numeric: 'always',
style: 'long'
#!/bin/bash
set -eu
set -x
docker build -t deno-cent7 .
@micalevisk
micalevisk / read-that-sheet.js
Last active September 18, 2022 05:21
Dead simple NodeJS script to read public Google Sheets as CSV. (just the first sheet)
// $ npm install -g google-spreadsheet
const { GoogleSpreadsheet } = require('google-spreadsheet')
const API_KEY = '<YOUR-SUPER-SECRET-API-KEY>' // See: https://developers.google.com/sheets/api/guides/authorizing#APIKey
const SHEET_ID = '<target-sheet-id>' // spreadsheet key is the long id in the sheets URL
const doc = new GoogleSpreadsheet(SHEET_ID)
doc.useApiKey(API_KEY)
@stefanbuck
stefanbuck / prepare-commit-msg
Last active June 9, 2023 21:09
Ticket number git hook
#!/usr/bin/env bash
#
# Authors:
# Stefan Buck (https://github.com/stefanbuck)
# Thomas Ruoff (https://github.com/tomru)
#
#
# Description:
# Are you still prefixing your commits with a ticket number manually? You will love this script!
# This is a git hook script that will automatically prefix your commit messages with a ticket
@soderlind
soderlind / Install.txt
Last active March 5, 2024 20:30
macOS DoH! (DNS over HTTPS) using cloudflared
1) Install cloudflared using homebrew:
brew install cloudflare/cloudflare/cloudflared
2) Create /usr/local/etc/cloudflared/config.yaml, with the following content
proxy-dns: true
proxy-dns-upstream:
- https://1.1.1.1/dns-query
- https://1.0.0.1/dns-query
@amjith
amjith / git-open.sh
Created February 21, 2018 03:05
git-open.sh
#!/bin/bash
dirty=`git status --porcelain -uno | sed s/^...//`
last_modified=`git show --pretty="format:" --name-only HEAD`
if [ -n "$dirty" ]; then
echo $dirty
else
echo $last_modified
fi
@clarkbw
clarkbw / redux-performance-mark.js
Last active February 8, 2024 05:03
A User Timing middleware for redux to create performance markers for dispatched actions
const timing = store => next => action => {
performance.mark(`${action.type}_start`);
let result = next(action);
performance.mark(`${action.type}_end`);
performance.measure(
`${action.type}`,
`${action.type}_start`,
`${action.type}_end`
);
return result;
@joepie91
joepie91 / vpn.md
Last active May 20, 2024 03:37
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@danielgtaylor
danielgtaylor / gist:0b60c2ed1f069f118562
Last active April 2, 2024 20:18
Moving to ES6 from CoffeeScript

Moving to ES6 from CoffeeScript

I fell in love with CoffeeScript a couple of years ago. Javascript has always seemed something of an interesting curiosity to me and I was happy to see the meteoric rise of Node.js, but coming from a background of Python I really preferred a cleaner syntax.

In any fast moving community it is inevitable that things will change, and so today we see a big shift toward ES6, the new version of Javascript. It incorporates a handful of the nicer features from CoffeeScript and is usable today through tools like Babel. Here are some of my thoughts and issues on moving away from CoffeeScript in favor of ES6.

While reading I suggest keeping open a tab to Babel's learning ES6 page. The examples there are great.

Punctuation

Holy punctuation, Batman! Say goodbye to your whitespace and hello to parenthesis, curly braces, and semicolons again. Even with the advanced ES6 syntax you'll find yourself writing a lot more punctuatio