Skip to content

Instantly share code, notes, and snippets.

View WilliamNHarvey's full-sized avatar
🍓
👉🤠👉

William Harvey WilliamNHarvey

🍓
👉🤠👉
View GitHub Profile
@WilliamNHarvey
WilliamNHarvey / ruby_rsa_publickey.rb
Last active February 23, 2024 00:57
Generate an instance of OpenSSL::PKey::RSA from `n` and `e` in OpenSSL 3 on Ruby
# Given n and e in typical encoding, like that found on a jwks well-known.
# For example for google, from https://www.googleapis.com/oauth2/v3/certs
n = "t0VFy4n4MGtbMWJKk5qfCY2WGBja2WSWQ2zsLziSx9p1QE0QgXtr1x85PnQYaYrAvOBiXm2mrxWnZ42MxaUUu9xyykTDxsNWHK--ufchdaqJwfqd5Ecu-tHvFkMIs2g39pmG8QfXJHKMqczKrvcHHJrpTqZuos1uhYM9gxOLVP8wTAUPNqa1caiLbsszUC7yaMO3LY1WLQST79Z8u5xttKXShXFv1CCNs8-7vQ1IB5DWQSR2um1KV4t42d31Un4-8cNiURx9HmJNJzOXbTG-vDeD6sapFf5OGDsCLO4YvzzkzTsYBIQy_p88qNX0a6AeU13enxhbasSc-ApPqlxBdQ"
e = "AQAB"
rsa = create_rsa_key(n, e)
def create_rsa_key(n, e)
data_sequence = OpenSSL::ASN1::Sequence([
OpenSSL::ASN1::Integer(base64_to_long(n)),
@WilliamNHarvey
WilliamNHarvey / my_controller.rb
Created August 8, 2022 23:31
DPoP on browser with Rails
# https://github.com/WilliamNHarvey/dpop-ruby
class MyController < ApplicationController
include Dpop::Controller
ensure_dpop!
def index
uri = URI("https://www.myresourcehost.com/index?page=1")
proof = get_proof(htu: dpop_htu(uri), htm: "GET")
@WilliamNHarvey
WilliamNHarvey / shopifyreviews.rb
Created May 29, 2021 21:19
Combine etsy reviews with products to import to shopify
# Update json file names and run with ruby shopifyreviews.rb
require 'json'
require 'date'
# EtsySoldOrderItems csv file, converted to json
order_item_file = File.read('./EtsySoldOrderItems2021.json')
# Reviews file exported from etsy.
# If you have many reviews and you want all of them in shopify, there's some extra work to do here to combine those files.
reviews_file = File.read('./reviews.json')
package main
import (
"fmt"
"math"
"math/rand"
"time"
"sync"
)

Keybase proof

I hereby claim:

  • I am williamnharvey on github.
  • I am williamnharvey (https://keybase.io/williamnharvey) on keybase.
  • I have a public key ASClLqTUgZv8g2R6i70APAtDyJI6b18klAkg1nonNHJB0Qo

To claim this, I am signing this object:

@WilliamNHarvey
WilliamNHarvey / .block
Last active August 9, 2018 17:21
fork of Collapsible tree diagram in v4
license: mit