Skip to content

Instantly share code, notes, and snippets.

View cannikin's full-sized avatar
🔨
Woodworking

Rob Cameron cannikin

🔨
Woodworking
View GitHub Profile
rtl_fm, a simple narrow band FM demodulator for RTL2832 based DVB-T receivers
Use: rtl_fm -f freq [-options] [filename]
-f frequency_to_tune_to [Hz]
use multiple -f for scanning (requires squelch)
ranges supported, -f 118M:137M:25k
[-M modulation (default: fm)]
fm, wbfm, raw, am, usb, lsb
wbfm == -M fm -s 170k -o 4 -A fast -r 32k -l 0 -E deemp
raw mode outputs 2x16 bit IQ pairs
pi@picluster1 ~ $ sudo rtl_fm -f 441M -M wbfm -s 100000 -r 48000 -l 80 - | aplay -r 48k -f S16_LE
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001
Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to automatic.
Tuned to 441291000 Hz.
Oversampling input by: 11x.
Oversampling output by: 1x.
# app/views/posts/show.html.erb
<article id="post-<%= @post.id %>" class="post">
<h1><%= @post.title %></h1>
<%= @post.body %>
<small><%= @post.author %></small>
<section class="comments">
<h2>Comments</h2>
<%= render @post.comments %>
</section>
</article>
@cannikin
cannikin / gist:abb686146972a6716764
Created June 22, 2015 22:56
Git pre-commit hook for Ruby/Javascript debugging statements
#!/bin/sh
FILES='(js|css|rb|haml|erb)'
FORBIDDEN='(binding.pry|console.|debugger)'
GREP_COLOR='4;5;37;41'
if [[ $(git diff --cached --name-only | grep -E $FILES) ]]; then
git diff --cached --name-only | grep -E $FILES | \
xargs grep --color --with-filename -n -E $FORBIDDEN && \
printf "\nLooks like you are trying to commit something you shouldn't. Please fix your diff, or run 'git commit --no-verify' to skip this check, if you must." && \
@cannikin
cannikin / README.md
Last active March 28, 2019 16:08
Typical Ruby on Rails AWS Server Setup

Typical Ruby on Rails AWS Server Setup

You should be able to start a fresh EC2 instance of Ubuntu and follow the instructions below to get a server with your preferred version of Ruby, nginx ready to delegate requests to Unicorn, and logrotate setup to keep your disk from filling up with log files. You will also have ruby-install for installing new rubies and chruby for switching between them. A .ruby-version file will be added to the home directory of the user that runs this script.

Install

  1. Start an EC2 instance using the latest Ubuntu image (as of 2015-06-18 ami-5189a661 for EBS, 64-bit SSD)
  2. Copy the config files below into /tmp using the file names specified in the title.
  3. Edit /tmp/setup.sh and change the variables at the top to match your setup
  4. Make /tmp/setup.sh executable: chmod +x /tmp/setup.sh
positron-2:cal_counter_grape rob$ rake jasmine:ci
[2015-04-07 11:33:05] INFO WEBrick 1.3.1
[2015-04-07 11:33:05] INFO ruby 2.2.1 (2015-02-26) [x86_64-darwin14]
[2015-04-07 11:33:05] INFO WEBrick::HTTPServer#start: pid=21195 port=59830
Waiting for jasmine server on 59830...
jasmine server started.
F
Failures:
Entries sorts entries by ate_at, newest first
@cannikin
cannikin / gist:08ab4d8002659d4b3da4
Last active August 29, 2015 14:15
Raspberry Pi 2 overclock benchmark
# Procedure
#
# From a completely fresh restart, ssh'd into the Pi from my mac and then ran the
# sysbench command listed at the top of each section. Copied and pasted the
# output, restarted, and ran the next.
#
# 1000MHz overclock settings:
#
# arm_freq=1000
# sdram_freq=500
@cannikin
cannikin / clean_marvel.rb
Created December 5, 2014 18:44
Delete all of the annoying .marvel indexes from Elasticsearch
require 'elasticsearch'
require 'optparse'
client = Elasticsearch::Client.new :host => 'localhost:9200'
indices = client.cat.indices.split("\n").collect { |i| i.split(' ')[1] }
indices.each do |index|
if index =~ /\.marvel/
client.indices.delete :index => index
puts "Deleting #{index}"
- cache [@user, @user.posts] do
= @user.inspect
- @user.posts.each do |post|
- cache post do
= post.inspect
@cannikin
cannikin / gist:9242443
Created February 27, 2014 01:26
HAML filter example
%h1 Heading 2
:javascript
console.info
%h2 Heading 2