Skip to content

Instantly share code, notes, and snippets.

View Stanback's full-sized avatar

Brian Stanback Stanback

  • Demand.io
  • Los Angeles, California
View GitHub Profile
@Stanback
Stanback / preactDomRenderer.js
Last active June 28, 2017 21:39
Preact DOM render using undom
// src/app/preactDomRenderer.js
import { h, render } from 'preact';
import undom from 'undom';
const VOID_ELEMENTS = [
'area',
'base',
'br',
'col',
@Stanback
Stanback / compress.sh
Created December 8, 2017 18:57
PDF Compression w/ Ghostscript
gs \
-dNOPAUSE \
-dQUIET \
-dBATCH \
-dSAFER \
-dPDFSETTINGS=/printer \
-dCompatibilityLevel=1.3 \
-dPDFA=2 \
-dPDFACompatibilityPolicy=1 \
-dSimulateOverprint=true \
@Stanback
Stanback / animation.css
Created April 12, 2018 16:12
CSS animation example
body {
padding: 5rem;
}
.animation {
height: 1.25rem;
margin: .625rem 0 0;
}
.animation-dot {
@Stanback
Stanback / coffee2js.sh
Last active July 11, 2019 10:30
Convert all CoffeeScript files to Javascript (coffee2js)
#!/bin/sh
# Install coffeescript cli
npm -g install coffee-script
# Convert all coffeescript files to javascript
find . -name "*.coffee" -exec coffee --no-header --bare -c {} \;
# Optionally delete original coffee files
find . -name "*.coffee" -exec rm {} \;
@Stanback
Stanback / nginx.conf
Last active February 4, 2022 18:05
Example Nginx configuration for serving pre-rendered HTML from Javascript pages/apps using the Prerender Service (https://github.com/collectiveip/prerender).Instead of using try_files (which can cause unnecessary overhead on busy servers), you could check $uri for specific file extensions and set $prerender appropriately.
# Note (November 2016):
# This config is rather outdated and left here for historical reasons, please refer to prerender.io for the latest setup information
# Serving static html to Googlebot is now considered bad practice as you should be using the escaped fragment crawling protocol
server {
listen 80;
listen [::]:80;
server_name yourserver.com;
root /path/to/your/htdocs;
@Stanback
Stanback / ip_conversions.scala
Last active June 10, 2022 10:46
Scala example for converting an IPv4 or IPv6 address to a base 10 decimal/long/BigInt w/ netmask range calculation
import java.net.{Inet4Address, Inet6Address, InetAddress}
import scala.util.Try
sealed trait IPAddressException {
self: Throwable => val message: String
}
case class IPAddressParseException(message: String) extends Exception(message) with IPAddressException
trait IPAddress {
@Stanback
Stanback / samsung_remote.js
Last active September 29, 2022 05:13 — forked from danielfaust/samsung_remote.py
Samsung TV Remote Control Node.js Script
const net = require('net');
//
// A Node.js port of this original Gist: https://gist.github.com/danielfaust/998441
// To find hosts on the network: nmap -Pn -p55000 192.168.12.1/24
//
// Note: This is for Samsung TVs circa 2012-2015 that use a service running on port 55000
// Samsung TV's circa 2016 and later use a WebSocket service on port 8001 which is different
//
@Stanback
Stanback / nginx.conf
Last active May 3, 2024 12:01 — forked from michiel/cors-nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which