Skip to content

Instantly share code, notes, and snippets.

View robvitaro's full-sized avatar

Rob Vitaro robvitaro

  • Lehigh Valley, PA
View GitHub Profile
@robvitaro
robvitaro / active_storage_bug.rb
Last active September 3, 2020 13:43
A bug I discovered with duplicating ActiveStorage records and the .attached? method. Rails issue: https://github.com/rails/rails/issues/40166
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
@robvitaro
robvitaro / transformer.xslt
Created February 17, 2020 19:28
Flatten an XML file to "full-xpath,value" csv file
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*[@* or not(*)] ">
<xsl:if test="not(*)">
<xsl:apply-templates select="ancestor-or-self::*" mode="path"/>
<xsl:value-of select="concat(',',.)"/>
<xsl:text>&#xA;</xsl:text>
</xsl:if>
@robvitaro
robvitaro / keybase.md
Last active July 16, 2019 21:02
keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@robvitaro
robvitaro / delegate_matcher.rb
Last active December 17, 2016 08:45 — forked from bparanj/delegate_matcher.rb
RSpec matcher for delegations
# RSpec matcher to spec delegations.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:month).to(:created_at) }
# it { should delegate(:year).to(:created_at) }
# end