Skip to content

Instantly share code, notes, and snippets.

Stephan Schmitz eyecatchup

Block or report user

Report or block eyecatchup

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
@eyecatchup
eyecatchup / catch-js-error-stacktrace.js
Created Jul 1, 2019
JavaScript global error handling
View catch-js-error-stacktrace.js
var sendError = function (err) {
console.log('Caught JS client error:');
console.dir(err);
var xhr = new XMLHttpRequest();
xhr.open('POST', '/api/error/add', true);
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
xhr.send(JSON.stringify(err));
};
@eyecatchup
eyecatchup / search-devtools-history.md
Created May 24, 2019
Search Chrome Devtools history
View search-devtools-history.md

Search Chrome Devtools history

  1. Undock the console (click on the icon in the bottom-left corner, ![undock icon][1]).
    (if you don't see ![the undock icon][2], but ![][3], then hold the mouse pressed for a few seconds to get the desired icon)
  2. Press Ctrl + Shift + J to open the console for this console. (On OSX use Cmd + Option + i)
  3. Use the following snippet to get an array of matches for your search term:
const searchHistory = query => {console.dir(JSON.parse(localStorage.getItem('consoleHistory')).filter(function(item){ return ~item.indexOf(query);}))}
searchHistory('token')
@eyecatchup
eyecatchup / js-generator-functions.md
Last active Mar 19, 2019
Creating a `GeneratorFunction` in JavaScript
View js-generator-functions.md

Generator defined using the function* statement syntax:

// function *idMaker(){ <- also possible, even though no reference found
function* idMaker(){
  var index = 0;
  while(index < index+1)
    yield index++;
}
@eyecatchup
eyecatchup / smooth-scrolling-polyfill.md
Last active Jun 17, 2019
Smooth Scroll behavior polyfill
View smooth-scrolling-polyfill.md

The Scroll Behavior specification has been introduced as an extension of the Window interface to allow for the developer to opt in to native smooth scrolling. To date this has only been implemented in Chrome, Firefox and Opera.

There's a complete polyfill here (3.3KB minified). But most of the times, the following is enough for me (641 bytes minified):

smooth-scrolling-poyfill.js

Use as: scrollToElem('#elem-selector');

@eyecatchup
eyecatchup / crypto-sha.js
Created Mar 13, 2019 — forked from chrisveness/crypto-sha.js
Uses the SubtleCrypto interface of the Web Cryptography API to hash a message using SHA-256.
View crypto-sha.js
/**
* Returns SHA-256 hash from supplied message.
*
* @param {String} message.
* @returns {String} hash as hex string.
*
* @example
* sha256('abc').then(hash => console.log(hash));
* const hash = await sha256('abc');
*/
View aaf-livestreams-season-2019.md

Complete AAF season 2019 schedule with free live streams

The Alliance of American Football (AAF) games can be watched live through AAF's TV partners, including CBS, CBSSN, NFL Network, TNT and B/R Live.

But also, most AAF games can be watched live via the free AAF.com website.

The official live stream URLs are public only a few hours before kickoff. But because the AAF live stream URLs are generated by the following pattern:

https://aaf.com/live/{internalGameId}
@eyecatchup
eyecatchup / install-phantomjs-from-source.sh
Created Aug 17, 2018
Install PhantomJS on Debian/Ubuntu from source
View install-phantomjs-from-source.sh
#!/usr/bin/env bash
# This script install PhantomJS in your Debian/Ubuntu System
#
# This script must be run as root:
# sudo sh install_phantomjs.sh
#
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
@eyecatchup
eyecatchup / README.md
Created May 21, 2018 — forked from surma/README.md
webpack-emscripten-wasm
View README.md

Minimal example making webpack and wasm/Emscripten work together.

Build instructions:

  • Clone this gist
  • npm install
  • npm start
  • Open http://localhost:8080
  • Look at console
@eyecatchup
eyecatchup / package.json
Created Apr 19, 2018 — forked from surma/package.json
Boilerplate for quick one-off TypeScript projects. Just run `npm start`
View package.json
{
"name": "tsquickstart",
"version": "1.0.0",
"description": "Boilerplate for quick one-off TypeScript projects. Just run `npm start`",
"scripts": {
"init": "test -f tsconfig.json || (tsc --init -t ESNext -m ESNext && npm install)",
"start": "npm run init && concurrently \"npm run watch\" \"npm run serve\"",
"serve": "http-server",
"watch": "tsc -p . --watch",
"build": "tsc -p ."
@eyecatchup
eyecatchup / certificate.sh
Created Mar 12, 2018 — forked from WebReflection/certificate.sh
A basic Self Signed SSL Certificate utility
View certificate.sh
#!/usr/bin/env bash
# A basic Self Signed SSL Certificate utility
# by Andrea Giammarchi @WebReflection
# https://www.webreflection.co.uk/blog/2015/08/08/bringing-ssl-to-your-private-network
# # to make it executable and use it
# $ chmod +x certificate
# $ ./certificate # to read the how-to
You can’t perform that action at this time.