Skip to content

Instantly share code, notes, and snippets.

@brianhempel
brianhempel / bench_rails_memory_usage.rb
Last active March 25, 2025 18:43
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@paulirish
paulirish / bling.js
Last active February 18, 2025 14:08
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };
@aseroff
aseroff / customizing_spina.md
Last active October 18, 2023 19:58
Customizing a SpinaCMS-powered site/blog

For a while, my org was using Wordpress to manage a public-facing website, which was reverse-proxied on my Rails application's server to share its DNS (a fairly common setup). However, the cost of supporting Wordpress and the proxy became too great to justify, and we looked into replacing Wordpress with another CMS option. I came across SpinaCMS, an open-source, Rails-powered CMS, which offered a lot of upside to proxying to a seperate server running a separate application. However, there were several gotchas that took some navigating, that I want to share in one place, considering I believe these would all be common situations to anyone trying to accomplish a similar goal. This guide will assume you have completed the basic setup of gem installation and setup rake tasks.

Using MySQL instead of Postgres

If your application is already running on MySQL, you probably don't want to go through the hurdles of moving to a Postgres database. Fortunately, unless you are using the e-commer

@caged
caged / spina-pro-messages.md
Last active January 8, 2025 15:28
Getting started with spina pro message inbox.

Spina Pro Message Inbox Setup

As of 01/07/2025, the Spina Pro Messages guide is unpublished, making it a little difficult getting up and running with message inboxes. Below is information I've peiced together while trying to get it running. Hopefully it can help the next person.

Prerequisites

  • Spina pro installed using this guide.
  • You have config.plugins = [ "Pro" ] set in your config/spina.rb config.

Generate your Message object