Skip to content

Instantly share code, notes, and snippets.

@chrisn
chrisn / external-player.html
Created August 31, 2023 20:31
Peaks.js with multiple audio tracks
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Peaks.js Demo Page</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="titles">
@chrisn
chrisn / peaks-howler-example.js
Last active October 12, 2022 14:28
Peaks.js custom player example with Howler.js
const audioContext = new AudioContext();
const audioUrl = '/example.mp3';
// Load audio file into audio buffer
const response = await fetch(audioUrl);
const audioData = await response.arrayBuffer();
const audioBuffer = await audioContext.decodeAudioData(audioData);
// Create Peaks.js custom player object, using Howler.js
@chrisn
chrisn / Dockerfile
Last active November 4, 2021 18:57
Compile audiowaveform in Docker for amazonlinux:1
FROM amazonlinux:1
RUN yum -y update
RUN yum -y install make wget tar gcc gcc-c++ file diffutils
RUN wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz && \
tar -xzvf cmake-3.7.2.tar.gz && cd cmake-3.7.2 && \
./bootstrap && make && make install
RUN yum -y install cmake autogen automake libtool \
gzip zip libcurl-devel zlib-static libpng-static xz git \
boost-static boost-devel \
bzip2-devel which gd-devel
@chrisn
chrisn / Dockerfile
Last active June 2, 2020 20:32
Compile audiowaveform for AWS Lambda
FROM amazonlinux:latest
RUN yum -y install make cmake3 autogen automake libtool gcc gcc-c++ wget tar gzip zip gd-devel flac-devel libvorbis-devel boost-devel libcurl-devel
# libid3tag
WORKDIR /root
RUN wget https://netix.dl.sourceforge.net/project/mad/libid3tag/0.15.1b/libid3tag-0.15.1b.tar.gz
RUN tar xzf libid3tag-0.15.1b.tar.gz
WORKDIR /root/libid3tag-0.15.1b
RUN ./configure && make && make install
@chrisn
chrisn / sinon-chai-expect.md
Last active August 26, 2016 13:22 — forked from patocallaghan/sinon-chai-expect.md
Sinon Chai assertions in expect style. Examples from http://chaijs.com/plugins/sinon-chai

Sinon JS

Spies

// Anonymous function
var spy = sinon.spy();

// Anonymous named function
var spy = sinon.spy().named('a callback');
@chrisn
chrisn / .eslintrc.js
Last active June 22, 2017 09:07
eslint config file
module.exports = {
"env": {
"browser": true,
"amd": true
},
"extends": "eslint:recommended",
"rules": {
"array-bracket-spacing": ["error", "never"],
"brace-style": ["error", "stroustrup"],
"block-scoped-var": "error",
@chrisn
chrisn / drop_shadow
Created December 28, 2013 09:36
Add a drop shadow to an image, using ImageMagick
convert <input-file> \( +clone -background black -shadow 30x8+0+0 \) +swap -background none -layers merge +repage <output-file>
@chrisn
chrisn / robocopy_backup
Created December 26, 2013 21:05
robocopy command to backup to a shared drive
robocopy D:\ Z:\BackupDir /MIR /XD "$RECYCLE.BIN" "System Volume Information" /FFT
@chrisn
chrisn / .gitconfig
Last active December 29, 2015 05:09
Git configuration
[alias]
st = status
dif = diff
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
wd = diff --word-diff
[color]
ui = true
@chrisn
chrisn / Preferences.sublime-settings
Created November 15, 2013 22:30
My Sublime Text 2 user settings
{
// Controls auto pairing of quotes, brackets etc
"auto_match_enabled": false,
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
// Set to true to ensure the last line of the file ends in a newline
// character when saving
"ensure_newline_at_eof_on_save": true,