Skip to content

Instantly share code, notes, and snippets.

@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

require 'rspec'
require 'set'
class Traverser
attr_reader :elements, :satisfied
def initialize(elements, satisfied:)
@elements = elements
@satisfied = satisfied
end
# Given an ordered list of elements, how can the possible combinations
# of those elements (of all lengths, order does not matter, no
# repetition) be traversed in the sequence shown below? Either
# iterative or recursive, but it needs to be in such a way that the
# computation of certain branches can be skipped based on a condition
# computed from the combination. E.g. when it reaches [:a, :b], it
# should be possible to say: if check?([:a, :b]) then skip everything
# until [:a, :b, :d] and continue with [:a, :c].
#
# In the concrete problem behind this, the list of elements is a lot
@mblarsen
mblarsen / deploy.yaml
Last active July 24, 2022 13:27
Solution for `git clone` using Ansible for repos with private submodules with github deploy keys
# Problem:
#
# If you use git submodules linking two private github repos, you'll need to create a separate deploy key for each.
# Multiple keys are not supported by Ansible, nor does ansible (when running git module) resort to your `.ssh/config` file.
# This means your ansible playbook will hang in this case.
#
# You can however use the ansible git module to checkout your repo in multiple steps, like this:
#
- hosts: webserver
vars:
@Envek
Envek / pg_interval_support_4_1.rb
Last active December 18, 2023 14:41
Enables PostgreSQL interval datatype support (as ActiveSupport::Duration) in Ruby on Rails from 4.1 to 6.0
# Enables PostgreSQL interval datatype support (as ActiveSupport::Duration) in Ruby on Rails 4.1.
# Based on https://gist.github.com/clarkdave/6529610
require 'active_support/duration'
# add a native DB type of :interval
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:interval] = { name: 'interval' }
# add the interval type to the simplified_type list. because this method is a case statement
# we can't inject anything into it, so we create an alias around it so calls to it will call
@jdickey
jdickey / Simplest possible(?) non-ActiveRecord usage of ActiveModel::SecurePassword#has_secure_password.md
Created August 10, 2015 14:58
Simplest possible(?) non-ActiveRecord usage of ActiveModel::SecurePassword.has_secure_password

Here's what I've (re)learned after a few hours poking at Sequel and ActiveModel::SecurePassword.has_secure_password

It's Even Simpler than I Remember It

In olden times (pre-AM 4.3?) I seem to recall that there were more than one ActiveModel module that needed to be included in a non-ActiveRecord::Base subclass to get it to meet requirements for has_secure_password. That has now been reduced to one (meta-)module.

For example, see the below user.rb file. All you need is include ActiveModel::SecurePassword, apparently.