Skip to content

Instantly share code, notes, and snippets.

View brandonhill's full-sized avatar

Brandon Hill brandonhill

  • Newmarket, Ontario
View GitHub Profile
@brandonhill
brandonhill / server.js
Created October 8, 2022 12:01
Quick local HTTPS server (Node.js)
const { spawnSync } = require('child_process')
const { createReadStream, existsSync, readFileSync } = require('fs')
const { access } = require('fs/promises')
const https = require('https')
const conf = {
default: 'index.html',
log: {
access: false,
error: true },
@brandonhill
brandonhill / gist-loader.js
Created October 7, 2022 07:00
Loads javascript gists into an HTML page.
const gist = async (id, d = document, s = [
'//api.github.com/gists/',
'?callback=',
'__gg',
'script']) => {
const load = (raw, src) => {
const el = d.createElement(s[3])
raw && (el.innerHTML = raw) || (el.src = src)
d.head.appendChild(el)
@brandonhill
brandonhill / fireworks.js
Last active October 8, 2022 01:46
Fireworks
class Firework {
done = false
exploded = false
particles = []
constructor(ctx, gravity, x, y, vel) {
this.col = { h: Util.rand(360), a: Util.rand(0.5, 0.9) }
this.ctx = ctx
this.grav = gravity
this.vel = vel
@brandonhill
brandonhill / ad-block-detect.js
Created June 23, 2022 20:25
Ad blocker detection
// makes dummy ad call, if errored assumes blocker present
((d, src) => {
const s = d.createElement('script')
s.addEventListener('error', () => {
console.log('ad blocker present')
// tell them how their content theft makes you feel appreciated...
})
s.async = true
s.src = src
d.head.appendChild(s)