Skip to content

Instantly share code, notes, and snippets.

View bwsewell's full-sized avatar

Brian Sewell bwsewell

View GitHub Profile
@ashleymason
ashleymason / luxpo_retargeting_using_real_estate_ads.rb
Last active February 25, 2019 19:49
luxpo_retargeting_using_real_estate_ads
partner = Partner[:luxpo];
partner.extra_data[:default_layouts][:retargeting] = {anx_web: 'luxpo_retargeting_web', facebook: 'luxpo_retargeting_fb'};
partner.save;
pas = PartnerAutomationSetting.find_by(partner_id: partner.id);
unless pas.present?
pas = PartnerAutomationSetting.create(
automation_type: 'retargeting',
send_email: false,
launch_date: 1.year.ago,
@wteuber
wteuber / encrypt_decrypt.rb
Last active February 2, 2026 15:13
Basic encrypt and decrypt Strings in Ruby with deterministic salt or IV, generate and store random salt and IV in production
require 'openssl'
class String
CIPHER_NAME = 'aes-256-cbc'.freeze
PBKDF_ITER = 200_000
KEY_LEN = 32 # 256 bits
SALT_CONST = "fixed-global-salt-v1".freeze
IV_SALT_CONST = "fixed-iv-salt-v1".freeze
def encrypt(password)
@anantn
anantn / firebase_player_assignment.js
Last active January 14, 2023 01:51
Firebase: Assigning players in a multiplayer game. This snippet assigns you a spot in a game if the game isn't full yet.
function go() {
var userId = prompt('Username?', 'Guest');
// Consider adding '/<unique id>' if you have multiple games.
var gameRef = new Firebase(GAME_LOCATION);
assignPlayerNumberAndPlayGame(userId, gameRef);
};
// The maximum number of players. If there are already
// NUM_PLAYERS assigned, users won't be able to join the game.
var NUM_PLAYERS = 4;