Skip to content

Instantly share code, notes, and snippets.

View ba55ie's full-sized avatar
🍌
Use the Source Luke

Sebastiaan ba55ie

🍌
Use the Source Luke
  • Schiedam
View GitHub Profile
@adamreisnz
adamreisnz / package.json
Last active April 12, 2025 09:09
Simple pure npm scripts build process
{
"name": "project-name",
"description": "Template for static sites",
"version": "1.0.0",
"homepage": "http://www.project-name.com",
"author": {
"name": "Adam Reis",
"url": "http://adam.reis.nz"
},
"license": "UNLICENSED",
@Rich-Harris
Rich-Harris / service-workers.md
Last active May 16, 2025 04:55
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.

@lennym
lennym / app.js
Created July 19, 2016 14:55
Express middleware mounting patterns
const app = require('express');
app.use(require('./default-middleware'));
app.use(require('./router'));
module.exports = app;
@ba55ie
ba55ie / client.js
Last active February 20, 2019 07:11
Node.js SignalR V2.2.0 client
'use strict';
const jsdom = require('jsdom');
const window = jsdom.jsdom().defaultView;
const url = 'http://YOUR_SIGNALR_URL'; // Used for CORS
const hubs = 'http://YOUR_SIGNALR_HUBS_URL';
function loadScript(src) {
return new Promise((resolve, reject) => {
@dimitardanailov
dimitardanailov / sample-nginx.conf
Last active June 3, 2021 17:30
Configuration for single page application(Framework: Angularjs, Web server: Nginx)
server {
listen 80 default deferred;
server_name myapp.com;
root /var/www/project-folder/;
# Nginx and Angularjs with html mode 5 - https://gist.github.com/cjus/b46a243ba610661a7efb
index index.html;
@beaugunderson
beaugunderson / cool-modules.md
Last active February 2, 2023 19:58
cool modules from nodeconf

from streams session

  • end-of-stream - specify a callback to be called when a stream ends (which is surpsingly hard to get right)
  • duplexify - compose a Duplex stream from a Readable and a Writable stream
  • pump - pipe streams together and close all of them if one of them closes
  • pumpify - combine an array of streams into a single duplex stream using pump and duplexify
  • through2 - tools for making Transform streams
  • from2 - tools for making Readable streams

from "participatory modules" session

@AllThingsSmitty
AllThingsSmitty / mustard.js
Last active April 13, 2016 14:02
Revised cut-the-mustard browser feature detection
// Streamlined CTM method using Page Visibility API (http://caniuse.com/#feat=pagevisibility)
if ('visibilityState' in document) {
// Modern browser, add JS functionality
}
// Previous CTM method based on which DOM features are present
if('querySelector' in document
&& 'localStorage' in window
&& 'addEventListener' in window) {
// Modern browser, add JS functionality

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@tracker1
tracker1 / 01-directory-structure.md
Last active May 3, 2025 04:36
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@renegare
renegare / gulp-karma.js
Last active March 28, 2018 05:37
Gulp Karma Integration
/**
* testing tasks (using karma to test in the browser). Requires a karma.conf.js for full config
* single-run testing
* continuous testing
*/
/** base deps, but you may need more specifically for your application */
var gulp = require('gulp');
var gutil = require('gulp-util');
var path = require('path');