Skip to content

Instantly share code, notes, and snippets.

View moll's full-sized avatar

Andri Möll moll

View GitHub Profile
@williewillus
williewillus / primer.md
Last active February 26, 2025 07:07
1.13/1.14 update primer

This primer is licensed under CC0, do whatever you want.

BUT do note that this can be updated, so leave a link here so readers can see the updated information themselves.

1.13 and 1.14 are lumped together in this doc, you're on your own if you just want to go to 1.13 and not 1.14, for some reason.

1.15 stuff: https://gist.github.com/williewillus/30d7e3f775fe93c503bddf054ef3f93e

Things in Advance

  • ResourceLocation now throw on non-snake-case names instead of silently lowercasing for you, so you probably should go and change all those string constants now. More precisely, domains must only contain alphanumeric lowercase, underscore (_), dash (-), or dot (.). Paths have the same restrictions, but can also contain forward slashes (/).
@moll
moll / controller.js
Last active January 2, 2016 08:09
World's smallest useful Node.js Express web controller library you can do. Say no to frameworks!
var inherit = require("descend")
var Controller = module.exports = function(req, res, next) {
this.req = req
this.res = res
this.next = next
}
Controller.inherit = function() {
var heir = inherit.apply(this, arguments)
@moll
moll / migrate_sessions_to_devise_3.rb
Created September 2, 2013 21:56
Because Devise 3 (and/or Warden) changed the signature of the session info, all sessions were invalidated and thereby people logged out. You do *not* log people out unless they ask for it. Capisce? This migration migrates migraines by migrating those sessions. Replace the word "account" and "Account" if your account model isn't named Account, bu…
class MigrateSessionsToDevise3 < ActiveRecord::Migration
class Session < ActiveRecord::Base
attr_protected
serialize :data, JSON
end
def up
Session.find_each do |session|
warden = session.data["warden.user.account.key"]
next unless warden
@digitalresistor
digitalresistor / Duplicate_EVP_PKEY.md
Last active October 23, 2018 01:38
Stupid OpenSSL idiosyncrasies/bad documentation/missing documentation I run across, or simply completely undocumented functions.

You are now getting to a point where you know you want to get a copy of an EVP_PKEY for one reason or another, not that it matters much why, you just need it.

So you start looking for a way to duplicate it, there has to be a function for it, right? You come across EVP_PKEY_CTX_dup, so you make the assumption that EVP_PKEY_dup should probably exist too ... well you'd be wrong. You come across this message on the OpenSSL mailling list: http://www.mail-archive.com/[email protected]/msg17608.html and the next follow-up says to just up the reference count, or RSA_dup() and copy it into the new EVP_PKEY ... except RSA_dup() doesn't exist either.

No real solutions come out of that email thread. No deep copies seem to be possible, well until you simply consider converting it from an EVP_PKEY format to PEM/DER and then back to an EVP_PKEY.

So, in that case all that is left is to encode it to PEM/DER and then decode it from PEM/DER.

// Create new memory BIO

BIO* tbio = BIO_new(BIO_s_