Skip to content

Instantly share code, notes, and snippets.

Avatar

Wilson Page wilsonpage

View GitHub Profile
View minimal-analytics-snippet.js
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@bhongy
bhongy / node-proxy-server.js
Created Aug 7, 2018
[nodejs] A simple example how to write a proxy server piping server request to client request / client response back to server response.
View node-proxy-server.js
// from: http://book.mixu.net/node/ch10.html
'use strict';
const http = require('http');
const url = require('url');
const server = http.createServer((sreq, sres) => {
const { pathname } = url.parse(sreq.url);
const opts = {
@pioug
pioug / index.js
Last active Dec 22, 2020
Errors to ignore on Sentry, likely caused by browsers/extensions/webviews
View index.js
const ignoreErrors = [
/^No error$/,
/__show__deepen/,
/_avast_submit/,
/Access is denied/,
/anonymous function: captureException/,
/Blocked a frame with origin/,
/console is not defined/,
/cordova/,
/DataCloneError/,
@hexsprite
hexsprite / serviceworker-errors.js
Created Aug 18, 2017
service worker error tracking example
View serviceworker-errors.js
/* eslint-env browser, serviceworker */
self.addEventListener('error', function (event) {
logError(event.error)
})
self.addEventListener('unhandledrejection', function (event) {
let { reason, detail } = event
if (!reason && detail) {
reason = detail.reason
}
View GrooveShark.class.php
<?php
/**
* GrooveShark - Interface to the Grooveshark unofficial web API
*
* PHP Version 5
*
* @author Matt Austin <matt@m-ausitn.com>
*/
include("util.class.php");
View app-test.jade
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible", content="IE=edge,chrome=1")
title= title
link(rel='stylesheet', href='/public/js/libs/nodeunit/nodeunit.css')
script(src="/public/js/libs/nodeunit/nodeunit.js")
script(data-main="/public/js/app-test", src="/public/js/libs/require/require.js")
<!-- nodeunit HTML -->
@tbranyen
tbranyen / server.js
Last active Jul 28, 2019
backbone/node.js pushState enabled server
View server.js
// Require libraries
var os = require("os");
var fs = require("fs");
var readline = require("readline");
var cluster = require("cluster");
var express = require("express");
var site = express();
// Var up, bro
var i, read;