Skip to content

Instantly share code, notes, and snippets.

View cannikin's full-sized avatar
🔨
Woodworking

Rob Cameron cannikin

🔨
Woodworking
View GitHub Profile

Consider this. Imagine there is an online dating site that works nearly perfectly. It was coded in a garage by a couple of college dropouts. You open an account, you answer some questions, and within three days it matches you with the love of your life. It is amazing!

It is so amazing that it attracts investors. The garage becomes an office. Now the coders are surrounded by men in suits. Now the service that was once free requires a subscription; now the terms of service are quietly altered, and the data the site gathers is sold to corporations that do who knows what with it. Money changes everything!

@cannikin
cannikin / gist:de18c08eab69e03da44ae8faf7388e60
Created April 18, 2016 17:51
Ruby Sublime style settings
{
"binary_file_patterns":
[
"log/",
"tmp/"
],
"ensure_newline_at_eof_on_save": true,
"rulers":
[
80
@cannikin
cannikin / Packages\User\RubyTest-Twilight.tmTheme
Last active December 8, 2015 18:15
Sublime Text Settings
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>TestConsoleTheme</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
source 'https://rubygems.org'
# Gems needed for edge rails
gem 'rails', github: "rails/rails"
gem 'sprockets-rails', github: "rails/sprockets-rails"
gem 'sprockets', github: "rails/sprockets"
gem 'sass-rails', github: "rails/sass-rails"
gem 'arel', github: "rails/arel"
gem 'rack', github: "rack/rack"
@cannikin
cannikin / deploy.rb
Last active October 22, 2018 09:02
Notify Sentry of a new release via Capistrano
# This task will notify Sentry via their API[1] that you have deployed
# a new release. It uses the release timestamp as the `version`
# (like 20151113182847) and the git ref as the optional `ref` value.
#
# This task requires several environment variables be set (or just
# hardcode the values in here if you like living on the edge):
#
# ENV['SENTRY_API_ENDPOINT'] : API endpoint, https://app.getsentry.com
# ENV['SENTRY_ORG'] : the organization for this app
# ENV['SENTRY_PROJECT'] : the project for this app
@cannikin
cannikin / logstasher.json
Created November 11, 2015 21:25
Logstasher output
{"method":"GET","path":"/","format":"*/*","controller":"index","action":"index","status":200,"duration":2.51,"view":0.91,"db":0.0,"ip":"50.31.164.139","route":"index#index","request_id":"1b8d526e74667b136c5b6c33adec241d","parameters":{},"user_id":null,"server":"prod1","source":"workingnotworking.app.prod","tags":["request"],"@timestamp":"2015-11-11T21:25:24Z","@version":"1"}
{"method":"GET","path":"/messages/notifications","format":"*/*","controller":"messages","action":"notifications","status":200,"duration":5.61,"db":2.56,"ip":"2.136.171.212","route":"messages#notifications","request_id":"6fd9ddd3d818954c3b7bf3f07d8b9a21","parameters":{"since":"1444824793"},"user_id":3428,"server":"prod1","source":"workingnotworking.app.prod","tags":["request"],"@timestamp":"2015-11-11T21:25:24Z","@version":"1"}
{"method":"GET","path":"/messages/notifications","format":"html","controller":"messages","action":"notifications","status":200,"duration":46.33,"db":43.06,"ip":"108.60.145.130","route":"messages#notifications","requ
@cannikin
cannikin / remote_ip.rb
Created November 10, 2015 17:36
Rails code for raising ActionDispatch::RemoteIp::IpSpoofAttackError
# Determines originating IP address. REMOTE_ADDR is the standard
# but will be wrong if the user is behind a proxy. Proxies will set
# HTTP_CLIENT_IP and/or HTTP_X_FORWARDED_FOR, so we prioritize those.
# HTTP_X_FORWARDED_FOR may be a comma-delimited list in the case of
# multiple chained proxies. The last address which is not a known proxy
# will be the originating IP.
def calculate_ip
client_ip = @env['HTTP_CLIENT_IP']
forwarded_ips = ips_from('HTTP_X_FORWARDED_FOR')
remote_addrs = ips_from('REMOTE_ADDR')
@cannikin
cannikin / make_install.out
Last active October 3, 2015 22:19
Post portaudio instructions on the Pi
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
pi@picluster1 ~/superham $ ruby demod-raw.rb iq.dat
Reading file iq.dat...
Read 5100000 data points from file.
6:1 low pass filter...
Now 850000 samples.
FM demodulator...
Deemph filter...
Reducing low pass real filter...
Now 160000 samples.
Playing 160000 data points.
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