Skip to content

Instantly share code, notes, and snippets.

View clowder's full-sized avatar

Chris Lowder clowder

  • London
View GitHub Profile
@clowder
clowder / .sqlfluff
Created March 2, 2022 16:49
SQLFluff Config
[sqlfluff]
dialect = postgres
templater = raw
[sqlfluff:rules]
tab_space_size = 2
max_line_length = 100
[sqlfluff:rules:L010]
# Keywords
@clowder
clowder / keybase.md
Created October 19, 2021 14:08
keybase.md

Keybase proof

I hereby claim:

  • I am clowder on github.
  • I am therealclowder (https://keybase.io/therealclowder) on keybase.
  • I have a public key whose fingerprint is 801C A02A E768 FCAD 5621 3C5A CF62 2202 E67E 2FC4

To claim this, I am signing this object:

layout title description tags
default
SQL Style Guide
A guide to writing clean, clear, and consistent SQL.
data
process

Purpose

diff --git a/db/seeds.rb b/db/seeds.rb
index 127561c..2ec12b2 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -653,6 +653,12 @@ if activities.options.blank?
])
end
+likert_0 = LikertOption.find_or_create_by(value: 0)
+likert_1 = LikertOption.find_or_create_by(value: 1)
@clowder
clowder / hander.rb
Created December 14, 2016 21:16
A markdown ActionView::Template hander for Rails, that supports string interpolation
require 'redcarpet'
module Handlers
module Markdown
class HTMLWithPants < Redcarpet::Render::HTML
include Redcarpet::Render::SmartyPants
end
def self.call(template)
escaped_source = template.source.gsub('"', '\"')
@clowder
clowder / spaces_controller.rb
Created July 16, 2015 11:03
Admin preview user content
class Admin::SpacesController < AdminController
def preview
space = Space.find(params[:id])
prepend_view_path 'app/views/spaces' # Ensures our `:template` is found.
lookup_context.prefixes = ['spaces', 'application'] # Ensures that our templates partials are pulled from the right places.
render template: 'show', layout: 'application', locals: { space: space }
end
end
@clowder
clowder / unsolicited.fu
Last active September 9, 2020 09:53
List of domains that send recruiter spam
armakuni.ext.careers
arrowsgroup.com
bridgenoble.com
colstonconsulting.co.uk
dawsonhill.co.uk
esynergy-solutions.co.uk
exploreltd.com
frasermarsh.com
hydrogengroup.com
initi8recruitment.com
@clowder
clowder / application_helper.rb
Created September 11, 2013 13:11
CSS Hack: Force vertical center.
module ApplicationHelper
def force_vertical_center(opts={})
raise ArgumentError, "Missing block" unless block_given?
capture_haml do
haml_tag '.vertical-center', opts do
haml_tag '.inner', &Proc.new
end
end
end
@clowder
clowder / uuid_primary_key.rb
Created August 6, 2013 10:35
Postgres UUID primary keys for your Rails 3 apps.
class UuidPrimaryKey < ActiveRecord::Migration
def up
execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
create_table :your_table, :id => false do |t|
# etc...
t.timestamps
end
execute 'ALTER TABLE your_table ADD COLUMN id uuid DEFAULT uuid_generate_v4() PRIMARY KEY;'
@clowder
clowder / child.rb
Last active December 15, 2015 18:08
Polymorphic routes
class Child < ActiveRecord::Base
belongs_to :parent
has_many :leaves, :as => :branch
def route_parts
[parent, self]
end
end