Skip to content

Instantly share code, notes, and snippets.

Wes Johnson sterlingwes

Block or report user

Report or block sterlingwes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sterlingwes
sterlingwes / javascript.json
Created Jul 28, 2017
React VS Code Snippets
View javascript.json
{
/*
// 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
Performance timing with window.performance
View PerformanceTimer.js
const perf = window.performance
class PerformanceTimer {
constructor (name) {
this.name = name
this.markStart = `${name}-start`
this.markStop = `${name}-stop`
}
start () {
@sterlingwes
sterlingwes / loadertest.html
Created May 10, 2017
Three.js OBJ Loader test
View loadertest.html
<html>
<head>
<script src="node_modules/three/build/three.js"></script>
<script src="node_modules/three/examples/js/loaders/OBJLoader.js"></script>
</head>
<body>
<script>
const model = 'https://s3.amazonaws.com/areo-dev-wjohnson/v1/worlds/a42d78b1-a28a-4d7b-b64e-c1512ea9bac4/models/a4cd6444-fa12-4edf-aba5-8aa72e693bc6-m'
fetch(model)
.then(response => response.blob())
@sterlingwes
sterlingwes / loaderHook.js
Last active May 2, 2017
webpack server side rendering with file loader (ie: require()'d images)
View loaderHook.js
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
Last active Apr 4, 2018
Getting past cross-origin Web Worker exception
View README.md

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 / README.md
Created Jan 5, 2017
Convert video to optimized GIF with libav (avconv)
View README.md

Prerequisites

  • avconv
  • gifsicle

If you're on Ubuntu:

  • apt-get install gifsicle libav-tools

Command

View 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 / README.md
Created Jan 31, 2016
Converting a scanned PDF to EPUB ebook (or other format)
View README.md

Caveat

You're not going to get a beautiful EPUB out the other end - if that's what you're looking for, expect to do some manual clean-up work yourself.

Basic order of operations:

  • Convert your PDF to an OCR-friendly format
  • OCR that shit into plaintext
  • Convert that plaintext into your format of choice (in this case, an EPUB)
@sterlingwes
sterlingwes / injected.snippet.js
Created Jan 3, 2016
Squarespace Parse Query String and Prefill Email Field in Contact Form
View injected.snippet.js
function parseSearchString () {
var qs = window.location.search
qs = qs.replace(/^\?/,'')
var parts = qs.split('&')
var params = {}
parts.forEach(function (part) {
var pair = part.split('=')
params[pair[0]] = decodeURIComponent(pair[1])
})
return params
You can’t perform that action at this time.