Skip to content

Instantly share code, notes, and snippets.

View sterlingwes's full-sized avatar
🍉

Wes Johnson sterlingwes

🍉
View GitHub Profile
@sterlingwes
sterlingwes / README.md
Created October 8, 2019 17:57
Generate SSH public key fingerprint (github key check)

Useful for comparing the fingerprint shown by github at https://github.com/settings/keys against the public key on your machine to see whether it's a match:

ssh-keygen -l -E md5 -f ~/.ssh/id_rsa.pub

This lists the MD5 fingerprint

Source

@sterlingwes
sterlingwes / README.md
Last active April 4, 2018 06:05
Getting past cross-origin Web Worker exception

Cross-origin web worker scripts

If you're like me and wanted to serve your main app script from a CDN and still load a web worker, you may have encountered the following error:

Uncaught DOMException: Failed to construct 'Worker': Script at 'http://cdn.example.com/worker.js' cannot be accessed from origin 'http://example.com'

You can get around this fairly simply with importScripts by making the script you instantiate your worker with load the actual worker script from the CDN.

@sterlingwes
sterlingwes / javascript.json
Created July 28, 2017 14:38
React VS Code Snippets
{
/*
// Place your snippets for JavaScript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
@sterlingwes
sterlingwes / PerformanceTimer.js
Created May 10, 2017 16:01
Performance timing with window.performance
const perf = window.performance
class PerformanceTimer {
constructor (name) {
this.name = name
this.markStart = `${name}-start`
this.markStop = `${name}-stop`
}
start () {
@sterlingwes
sterlingwes / loaderHook.js
Last active May 2, 2017 16:04
webpack server side rendering with file loader (ie: require()'d images)
const fs = require('fs')
const utils = require('loader-utils')
const defaultOptions = {
extensions: ['.png', '.jpg'],
filePrefix: 'img/img-',
hashLength: 6
}
module.exports = function (options) {
@sterlingwes
sterlingwes / README.md
Created January 5, 2017 16:53
Convert video to optimized GIF with libav (avconv)

Prerequisites

  • avconv
  • gifsicle

If you're on Ubuntu:

  • apt-get install gifsicle libav-tools

Command

@sterlingwes
sterlingwes / keybase.md
Created February 8, 2016 17:49
keybase.md

Keybase proof

I hereby claim:

  • I am sterlingwes on github.
  • I am sterlingwes (https://keybase.io/sterlingwes) on keybase.
  • I have a public key whose fingerprint is 85ED 9BAF 923C 814E A02C 2775 F61C 0CD9 87CB D962

To claim this, I am signing this object:

@sterlingwes
sterlingwes / StorytimeParser.js
Last active December 31, 2015 23:00
WIP Parser for Storytime Data
var DEFAULT_UNITS = 'hours'
var HOURS_FROM_MILLISECONDS = 3600000
var MINUTES_FROM_MILLISECONDS = HOURS_FROM_MILLISECONDS / 60
var m = require('moment')
/*
* allows for manipulating the raw data stored by Storytime
*
* filepath (string) - expects a json file relative to the execution context
@sterlingwes
sterlingwes / webplatform.js
Created March 6, 2013 05:30
BlackBerry WebWorks Native Javascript Wrapper exposed at platform:///webplatform.js by webviews
(function () {
/*
Copyright 2012 Research In Motion Limited.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0