Skip to content

Instantly share code, notes, and snippets.

View dvdsmpsn's full-sized avatar

David Simpson dvdsmpsn

View GitHub Profile
@dvdsmpsn
dvdsmpsn / gist:855ea95f91ae38808eb6bc6cd9fb2b51
Created January 24, 2018 11:00 — forked from solenoid/gist:1372386
javascript ObjectId generator
var mongoObjectId = function () {
var timestamp = (new Date().getTime() / 1000 | 0).toString(16);
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
return (Math.random() * 16 | 0).toString(16);
}).toLowerCase();
};
@dvdsmpsn
dvdsmpsn / gist:5c98442e5af17b43858dc110ad424e0f
Last active August 19, 2023 17:56 — forked from alexis89x/broadcast-channel-es6.js
Broadcast Channel API polyfill
/**
@class BroadcastChannel
A simple BroadcastChannel polyfill that works with all major browsers.
Please refer to the official MDN documentation of the Broadcast Channel API.
======
@see <a href="https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API">Broadcast Channel API on MDN</a>
@author Alessandro Piana
@version 1.0.0
@dvdsmpsn
dvdsmpsn / index.html
Created February 24, 2016 14:44 — forked from DeBraid/index.html
Using Chrome DevTools to scrape HTML table and convert to JSON.
// ****************************************************
// USING JQUERY TO CONVERT HTML TABLE INTO JSON
// by Derek from www.cacheflow.ca
// Watch the video: http://youtu.be/DPOOIOU0zVA
// ****************************************************
// Step 1: Create keys for JSON object
var cols = $("#tableID thead tr th").map(function(){
@dvdsmpsn
dvdsmpsn / speedtest-ifttt.sh
Last active March 22, 2018 17:49 — forked from aallan/speedtest-ifttt.sh
Modified version of Henrik Bengtsson's speedtest-cli code which will dispatch the test results to the IFTTT Maker Channel.
#!/usr/bin/env bash
###########################################################################
# Originally written by: Henrik Bengtsson, 2014
# https://github.com/HenrikBengtsson/speedtest-cli-extras
# Modified to use IFTTT by: Alasdair Allan, 2015
# License: GPL (>= 2.1) [http://www.gnu.org/licenses/gpl.html]
###########################################################################
# Character for separating values
# (commas are not safe, because some servers return speeds with commas)
#!/bin/bash
checkExisting(){
echo "Checking if already existing device on file..."
while read fileLine; do
if [ "$line" = "$fileLine" ]; then
echo "[WARNING] Device already initialized on this system. Nothing to do here"
@dvdsmpsn
dvdsmpsn / README.md
Created November 14, 2015 20:14 — forked from teffalump/README.md
OpenWRT adblock implementation

Description

In its basic usage, this script will modify the router such that blocked addresses are null routed and unreachable. Since the address blocklist is full of advertising, malware, and tracking servers, this setup is generally a good thing. In addition, the router will update the blocklist weekly. However, the blocking is leaky, so do not expect everything to be blocked.

Setup

The script must be copied to an OpenWRT router (gargoyle firmware works fine, too).

For example, if the router is located at 192.168.1.1:

@dvdsmpsn
dvdsmpsn / String.prototype.template.js
Last active August 29, 2015 14:13 — forked from WebReflection/String.prototype.template.js
ES6 Template like strings in ES3 compatible syntax.
/**
* Usage:
* 'Hello ${name}'.template({
* name: 'chaps'
* });
*
* From: https://gist.github.com/WebReflection/8f227532143e63649804
*/
String.prototype.template = function (object) {