Skip to content

Instantly share code, notes, and snippets.

View gavinhughes's full-sized avatar

Gavin Hughes gavinhughes

View GitHub Profile
@gavinhughes
gavinhughes / crash.txt
Created August 21, 2020 15:10
Emacs crash report
This file has been truncated, but you can view the full file.
Date/Time: 2020-08-21 11:07:59 -0400
End time: 2020-08-21 11:08:26 -0400
OS Version: Mac OS X 10.15.5 (Build 19F101)
Architecture: x86_64h
Report Version: 29
Data Source: Stackshots
Shared Cache: 0x26e8000 2CDD2B20-3DA2-39B1-9801-CE90D65CC62D
Command: Emacs
@gavinhughes
gavinhughes / readme.org
Last active August 31, 2018 18:51
Ledger Recur - Automated entry of recurring transactions into ledger files

Ledger Recur

Ledger Recur provides automated entry of recurring transactions into ledger files.

The command `recur journal.ledger recurring.rcr` enters all recurring transactions specified in the file `recurring.rcr` into the file `journal.ledger`.

A recur file is parsed before transactions are entered into a ledger file. If erorrs are found, they are reported and no transactions are entered.

Recur file syntax

@gavinhughes
gavinhughes / gist:4552586
Created January 17, 2013 01:00
Gemfile for VCR FiberError debugging
source 'https://rubygems.org'
#
# Hack: Workaround1: http://railsapps.github.com/openssl-certificate-verify-failed.html
# source 'http://rubygems.org'
gem 'rails', '3.2.9'
gem 'bcrypt-ruby', require: 'bcrypt'
gem 'pg'
# Add support for pg data types. Not needed >= Rails 4.0
@gavinhughes
gavinhughes / db_disconnect.rake
Created September 25, 2012 10:56
Rake task to disconnect postgres db
namespace :db do
desc "Drop postgresql db connections"
task :disconnect => :environment do
begin
ActiveRecord::Base.connection.select_all("select * from pg_stat_activity order by procpid;").each do |x|
ActiveRecord::Base.connection.execute("select pg_terminate_backend(#{x['procpid']})")
end
rescue
end
puts "DB sessions disconnected."
@gavinhughes
gavinhughes / Edit email.html.erb
Created January 8, 2012 21:45
Devise Issue #1553
<-- registrations/email/edit.html.erb -->
<h2>Change Email</h2>
<%= form_for(resource, :as => resource_name, :url => { registrations_email_path(resource) }, :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<div><p><strong>Current email:</strong></p>
<p><%= resource.email %></p></div>
[1] pry(#<ProfilesController>)> @user = current_user.dup
=> #<Sponsor _id: 4f065814421aa90df800001a, _type: "Sponsor", created_at: 2012-01-06 02:02:01 UTC, updated_at: 2012-01-06 02:03:25 UTC, email: "gavin@gavin.com", encrypted_password: "$2a$10$/ondEoQsfgQ2yzMCW8qasOTLdqJTszzHLH6Ice6wOwTV7yTJuncUe", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: 2012-01-06 02:02:15 UTC, last_sign_in_at: 2012-01-06 02:02:15 UTC, current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", confirmation_token: nil, confirmed_at: 2012-01-06 02:02:08 UTC, confirmation_sent_at: 2012-01-06 02:02:01 UTC, unconfirmed_email: nil, first_name: nil, last_name: nil, nickname: "Gavin", gender: nil, birthdate: 2002-02-02 00:00:00 UTC, preferred_relationship_types: [""], statement: "", first_specified_birthdate: 2002-02-02 00:00:00 UTC>
[2] pry(#<ProfilesController>)> current_user.reload
=> #<Sponsor _id: 4f065619421aa90df8000011, _type: "Sponsor", created_at: 2012-0
@gavinhughes
gavinhughes / gist:1323987
Created October 29, 2011 01:57
Cucumber web steps
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require 'uri'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
@gavinhughes
gavinhughes / rails31init.md
Created October 28, 2011 07:58 — forked from docwhat/rails31init.md
Rails 3.1 with Rspec, Factory Girl, Haml, Simple Form, Database Cleaner, Spork, and Guard

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@gavinhughes
gavinhughes / Slugify
Created July 9, 2011 01:18
Convert string to underscored slug
module Slugify
def slugify(string)
# Strip the string
ret = string.strip
# Blow away apostrophes
ret.gsub! /['`]/,""
@gavinhughes
gavinhughes / Conversation
Created November 23, 2010 11:59
Conversation: concept for a internal messaging gem
= conversation
Conversation is a Ruby gem that gives your Rails 3 application messaging and commenting features.
Messages and comments can be configured to be either threaded or unthreaded. Any number of models
can be messageable, commentable, or both. You make a model messageable like this
class User < ActiveRecord::Base
messageable
end