Skip to content

Instantly share code, notes, and snippets.

@kelmerp
kelmerp / csp-hash.js
Created April 2, 2025 20:38 — forked from rubenarakelyan/csp-hash.js
Calculate the CSP hash of a script in the browser console
const scripts = document.getElementsByTagName("script"),
script_content = scripts[scripts.length - 1].innerHTML,
enc = new TextEncoder(),
data = enc.encode(script_content);
crypto.subtle.digest('SHA-256', data).then(function(val) {
const digest = ["sha256", _arrayBufferToBase64(val)].join("-");
console.log(`The digest for your script is: ${digest}`);
});
@kelmerp
kelmerp / gist:f4d72ee501db588ac21ef1c3ff758a40
Created August 15, 2024 15:50
bh db wipe; reset tables on our end
irb(main):005:0> Corp::BhReservationRequest.distinct(:bh_user_info_id).pluck(:bh_user_info_id)
=> ["08aa7047-da53-447f-9873-3c2155c2fb9e", "08afc806-ff07-46ec-b90e-fb0fd75806c0", "0a42b13b-6374-42d6-9720-747e6234fe04", "0a70fee5-362c-4f29-b750-3914e6f1a9ed", "0beb079e-1fda-48ea-b659-b6fae092071d", "10681110", "109487b5-191f-4869-82eb-0151d134d63d", "14153983", "16431310", "1689bbfb-f072-4e81-88d4-4223351171e4", "17652199", "19945996", "1af107b5-a718-4fbe-aa37-6c05c14ce080", "1c5472ce-8276-ed11-a866-005056993f98", "1d7766ca-f405-ec11-a858-005056993f98", "1f36d445-ba66-48c5-bec3-244a745062d5", "20214407", "205bb208-21ed-4fe5-9697-669895e38510", "214fa430-a852-4424-ad70-f0b6342ef2bf", "269f1e3f-d51c-4a23-a5f3-eb6197d56c87", "27964329", "28289464", "2b6dec2e-362b-4305-8d72-d0372c4c4b63", "2bf2843a-eaf8-4ee4-9050-13ddb437b280", "2c262371-faea-e911-a842-005056993f98", "2f5e762a-bc5a-4aff-a30c-4aa76313c374", "2f8da8b7-0da0-4b5a-85de-65372453ce15", "30041851", "3128cfcb-e4f1-4ec6-a685-cd6d18aaba58", "31c0ed20-3b5d-46
@kelmerp
kelmerp / HOWTO.md
Last active May 18, 2024 12:39 — forked from ivanvermeyen/HOWTO.md
Multiple MySQL versions on MacOS with Homebrew

Update - 4 september 2020

Making multiple MySQL versions work with Homebrew was tricky to say the least. Fortunately there are 2 new easy ways that I learned of to achieve this.

DBngin app

As @4unkur and @henrytirla commented below, there is this extremely easy to use app called DBngin, which lets you setup multiple databases (not only MySQL) simultaneously using different ports:

https://dbngin.com/

@kelmerp
kelmerp / gist:3e645298958263c39ac00a701c82fbac
Created April 7, 2022 16:40
rails best practices report on sittercity
Source Code: |===============================================================================================================|
/Users/kPerez/dev/ruby/empire-monorepo/sittercity/db/schema.rb:15 - always add db index (account_notes => [member_id])
/Users/kPerez/dev/ruby/empire-monorepo/sittercity/db/schema.rb:15 - always add db index (account_notes => [transaction_id])
/Users/kPerez/dev/ruby/empire-monorepo/sittercity/db/schema.rb:24 - always add db index (account_termination_reasons => [member_id])
/Users/kPerez/dev/ruby/empire-monorepo/sittercity/db/schema.rb:131 - always add db index (aloka_legacy_conversation_messages_email_templates_xref => [conversation_message_id])
/Users/kPerez/dev/ruby/empire-monorepo/sittercity/db/schema.rb:165 - always add db index (apple_receipts => [payment_method_id])
/Users/kPerez/dev/ruby/empire-monorepo/sittercity/db/schema.rb:202 - always add db index (background_check_disputes => [background_check_id])
/Users/kPerez/
@kelmerp
kelmerp / zoo.js
Last active December 22, 2015 09:29 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
var Zoo = {
init: function(animals){
this.animals = animals
},
bipeds: function(){
return this.animals.filter(function(animal){ return animal.legs === 2});
},
@kelmerp
kelmerp / index.html
Last active December 22, 2015 09:19 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/

Instructions:

  1. Download this application skeleton.
  2. Convert the app to use AJAX.
  3. Add any files you changed to your gist and submit your code.
@kelmerp
kelmerp / carousel.js
Created August 16, 2013 00:22 — forked from ksolo/carousel.js
Image Carousel
// shorthand for $(document).ready();
$(function(){
//Your code...
$("form").submit(function(event) {
event.preventDefault();
var array = $('form').serializeArray();
var emailRegex = /[A-z0-9]+@[A-z0-9]+\.[A-z]{2,4}/;
var passwordRegex = /(.*[A-Z]+.*[0-9].*|.*[0-9].*[A-Z]+.*)/;
var email = array[0].value;
var password = array[1].value;