Skip to content

Instantly share code, notes, and snippets.

View wrs's full-sized avatar

Walter Smith wrs

View GitHub Profile
@wrs
wrs / hamlcdata.rb
Created July 5, 2010 21:32
Haml+CDATA filter for Haml
# Generates HAML surrounded by CDATA tags.
# Useful for JavaScript templates (e.g., jquery.mustache or jQote).
#
# Example:
# %script#foo_tmpl(type="text/x-mustache")
# :hamlcdata
# %p This is HAML enclosed in CDATA.
# %p You can use it for templating {{stuff}}.
# =>
# <script id='foo_tmpl' type='text/x-mustache'>
@wrs
wrs / app_config.rb
Created July 5, 2010 21:54
Simple Rails app configuration class
# Simple configuration system
#
# The configuration is represented as a tree of keys. Examples:
#
# AppConfig['key']
# AppConfig['key','subkey']
# AppConfig['key.subkey']
#
# An optional default value can be specified:
#
@wrs
wrs / DeviseJsonAdapter.rb
Created December 8, 2010 18:02
JSON-encoded error and redirect results for Devise controllers
# JSON-encoded error and redirect results for Devise controllers.
# This overrides an internal method of Devise, so be careful when updating Devise!
#
# Usage:
#
# class Users::RegistrationsController < Devise::RegistrationsController
# include DeviseJsonAdapter
# end
#
# devise_for :users, :controllers => { :registrations => "users/registrations" }
@wrs
wrs / capybara-firebug.rb
Created February 14, 2011 01:00
Install Firebug for Capybara
# UPDATE: You are probably better off using jfirebaugh's gem.
# See https://github.com/jfirebaugh/capybara-firebug
# Set up Capybara to install Firebug in the default session.
#
# Download firebug.xpi from http://getfirebug.com/downloads and check it in.
# Set FirebugFix::ORIGINAL_XPI_PATH to its location.
require 'selenium/webdriver'
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Sip>sip:7101@sip-dev.czops.net</Sip>
</Dial>
</Response>
<Response>
<Dial>
<User>sip:12067079127@prod-pbx-pub.czops.net:5080</User>
</Dial>
</Response>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say></Say>
<Pause length="2"/>
<Say>
Thank you for calling care zone. If this is a medical emergency, hang up and call 9 1 1.
Our phone system is down temporarily for maintenance. Please try again in a few minutes.
We are sorry for the inconvenience.
</Say>
<Hangup/>
@wrs
wrs / centriq-export.sh
Created January 16, 2026 23:54
Centriq export script
#!/usr/bin/env node
// Centriq (mycentriq.com) home inventory app will shut down on 1/31/26.
// This script exports data in a readable format so it can be moved to a
// different system. It writes a folder hierarchy containing data and photos
// per room.
//
// Written by Claude Code -- no warranty implied (Worked for me, though.)
/**
@wrs
wrs / README.md
Created March 13, 2026 22:19
jj: rebase branch containing conflicts in renamed files

jj-rebase-rename

Automates rebasing a jj branch when files have been renamed on the target. Based on the technique described in Rebasing Renamed Files with jj.

The problem

When you rebase a branch that modifies files at path A onto a commit where those files were moved to path B, jj produces whole-file conflicts instead of meaningful diffs. This makes the conflicts much harder to resolve than they need to be.

How it works

https://www.youtube.com/watch?v=tlQ7EoJDTQY
Hello, internet. I am making one of those videos where you sit in a chair and
directly address the camera about a serious subject. I know it's not in my
wheelhouse, and there are people who do this way better. And in fact, that's the
reason I'm making this video is that something happened last week that I really
wanted to see people make this kind of video about, and nobody did. So, I'm
hoping that I can generate some attention for it and some interest in this topic
so that people will cover it.