Skip to content

Instantly share code, notes, and snippets.

@revolunet
revolunet / create-wav-from-buffer.js
Last active January 29, 2022 14:01
web audio + wav buffering
/*
Goal : instantly play any wav source without download the file and without <audio/>
Idea is to use the fetch streaming API and pass raw data to web audio
My use case is playng a wav file
following http://stackoverflow.com/questions/38589614/webaudio-streaming-with-fetch-domexception-unable-to-decode-audio-data/38593356#38593356
@superjamie
superjamie / raspberry-pi-vpn-router.md
Last active December 29, 2024 07:04
Raspberry Pi VPN Router

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to PrivateInternetAccess VPN.

Requirements

Install Raspbian Jessie (2016-05-27-raspbian-jessie.img) to your Pi's sdcard.

Use the Raspberry Pi Configuration tool or sudo raspi-config to:

@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active March 14, 2025 01:20
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@brianmacarthur
brianmacarthur / flash-app.js
Last active March 19, 2025 14:21
Flash messaging in Express 4: express-flash vs. custom middleware in ejs, handlebars, or jade
var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var flash = require('express-flash');
var handlebars = require('express-handlebars')
var app = express();
var sessionStore = new session.MemoryStore;
// View Engines
@ajfisher
ajfisher / _readme.md
Last active November 21, 2023 16:28
Auto WiFi detection and hotspot creation in boot for RPI

Auto WiFi detection or wifi hostpot creation during boot for RPI

Note: These are rough notes and there may be some variance as versions of raspbian get updated but should be pretty reliable as a guide.

This gist provides some instructions and config in order to have your Raspberry PI automatically connect to a roamed network, however if it fails to discover an available network it will set itself up as a wireless access point for you to connect to.

@deandob
deandob / livestream
Created February 26, 2014 22:31
Node.JS function to remux mp4/h.264 video from an IP camera to a HTML5 video tag using FFMPEG
// Live video stream management for HTML5 video. Uses FFMPEG to connect to H.264 camera stream,
// Camera stream is remuxed to a MP4 stream for HTML5 video compatibility and segments are recorded for later playback
var liveStream = function (req, resp) { // handle each client request by instantiating a new FFMPEG instance
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var reqUrl = url.parse(req.url, true)
var cameraName = typeof reqUrl.pathname === "string" ? reqUrl.pathname.substring(1) : undefined;
if (cameraName) {
try {
cameraName = decodeURIComponent(cameraName);
@darkyen
darkyen / jsMp3dec.js
Last active January 13, 2023 02:36
A javascript based decoder for mp3 frame parsing supports id3
/*
var net = require('net');
var http = require('http');
var listeners = [];
var Meta = {};
var streamer = http.createServer(function(req,res){
res.write('ICY 200 OK\r\nicy-notice1:<BR>FUCK OFF <BR>icy-notice2:SHOUTcast Distributed Network Audio Server/posix v1.2.3<BR>icy-name:'+Meta.name+'\r\nicy-genre:'+Meta.genre+'\r\nicy-url:'+Meta.url+'\r\nContent-Type:audio/mpeg\r\nicy-pub:1\r\nicy-br:'+Meta.br+'\r\nicy-metaint:8192\r\n\r\n');
listeners.push(res);
});
@kadishmal
kadishmal / app.js
Created October 11, 2012 08:36
Simple Node.js server which responds in chunked transfer encoding
var http = require('http');
http.createServer(function (request, response) {
response.setHeader('Content-Type', 'text/html; charset=UTF-8');
response.setHeader('Transfer-Encoding', 'chunked');
var html =
'<!DOCTYPE html>' +
'<html lang="en">' +
'<head>' +
@hillct
hillct / bla.js
Created May 30, 2012 14:47 — forked from ovaillancourt/bla.js
registering methods on app in a middleware
//That's your middleware code
function myMiddleware(app){
var myVar = 42; //Put middleware-wide vars in the closure.
var actualMiddleware = function(req, res, next){
//Do stuffs here
next();
@ovaillancourt
ovaillancourt / bla.js
Created May 29, 2012 15:11
registering methods on app in a middleware
//That's your middleware code
function myMiddleware(app){
var myVar = 42; //Put middleware-wide vars in the closure.
var actualMiddleware = function(req, res, next){
//Do stuffs here
next();