Skip to content

Instantly share code, notes, and snippets.

View scottwater's full-sized avatar

Scott Watermasysk scottwater

View GitHub Profile
@scottwater
scottwater / index.js
Created March 27, 2019 14:04
Heroku/Fly SSL Proxy
import { proxy } from "@fly/cdn"
import { httpsUpgrader } from "@fly/cdn/lib/middleware"
const origin = proxy("https://YOURAPP.herokuapp.com", {
headers: { host: "YOURAPP.herokuapp.com" }
})
const router = httpsUpgrader(origin)
fly.http.respondWith(router)
@scottwater
scottwater / sample.html
Last active July 20, 2018 13:42
KickoffLabs Known Lead Event
<script>
$(document).ready(function() {
$(document).on('kol:knownlead', function(e, lead){
var social_id = lead.id;
});
});
</script>
@scottwater
scottwater / backplan_api.rb
Created February 23, 2018 18:46
Backplane API
class BackplaneApi
include HTTParty
debug_output $stderr if Rails.env.development?
base_uri 'www.backplane.io:443'
basic_auth ENV['BACKPLANE_TOKEN'], ''
format :json
def add_route(pattern, labels={})
@scottwater
scottwater / segment.html
Created February 22, 2018 14:09
Sample KickoffLabs Segment Integration.
<script type="text/javascript">
var segment_api_key = 'YOUR KEY HERE';
window.analytics||(window.analytics=[]),window.analytics.methods=["identify","track","trackLink","trackForm","trackClick","trackSubmit","page","pageview","ab","alias","ready","group","on","once","off"],window.analytics.factory=function(a){return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(a),window.analytics.push(t),window.analytics}};for(var i=0;i<window.analytics.methods.length;i++){var method=window.analytics.methods[i];window.analytics[method]=window.analytics.factory(method)}window.analytics.load=function(a){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src=("https:"===document.location.protocol?"https://":"http://")+"d2dq2ahtl5zl1z.cloudfront.net/analytics.js/v1/"+a+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)},window.analytics.SNIPPET_VERSION="2.0.6",
window.analytics.load(segment_api_key),
window.analytics.page();
</scr
@scottwater
scottwater / leaderboard_incognito.html
Last active February 21, 2018 19:36
Customize your LeaderBoard name list
<script type="template" id="incognito_rows">
<thead>
<tr>
<th>{{board_settings.rank_text}}</th>
<th>{{board_settings.who_text}}</th>
<th>{{board_settings.score_text}}</th>
</tr>
</thead>
<tbody>
{{#data.leads}}
@scottwater
scottwater / form.html
Created February 21, 2014 16:42
How to collect emails for KickoffLabs with just a HTML Form (note the list id 1905 and return_url hidden input).
<form class="form-inline" role="form" method="POST" action="https://api.kickofflabs.com/v1/1905/subscribe">
<input type="hidden" name="return_url" value="http://kickofflabs.com">
<label for="email">Email address</label>
<input type="email" id="email" name="email" placeholder="Your Best Email Address">
<button type="submit">Sign Me Up</button>
</form>
@scottwater
scottwater / push_bulk_in.rb
Created March 21, 2017 14:23
Sidekiq Push Bulk In
module Sidekiq
class Client
def self.push_bulk_in(interval, items)
int = interval.to_f
now = Time.now.to_f
ts = (int < 1_000_000_000 ? now + int : int)
items['at'.freeze] = ts if ts >= now
push_bulk(items)
end
module Keen
class AESHelperOld
def self.aes256_encrypt(key, plaintext, iv = nil)
puts 'IN DA MONKEY PATCH!'
padded_key = key
aes = OpenSSL::Cipher::AES.new(256, :CBC)
aes.encrypt
aes.key = padded_key
aes.iv = iv unless iv.nil?
@scottwater
scottwater / leaderboard.htm
Last active March 14, 2017 14:46
More Leads on the LeaderBoard
<!- Add this to the header HTML area of your KickoffLabs Landing Page ->
<script>
var kol_leader_board_options = {board_settings: {limit: 25}};
</script>
@scottwater
scottwater / backplane_health_check.rb
Last active January 24, 2017 14:40
Sample health check middleware for backplane.io
class BackplaneHealthCheck
OK_RESPONSE = [ 200, { 'Content-Type' => 'text/plain' }, ['OK!'.freeze]]
def initialize(app)
@app = app
end
def call(env)
if env['HTTP_HOST'.freeze] == 'backend'.freeze && env['PATH_INFO'.freeze] == '/health'.freeze
return OK_RESPONSE