Skip to content

Instantly share code, notes, and snippets.

View scottwater's full-sized avatar

Scott Watermasysk scottwater

View GitHub Profile
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 / 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
@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 / 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 / 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
<script>
var kol_share_links = {
network_overrides: [
[{network: 'weibo', share_text: "Hello Weibo!" language: 'zh_cn'}, 4]
]
};
</script>
@scottwater
scottwater / whatsapp.html
Created April 29, 2016 17:41
Add a what's app button to a KickoffLabs page or widget. Requires script versions 1.9.1 or greater.
<script>
var kol_share_links = {
network_overrides: [
[{network: 'whatsapp', device_type: 'mobile', share_text: "Hello WhatsApp!"}, 4]
]
};
</script>
@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 / two_to_the_power.rb
Last active April 26, 2016 18:23
Validating a value is 2 to the power of something
valid_values = 1,2,4,8
invalid_values = 3,6,99,101
def is_two_to_the_power?(value)
(Math.log2(value) % 1.0) == 0
end
valid_values.each {|i| raise "#{i} is not valid" unless is_two_to_the_power?(i)}
invalid_values.each {|i| raise "#{i} is valid" if is_two_to_the_power?(i)}
@scottwater
scottwater / Widget Event
Created June 30, 2015 14:51
KickoffLabs Widget Success Event
<script type="text/javascript">
$(document).ready(function(){
$(document).bind("kol:success", function(e, data, status, xhr) {
});
});
</script>