Skip to content

Instantly share code, notes, and snippets.

@jedp
jedp / gist:e59b9a342e020eb1418ea8104ead4905
Last active November 30, 2025 05:12
Raspotify + Schiit Modi
# /etc/raspotify/conf -- Arguments/configuration for librespot
# To restart: sudo systemctl restart raspotify
# A non-exhaustive list of librespot options and flags.
# Please see https://github.com/dtcooper/raspotify/wiki &
# https://github.com/librespot-org/librespot/wiki/Options
# for configuration details and a full list of options and flags.
# You can also find a full list with `librespot -h`.
@jedp
jedp / gist:3166329
Created July 23, 2012 21:25
Hash to small integer
// Hash 'string' to a small number (digits default: 6)
function hash(string, digits) {
digits = digits || 6;
var m = Math.pow(10, digits+1) - 1;
var phi = Math.pow(10, digits) / 2 - 1;
var n = 0;
for (var i = 0; i < string.length; i++) {
n = (n + phi * string.charCodeAt(i)) % m;
}
return n.toString();
@jedp
jedp / gist:3005816
Created June 27, 2012 18:18
postMessage() security review checklist

Security-Reviewing Uses of postMessage()

The postMessage() API is an HTML5 extension that permits string message-passing between frames that don't share the same origin. It is available in all modern browsers. It is not supported in IE6 and IE7.

postMessage is generally considered very secure as long as the programmer is careful to check the origin and source of an arriving

@jedp
jedp / gist:3778932
Created September 24, 2012 22:50
B2G repo setup and build quickstart

B2G Quickstart for Payments and Identity

Before you begin: You want to do this on a Mac. I have been using Linux for months, and unresolved redraw issues (white screen of death) are killing me. Mac works great. Use OSX.

This sets you up to make two separate targets:

  • One for a desktop [simulator] [1]
  • One for the Unagi [device] [2]

These are the moving parts:

  • [mozilla-inbound repo] [3] clone (hg)
@jedp
jedp / LEDs-STM32-SPI-DMA.md
Last active January 9, 2024 05:17
SPI DMA LED hacking

Controlling addressable LEDs with STM32 SPI + DMA

Overview

RGB5050 LEDs are programmed by sending a stream of 24-bit GRB packets, MSB first.

The logical 1s and 0s in the packets are encoded on a single line which is sent high or low with these timings:

  • 0 -> 0.3µs high ± 0.15µs, 0.9us low ± 0.15µs
@jedp
jedp / gist:2956223
Created June 19, 2012 20:03
libuv simple async
#include <v8.h>
#include <v8-profiler.h>
#include <node.h>
#include <uv.h>
#include <sys/time.h>
#include <iostream>
using namespace node;
using namespace v8;
using namespace std;
@jedp
jedp / gist:3922102
Created October 20, 2012 05:12
Blog Draft - Tracking Down Memory Leaks in Node.JS

#Tracking Down Memory Leaks in Node.JS

Last month, the Identity team at Mozilla delivered the first beta release of Persona. Getting to this point, we built a lot of tools to help us achieve the scalability and performance that Persona demands, and to help us with problems ranging from debugging to localization to dependency management and more. As a team, we hope our solutions will be useful to other developers, and of course we hope that other developers will help us make our tools even better. So we're kicking off a series of blog posts in which we're going to talk about

@jedp
jedp / example.js
Created August 1, 2012 20:45
Node.JS CouchDB paginator
var cradle = require('cradle');
// change as necessary
var host = '127.0.0.1';
var port = 5984;
var dbname = 'foo';
// setup cradle db and paginator
var conn = new (cradle.Connection)(host, port);
var db = conn.database(dbname);
@jedp
jedp / HOSTNAME_FIX.md
Last active February 17, 2022 19:16
Fix for InetAddress.getLocalHost on apple M1: Prevent hanging on inane DNS lookup

Fixing Ludicrous Java Localhost DNS Lookup on Mac

I recently started using the excellent adm wrapper for the android debug bridge.

I quickly noticed that my app was hanging on startup on an aarch_64 (Apple M1) machine.

Fortunately, vert.x, a dependency of adm, gave the following warning:

[vertx-blocked-thread-checker] WARN io.vertx.core.impl.BlockedThreadChecker - Thread Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 4985 ms, time limit is 2000 ms
@jedp
jedp / gist:2564204
Created May 1, 2012 01:27
basic zshrc
#!/usr/bin/env zsh
# Completions and autoload {{{
# note - you can get a clean config using compinstall and zsh-newuser-install
zstyle ':completion:*' completer _expand _complete _correct
zstyle ':completion:*' completions 4
zstyle ':completion:*' glob 1
zstyle ':completion:*' group-name ''
zstyle ':completion:*' ignore-parents parent pwd