Skip to content

Instantly share code, notes, and snippets.

View alectrocute's full-sized avatar
🐱

Alec Armbruster alectrocute

🐱
View GitHub Profile
@also
also / wave.js
Created April 2, 2011 23:50
Generate WAVE file headers in JavaScript
// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
function buildWaveHeader(opts) {
var numFrames = opts.numFrames;
var numChannels = opts.numChannels || 2;
var sampleRate = opts.sampleRate || 44100;
var bytesPerSample = opts.bytesPerSample || 2;
var blockAlign = numChannels * bytesPerSample;
var byteRate = sampleRate * blockAlign;
var dataSize = numFrames * blockAlign;
@leostratus
leostratus / webkit-pseudo-elements.md
Created September 21, 2012 01:44
Webkit Pseudo-Element Selectors (Shadow DOM Elements)

An ongoing project to catalogue all of these sneaky, hidden, bleeding edge selectors as I prepare my JSConf EU 2012 talk.

Everything is broken up by tag, but within each the selectors aren't particularly ordered.

I have not tested/verified all of these. Have I missed some or got it wrong? Let me know. - A

A friendly reminder that you may need to set this property on your target/selected element to get the styling results you want:

-webkit-appearance:none;

@acoomans
acoomans / vlcrecord.sh
Last active February 13, 2021 13:56
Record screen with VLC from command line (needs VLC nightly build)
/Applications/VLC-unstable.app/Contents/MacOS/VLC -I rc screen:// --noaudio --sout "#transcode{vcodec=h264,venc=x264, vb=800,acodec=none,scale=1.0}:std{access=file,mux=mp4,dst=my_first_transcoded_movie.mp4}"
@danharper
danharper / background.js
Last active March 30, 2024 18:25
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@cobookman
cobookman / gist:c1a9856a4588496b021a
Last active August 17, 2021 12:39
HTML5 Audio (mp3) and Video (webm) live transcoding streams

The following two functions will stream just about any audio or video file to any browsers supporting mp3 and/or webm. Due to the unknown number of bytes, a custom html5 audio/video player will have to be written (my next step) to allow seeking.

For w/e reason node.js didn't want to spawn a child process with a unix pipe in it. This could be so that they can keep support for windows computers. As such I've created the following bash script:

#!/bin/bash
START_TIME=${2:-0}
VARIABLE_BIT_RATE=${3:-4}
ABSOLUTE_PATH=$1
@jarlg
jarlg / sing.html
Created October 3, 2015 15:48
js example using webaudio to analyse mic input to control an oscillator
<!DOCTYPE html>
<html>
<head></head>
<body>
<script type=text/javascript>
navigator.getUserMedia = navigator.getUserMedia
|| navigator.webkitGetUserMedia
|| navigator.mozGetUserMedia;
@Maarten-Wijnants
Maarten-Wijnants / gist:ec4a3e9e65504e7e67a0873dca353871
Last active March 16, 2020 15:33
Ubuntu 14.04 Asterisk server installation
https://www.odoo.com/apps/modules/8.0/crm_voip/
# Install asterisk server on Ubuntu 14.04
# 1. Install dependencies
sudo apt-get update
sudo apt-get install wget
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install ncurses-dev
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8

@marcelo-ribeiro
marcelo-ribeiro / javascript-remove-accents.js
Last active May 21, 2023 09:17 — forked from fabiofdsantos/angularJS_removeAccents.js
An Javascript function to remove accents and others characters from an input string.
// Example: https://codepen.io/marcelo-ribeiro/pen/OJmVOyW
const accentsMap = new Map([
["A", "Á|À|Ã|Â|Ä"],
["a", "á|à|ã|â|ä"],
["E", "É|È|Ê|Ë"],
["e", "é|è|ê|ë"],
["I", "Í|Ì|Î|Ï"],
["i", "í|ì|î|ï"],
["O", "Ó|Ò|Ô|Õ|Ö"],