Skip to content

Instantly share code, notes, and snippets.

View KeithP's full-sized avatar

Keith Payne KeithP

  • equidat
  • London
  • 08:30 (UTC +01:00)
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 / .ebextensions redis.config
Last active March 11, 2022 06:49
install redis on AWS EC2
packages:
yum:
gcc-c++: []
make: []
git: []
commands:
redis_script_01:
command: wget https://raw.github.com/KeithP/install-redis-amazon-linux-centos/master/redis-install-script.sh
redis_script_02:
command: chmod 777 redis-install-script.sh
@KeithP
KeithP / .ebextensions\01-increase-timeout.config
Created October 23, 2014 20:38
Increase Elastic beanstalk timeout to 30 minutes
option_settings:
- namespace: aws:elasticbeanstalk:command
option_name: Timeout
value: 1800
# This is to enable WS support. Credits: # https://gist.github.com/Bubelbub/0a942a0d51a3d329897d
# THIS WORKS! for running the example 5.0.0.beta1 chat app on a single instance Elastic beanstalk AWS instance
files:
"/etc/nginx/conf.d/websockets.conf" :
content: |
upstream backend {
server unix:///var/run/puma/my_app.sock;
}
@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
<!-- 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 / 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`
#
@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'