Skip to content

Instantly share code, notes, and snippets.

View KeithP's full-sized avatar

Keith Payne KeithP

  • equidat
  • London
  • 06:40 (UTC)
View GitHub Profile
@KeithP
KeithP / markdown_template_handler.rb
Created November 6, 2023 10:58
MarkdownTemplateHandler fixed for Rails 7.1
# config/initializers/markdown_template_handler.rb
module MarkdownTemplateHandler
def self.call( template, source=nil )
source ||= template.source
# This worked prior to Rails 7.1:
# compiled_source = erb.call( template, source )
# But with Rails 7.1 it threw "ActionView::Template::Error: wrong argument type ActionView::OutputBuffer (expected String)"
@KeithP
KeithP / Carrd.co: add a Twitter Intent icon using Embed Control in the footer
Last active August 21, 2020 16:17
How to add a twitter card and intent to Carrd.co
@KeithP
KeithP / phone_breadcrumbs_builder.rb
Last active July 19, 2018 10:37
Make use of your Breadcrumbs in your phone-specific views, to give a simple page title and navigation up 1 in the Breadcrumb stack. You have already configured every page with Breadcrumbs, so use them in your phone view header.
# lib/phone_breadcrumbs_builder.rb
# inspired by https://gist.githubusercontent.com/marlosirapuan/3ceb02972400ea98ac5c8f419a61806b/raw/d994dc2d6b35702b4a66e2d1a01a9e9956883375/bulma_breadcrumbs_builder.rb
#
# Make use of your Breadcrumbs in your phone-specific views, to give a simple page title and navigation up 1
# in the Breadcrumb stack. You have already configured every page with Breadcrumbs, so use them in your phone view header.
#
# Example render in your phone view header:
#
# `<a href="/"><i class="fa fa-chevron-left"></i></a> This Page Title`
#
<!-- START-->
<hr>
<h3>Current planning applications:</h3>
<p><code><var><cite>Larger schemes currently awaiting planning decisions (updated weekly)</cite></var></code></p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json2html/1.2.0/json2html.min.js"></script><script>
function convertDate(inputFormat) {
function pad(s) { return (s < 10) ? '0' + s : s; }
var d = new Date(inputFormat);
return [pad(d.getDate()), pad(d.getMonth()+1), d.getFullYear()].join('/');
}
@KeithP
KeithP / privacy_notice.html.md
Last active April 8, 2018 22:00
Privacy Noitice - for Simple GDPR Compliance

DATA PRIVACY NOTICE

Thank you for using MyWebApp.com. This notice is to help you understand what information we collect, how we use it and what choices you have about it.

1. How we collect information:

a) When you give it to us or give us permission to obtain it

@KeithP
KeithP / init.coffee
Created April 6, 2018 13:32
How to initialise https://cookieconsent.insites.com with "Disabling cookies" code
window.App ||= {}
App.init = ->
window.cookieconsent.initialise
"palette":
"popup":
"background": "#252e39"
,
"button":
"background": "#14a7d0"
Failures:
1) Users::PasswordsController POST 'update' success should change the password
Failure/Error: @cond.wait(@monitor.instance_variable_get(:@mon_mutex), timeout)
fatal:
No live threads left. Deadlock?
# /home/keithp/.rvm/gems/ruby-2.3.0@my_app/bundler/gems/rails-5de1e4f2c45e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `block in lock_thread='
# /home/keithp/.rvm/gems/ruby-2.3.0@my_app/bundler/gems/rails-5de1e4f2c45e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:368:in `lock_thread='
# /home/keithp/.rvm/gems/ruby-2.3.0@my_app/bundler/gems/rails-5de1e4f2c45e/activerecord/lib/active_record/fixtures.rb:1012:in `block in teardown_fixtures'
1) Admins::DataLoadsController as an admin user POST create with valid params assigns a newly created data_load as @data_load
Failure/Error: @mon_mutex.lock
fatal:
No live threads left. Deadlock?
# /home/rof/cache/bundler/ruby/2.2.0/bundler/gems/rails-e8af65a46325/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:86:in `clear_query_cache'
# /home/rof/cache/bundler/ruby/2.2.0/bundler/gems/rails-e8af65a46325/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `disable_query_cache!'
# /home/rof/cache/bundler/ruby/2.2.0/bundler/gems/rails-e8af65a46325/activesupport/lib/active_support/callbacks.rb:413:in `block in make_lambda'
# /home/rof/cache/bundler/ruby/2.2.0/bundler/gems/rails-e8af65a46325/activesupport/lib/active_support/callbacks.rb:270:in `call'
# /home/rof/cache/bundler/ruby/2.2.0/bundler/gems/rails-e8af65a46325/activesupport/lib/active_support/callbacks.rb:270:in `block in simple'
1) Manage::NotificationSubscription
Failure/Error: it { is_expected.to respond_to :user }
ActiveRecord::StatementInvalid:
PG::UndefinedTable: ERROR: invalid reference to FROM-clause entry for table "i"
LINE 2: CROSS JOIN generate_subscripts(i.indkey, 1) k
^
HINT: There is an entry for table "i", but it cannot be referenced from this part of the query.
: SELECT a.attname FROM pg_index i
CROSS JOIN generate_subscripts(i.indkey, 1) k
32) Pages signed in should display the 'root_path'
Failure/Error: @user = create(:user)
ActiveRecord::StatementInvalid:
PG::UndefinedTable: ERROR: invalid reference to FROM-clause entry for table "i"
LINE 2: CROSS JOIN generate_subscripts(i.indkey, 1) k
^
HINT: There is an entry for table "i", but it cannot be referenced from this part of the query.
: SELECT a.attname FROM pg_index i
CROSS JOIN generate_subscripts(i.indkey, 1) k