Skip to content

Instantly share code, notes, and snippets.

View devoncrouse's full-sized avatar

Devon Crouse devoncrouse

View GitHub Profile
#!/usr/bin/env bash
# ./getPitchers.sh <apiKey>
CAMS=$(curl -s -L -X GET \
https://developer-api.nest.com/devices/cameras/ \
-H "authorization: Bearer ${1}" \
-H 'cache-control: no-cache' \
-H 'content-type: application/json')
$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog # provides kernel logging support
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$FileOwner root
$FileGroup root
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$WorkDirectory /var/spool/rsyslog
$IncludeConfig /etc/rsyslog.d/*.conf
@devoncrouse
devoncrouse / MessageConsumer.java
Created July 25, 2013 16:52
Simple class to consume from a Kafka topic
import java.util.List;
import java.nio.ByteBuffer;
import java.io.IOException;
import kafka.consumer.Consumer;
import kafka.consumer.ConsumerConfig;
import kafka.consumer.ConsumerIterator;
import kafka.consumer.KafkaStream;
import kafka.javaapi.consumer.ConsumerConnector;
@devoncrouse
devoncrouse / clean_audio.sh
Created May 7, 2013 17:02
Using Sox (http://sox.sourceforge.net) to remove background noise and/or silence from audio files (individually, or in batch).
# Create background noise profile from mp3
/usr/bin/sox noise.mp3 -n noiseprof noise.prof
# Remove noise from mp3 using profile
/usr/bin/sox input.mp3 output.mp3 noisered noise.prof 0.21
# Remove silence from mp3
/usr/bin/sox input.mp3 output.mp3 silence -l 1 0.3 5% -1 2.0 5%
# Remove noise and silence in a single command
@devoncrouse
devoncrouse / es_index_maintenance.js
Last active June 29, 2017 21:47
Elastic Search maintenance script for periodic indices. Manages optimization/write-protection/closure/removal of indices based on age (derived from index naming convention) and status.
#!/usr/bin/env node
// Configuration
var argv = require('optimist')
.usage('Usage: $0 --prefix index_prefix [options]')
.demand(['prefix'])
.describe({
host: 'Elastic Search host',
port: 'Elastic Search port',
secure: 'Use secure Elastic Search connection',
@devoncrouse
devoncrouse / hfsc.sh
Last active December 16, 2015 10:09
Adapted from https://gist.github.com/bradoaks/940616. Multiple port-based prioritization rules, and explicit de-prioritization for S3 CIDR ranges (long-running backups no longer impede browsing, etc.)
#!/bin/bash
# Set this to your internet-facing network interface:
WAN_INTERFACE=eth0
# Set this to your local network interface:
LAN_INTERFACE=bond0
# How fast is your downlink?
MAX_DOWNRATE=12288kbit
@devoncrouse
devoncrouse / dictionary.js
Created October 9, 2011 20:12 — forked from dakatsuka/dictionary.js
Dictionary Class for Node.js
var Dictionary = function() {
this.keys = {};
this.length = 0;
this.defaultValue = null;
};
Dictionary.prototype.store = function(key, value) {
this.keys[key] = value;
this.length++;
};