Skip to content

Instantly share code, notes, and snippets.

@billautomata
billautomata / reduce.js
Last active August 29, 2015 14:17
reduces the precision of floats in json files to save space
// usage
// node reduce.js worldmap.geojson 3
var fs = require('fs')
var json_string = fs.readFileSync(process.argv[2])
var precision = parseInt(process.argv[3])
console.log('original length: ' + json_string.length)
@billautomata
billautomata / http_relay.js
Created April 10, 2015 00:29
http replay
var http = require('http');
http.createServer(function (req, resp) {
var h = req.headers;
h.host = "stackoverflow.com";
var req2 = http.request({
host: h.host, port: 80, path: req.url, method: req.method, headers: h
}, function (resp2) {
resp.writeHead(resp2.statusCode, resp2.headers);
resp2.on('data', function (d) { resp.write(d); });
resp2.on('end', function () { resp.end(); });
@billautomata
billautomata / speaker_email.md
Created April 13, 2015 23:06
code_art_festival_speaker_packet

#code art festival - speaker information

Thank you for participating as a speaker in Code Art Festival. This is a not-for-profit festival created as an outgrowth of the PDX Creative Coders organization.

###where

The event is on July 25, 2015 at 1417 NW Everett St in Portland Oregon. (14th, and Everett in NW Portland).

###schedule

@billautomata
billautomata / expect.sh
Created April 14, 2015 12:50
how to use expect
#!/usr/bin/expect -f
spawn openssl pkcs12 -export -in client.crt -inkey private.key -certfile ca.crt -name Evident-Dev -out clientcert.p12
expect "assword:"
send "\r\r"
interact
@billautomata
billautomata / gist:6a137a2d5a700c0f7883
Created April 19, 2015 01:37
ffmpeg image sequence to HQ mp4
ffmpeg -f image2 -r 24 -i %04d.png -vcodec libx264 -profile:v high444 -refs 16 -crf 0 -preset ultrafast a.mp4
@billautomata
billautomata / example.js
Created April 19, 2015 19:53
sdr sweeper
var rtlsdr = require('rtlsdr'); // require the module
var freq = 91495300 // local NPR fm (91.49mhz)
freq = 45495300 // random freq in Hz 45,495,300hz
rtlsdr.getDevices(function (err, devices) {
devices[0].open(function (err, device) {
device.setSampleRate(2048000);
@billautomata
billautomata / example.sh
Last active August 29, 2015 14:19
ppp over serial
# on host A
# sudo pppd [options] myip:destip /dev/usb baudrate
# sudo pppd proxyarp mtu 1280 persist nodeflate noauth lcp-echo-interval 10 crtscts lock HOST_A_IP:HOST_B_IP /dev/ttyusb baud_rate
sudo pppd proxyarp mtu 1280 persist nodeflate noauth lcp-echo-interval 10 crtscts lock 10.10.1.2:10.10.1.1 /dev/ttyUSB0 57600
# on host B
sudo pppd proxyarp mtu 1280 persist nodeflate noauth lcp-echo-interval 10 crtscts lock 10.10.1.1:10.10.1.2 /dev/ttyUSB1 57600
#!/bin/sh
# install :
# curl -o installer.sh https://gist.github.com/iNem0o/6346423/raw && chmod +x installer.sh && sudo ./installer.sh
sudo apt-get update
sudo apt-get --no-install-recommends -y install git cmake libusb-1.0-0-dev libpulse-dev libx11-dev screen qt4-qmake libtool autoconf automake libfftw3-dev
mkdir ~/src
echo "Installation de rtl_sdr"
  1. compile ffmpeg for arm https://github.com/fiorix/ffmpeg-arm
  2. create youtube 'live event'. get rtmp url + session id
  3. run this:
raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/<SESSION>

you can tweak -b and -fps to your liking. the settings above work well for 1080p. by not specifying width or height we get the full 1920x1080 resolution from the raspi camera

Convert MOV to GIF using FFmpeg and ImageMagick

I tried a few different techniques to make a GIF via command-line and the following gives me the best control of quality and size. Once you're all setup, you'll be pumping out GIFs in no time!

Preparation

Install FFmpeg

  • $ brew install ffmpeg [all your options]
    • Example: $ brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Install ImageMagick