Skip to content

Instantly share code, notes, and snippets.

Brian Stanback Stanback

Block or report user

Report or block Stanback

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
@Stanback
Stanback / samsung_remote.js
Last active Aug 16, 2019 — forked from danielfaust/samsung_remote.py
Samsung TV Remote Control Node.js Script
View samsung_remote.js
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 / animation.css
Created Apr 12, 2018
CSS animation example
View animation.css
body {
padding: 5rem;
}
.animation {
height: 1.25rem;
margin: .625rem 0 0;
}
.animation-dot {
@Stanback
Stanback / compress.sh
Created Dec 8, 2017
PDF Compression w/ Ghostscript
View compress.sh
gs \
-dNOPAUSE \
-dQUIET \
-dBATCH \
-dSAFER \
-dPDFSETTINGS=/printer \
-dCompatibilityLevel=1.3 \
-dPDFA=2 \
-dPDFACompatibilityPolicy=1 \
-dSimulateOverprint=true \
@Stanback
Stanback / preactDomRenderer.js
Last active Jun 28, 2017
Preact DOM render using undom
View preactDomRenderer.js
// src/app/preactDomRenderer.js
import { h, render } from 'preact';
import undom from 'undom';
const VOID_ELEMENTS = [
'area',
'base',
'br',
'col',
@Stanback
Stanback / fixuri.scala
Last active Dec 14, 2016
Regex for fixing improperly formatted URIs
View fixuri.scala
/*
* Snippet to encode invalid characters from improperly formatted URIs
*
* RFC 3986 defines that URIs may contain the following characters:
* ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=`.```
*/
import java.net.URLEncoder
"""[^A-Za-z0-9-._~:/?#\[\]@!$&'\(\)*+,;=%`]|%[^0-9a-fA-F]{2}]""".r.
@Stanback
Stanback / getOrdinal.js
Created Aug 23, 2016
Convert integer to an ordinal number (e.g. 1st, 2nd, 3rd, etc)
View getOrdinal.js
function getOrdinal(value) {
const suffixes = ['th', 'st', 'nd', 'rd'];
const normalized = value % 100;
return value + (suffixes[(normalized - 20) % 10] || suffixes[normalized] || suffixes[0]);
}
@Stanback
Stanback / emblem2hbs.sh
Created Dec 1, 2015
Convert all emblem files to handlebars format (emblem2hbs.sh)
View emblem2hbs.sh
#!/bin/bash
# Install emblem2hbs cli
npm -g install emblem2hbs
# Convert all emblem files to handlebars
for f in $(ls -1 {,**/}*.emblem); do; emblem2hbs $f; done;
# Optionally delete original emblem files
find . -name "*.emblem" -exec rm {} \;
@Stanback
Stanback / coffee2js.sh
Last active Jul 11, 2019
Convert all CoffeeScript files to Javascript (coffee2js)
View coffee2js.sh
#!/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 / requestLogger.js
Last active Nov 18, 2015
Request logger middleware example using winston logger
View requestLogger.js
// To use:
// server.use(requestLogger);
function requestLogger(req, res, next) {
req._startTime = new Date();
var logRequest = function() {
res.removeListener('finish', logRequest);
res.removeListener('close', logRequest);
var status = res.headersSent && res.statusCode || null;
var userAgent = req.headers['user-agent'];
View Dockerfile
#
# Oracle Java8 Dockerfile
#
FROM ubuntu
RUN apt-get update; \
apt-get install -y \
software-properties-common
You can’t perform that action at this time.