Skip to content

Instantly share code, notes, and snippets.

View toddpress's full-sized avatar

Todd Pressley toddpress

  • ATI
  • Summerville
View GitHub Profile
@toddpress
toddpress / web.config
Created April 10, 2020 14:01
IIS-Node web.config boilerplate
?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!--
All appSettings are made available to your Node.js app via environment variables
You can access them in your app through the process.env object.
process.env.<key>
-->
<script>
$.as.route.page('settings', () => {
if(!S.user.is){ return $.as.route('hi') }
$.as('#settings', S.user);
;(() => {
$('#pet').on('keyup', function(){ $('.pet').text(this.value.length + ' letters.') });
$('#kiss').on('keyup', function(){ $('.kiss').text(this.value.length + ' letters.') });
S.user.get('settings').get('pet').on(function(l){ $('#pet').val(Gun.text.random(l, '*')) });
@Rich-Harris
Rich-Harris / service-workers.md
Last active July 10, 2024 17:04
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@jmar777
jmar777 / enum.js
Created June 21, 2016 04:36
Enum Implementation using ES6 Proxies and Symbols
function Enum(names) {
let members = Object.create(null);
members.tryParse = name => {
if (!members[name]) {
throw new Error(`Unable to parse '${name}' as an Enum member.`);
}
return members[name];
};
@remojansen
remojansen / class_decorator.ts
Last active September 14, 2023 14:54
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@shrunyan
shrunyan / app.js
Last active January 7, 2017 14:40
Example Gulp build for Riotjs + ES6 + Browserify + Babelify + Riotify
import './app.tag'
riot.mount('#app', 'app')
var child_process = require('child_process'),
http = require('http');
url = require('url'),
ffmpeg = null;
var livestream = function (req, resp) {
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var input = 'udp://225.1.1.1:8208';
@kriegsman
kriegsman / TimecodePerformance.ino
Created January 8, 2015 17:24
Sequence a performance using timecode HH,MM,SS.SSS
#include "FastLED.h"
// This sketch shows how to sequence a performance using HH,MM,SS.SSS timecode.
//
// A "ResetPerformance" method is provided so that the performance can be
// restarted from a custom external trigger, e.g., a button or event.
// For demonstration purposes, this Performance is reset if the
// sketch receives a letter "r" on the serial port.
//
// -Mark Kriegsman, January 2015
@kriegsman
kriegsman / TimedPlaylist.ino
Last active February 12, 2022 19:36
Timed playlist of animations, designed for sequencing and performance.
#include "FastLED.h"
// This sketch shows one way to define a 'timed playlist'
// of animations that automatically rotate on a custom schedule.
//
// A "ResetPlaylist" method is provided so that the playlist can be
// restarted from a custom external trigger, e.g., a button or event.
// For demonstration purposes, the playlist is reset if the
// sketch receives a letter "r" on the serial port.
//
@kriegsman
kriegsman / SoftTwinkles.ino
Last active June 12, 2024 21:34
Soft, warm twinkles. Super short code, super complicated theory of operation.
#include "FastLED.h"
#define LED_PIN 3
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define NUM_LEDS 30
CRGB leds[NUM_LEDS];
#define BRIGHTNESS 120
#define DENSITY 80