Skip to content

Instantly share code, notes, and snippets.

View tenderlove's full-sized avatar
©️
 ​[object Object] :trollface:

Aaron Patterson tenderlove

©️
 ​[object Object] :trollface:
View GitHub Profile
struct heap_page_header {
struct heap_page *page;
};
struct heap_page_body {
struct heap_page_header header;
/* char gap[]; */
/* RVALUE values[]; */
};
struct heap_page_header {
struct heap_page *page;
};
struct heap_page_body {
struct heap_page_header header;
/* char gap[]; */
/* RVALUE values[]; */
};
struct heap_page {
short total_slots;
short free_slots;
short pinned_slots;
short final_slots;
struct {
unsigned int before_sweep : 1;
unsigned int has_remembered_objects : 1;
unsigned int has_uncollectible_shady_objects : 1;
unsigned int in_tomb : 1;
struct heap_page {
short total_slots;
short free_slots;
short pinned_slots;
short final_slots;
struct {
unsigned int before_sweep : 1;
unsigned int has_remembered_objects : 1;
unsigned int has_uncollectible_shady_objects : 1;
unsigned int in_tomb : 1;
# Method tables and constant tables are lazily allocated. When a module is
# mixed in to a class, it creates an ICLASS which is the object used to
# represent the module in the inheritance hierarchy. The ICLASS object shares
# some tables with the source module, so when it gets created Ruby will
# allocate these tables to share even if they didn't exist previously.
#
# You can see the tables get allocated in this function:
# https://github.com/ruby/ruby/blob/962c302a1ae8e50738c36adb61c8ec9c9fa5a49b/class.c#L832-L862
#
# Output on my machine:
class Infinite
def each
return enum_for(:each) unless block_given?
loop do
('a'..'zzz').each do |m|
yield m
end
end
end
end

URI.encode deprecations

We're getting these deprecation warnings because URI.encode the method doesn't really makes sense. Paths in URIs are escaped differently than query parameters, and those are escaped differently than anchors (I think). So fixing these warnings isn't always straight forward. We need to think about the context in which the data will be used. Typically I've seen this method used with query parameters, and in that case we should use URI.encode_www_form.

Keyword Argument Deprecations

From b5aeef5703dab7da9ebb47cc20e4c8b64f7f5866 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <[email protected]>
Date: Thu, 12 Mar 2020 10:25:48 -0700
Subject: [PATCH] Fix possible XSS vector in JS escape helper
This commit escapes dollar signs and backticks to prevent JS XSS issues
when using the `j` or `javascript_escape` helper
CVE-2020-5267
---
# frozen_string_literal: true
require "active_record"
require "active_record/railties/collection_cache_association_loading"
require "action_controller"
require "action_view"
require "tmpdir"
require "benchmark/ips"
ActionView::PartialRenderer.prepend(ActiveRecord::Railties::CollectionCacheAssociationLoading)
# An example of calculating least-squares linear regression fit in Ruby
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors