Skip to content

Instantly share code, notes, and snippets.

Avatar

James Harker JamesHarker

View GitHub Profile
@JamesHarker
JamesHarker / emojione-area.js
Created Mar 17, 2020
Emoji Picker Plugin for jQuery
View emojione-area.js
/*!
* EmojioneArea v3.4.1
* https://github.com/mervick/emojionearea
* Copyright Andrey Izman and other contributors
* Released under the MIT license
* Date: 2018-04-27T09:03Z
*/
window = ( typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {} );
document = window.document || {};
@JamesHarker
JamesHarker / Context.js
Created Mar 17, 2020
Javascript context menu
View Context.js
/*
* Context.js
* Copyright Jacob Kelley
* MIT License
*
*/
contextMenu = (function () {
var options = {
@JamesHarker
JamesHarker / colpik.js
Created Mar 17, 2020
colpick Color Picker
View colpik.js
/*
colpick Color Picker
Copyright 2013 Jose Vargas. Licensed under GPL license. Based on Stefan Petre's Color Picker www.eyecon.ro, dual licensed under the MIT and GPL licenses
For usage and examples: colpick.com/plugin
*/
(function ($) {
var colpick = function () {
@JamesHarker
JamesHarker / webhook-signature.rb
Last active Aug 29, 2015
Check a Dentally Webhook Signature
View webhook-signature.rb
# request_signature - the signature from the X-Dentally-Signature header
# request_body - the JSON body of the webhook request
# secret - the secret for the webhook
require "openssl"
digest = OpenSSL::Digest.new("sha256")
calculated_signature = OpenSSL::HMAC.hexdigest(digest, secret, request_body)
if calculated_signature == request_signature
@JamesHarker
JamesHarker / Ethnicity-codes.md
Created Sep 11, 2014
A list of ethnicity codes used in Dentally
View Ethnicity-codes.md
Code Description
01 White British
02 White Irish
03 White Other
04 White and Black Caribbean
05 White and Black African
06 White and Asian
07 Other Mixed Background
08 Asian or Asian British Indian
@JamesHarker
JamesHarker / timeslots.sql
Created May 2, 2014
Calculate Resource Availability by Time Period in Postgres
View timeslots.sql
CREATE TABLE reservations (
start_time timestamp not null,
finish_time timestamp not null,
id serial primary key
);
INSERT INTO reservations (start_time, finish_time)
VALUES ('2014-05-01 09:30:00', '2014-05-01 10:00:00'),
('2014-05-01 10:15:00', '2014-05-01 11:00:00'),
('2014-05-01 11:30:00', '2014-05-01 11:45:00');
@JamesHarker
JamesHarker / sidekiq.rb
Created May 1, 2014
Sidekiq initalizer
View sidekiq.rb
Sidekiq.configure_server do |config|
if defined?(ActiveRecord::Base)
config = ActiveRecord::Base.configurations[Rails.env]
config["reaping_frequency"] = ENV["DB_REAP_FREQ"] || 10 # seconds
config["pool"] = ENV["SIDEKIQ_DB_POOL"] || 20
ActiveRecord::Base.establish_connection(config)
end
end
@JamesHarker
JamesHarker / Rakefile
Created Feb 15, 2014
Using Postgres Schemas with Rails
View Rakefile
tasks = Rake.application.instance_variable_get '@tasks'
tasks.delete 'db:structure:dump'
namespace 'db' do
namespace 'structure' do
task :dump => [:environment, :load_config] do
configuration = ActiveRecord::Tasks::DatabaseTasks.current_config
filename = ENV['DB_STRUCTURE'] || File.join(Rails.root, "db", "structure.sql")
ENV['PGHOST'] = configuration['host'] if configuration['host']
ENV['PGPORT'] = configuration['port'].to_s if configuration['port']
ENV['PGPASSWORD'] = configuration['password'].to_s if configuration['password']
@JamesHarker
JamesHarker / gist:6697403
Created Sep 25, 2013
CircleCI tweaks for Postgres 9.3
View gist:6697403
sudo -u postgres sed "$id s/$5433/$5432/" -i /etc/postgresql/9.3/main/postgresql.conf
sudo -u postgres /etc/init.d/postgresql restart
sudo -u postgres createuser ubuntu -s
sudo -u postgres createdb circle_test -O ubuntu
View gist:5483481

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60