Skip to content

Instantly share code, notes, and snippets.


Lachlan Priest lcpriest

  • Singapore, Singapore
View GitHub Profile
View git-auto-rebase
# git-auto-rebase
# git-auto-rebase --force-push
function git-auto-rebase() {
if [[ $@ = "--force-push" ]]
lcpriest / missing_tests.rake
Created May 16, 2018
Generate missing test files in a rails app
View missing_tests.rake
namespace :missing_tests do
def progress(name, x, y)
print "\r #{name}: #{x}/#{y} %6.2f%%" % [x.to_f / y * 100]
def generate_files(name)
kind = name.to_s.singularize
collection = Dir.glob Rails.root.join('app', name.to_s, '**', '*').to_s
root = Rails.root.join('app', name.to_s).to_s << '/'
ext = case name
lcpriest /
Last active Nov 1, 2018
EmberJS dynamic query params

I was attempting to generate a list of links and found that some of them needed query params and others didn't. I could not find a recommended way to pass in a dynamic query-params object to the link-to helper. I ended up finding a solution in the Ember Discourse and decided to make it into an ember helper.


import Ember from 'ember';

export function dynamicParams([routeName, params]/*, hash*/) {
 return [
lcpriest / gist:c6448bb81d2193ffaafa64f8f5779b87
Last active Jul 24, 2017
Keyboard shortcuts for sublime
View gist:c6448bb81d2193ffaafa64f8f5779b87

cmd + option + (1,2,3,4,5) for split sublime into panes

cmd + shift + p to open sublime command palette

cmd + c with nothing selected in sublime copies the entire line for pasting

cmd + x with nothing selected in sublime cuts the entire line for pasting

ctrl + cmd + (up,down) to move entire line up or down

lcpriest / template.json
Created Mar 22, 2017
Elasticsearch mapping with dynamic templates for customer attributes
View template.json
"template": "account-*",
"settings": {
"analysis": {
"analyzer": {
"default": {
"tokenizer": "keyword",
"filter": "lowercase"
View elasticsearch.rb
client = 'test', type: 'contacts', body: body)
body = { query: { bool: { filter: { term: { name: 'lachlan' } } } } }
lcpriest /
Last active Jun 2, 2016
Common questions in Ruby + Ember
View gist:4f329d51fafbbfc167dd

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

lcpriest / index.js.erb
Created Oct 15, 2013
Simple implementation of autoscroll with will_paginate
View index.js.erb
$('#collection').append("<%= j render partial: 'partial', collection: @collection %>");
<% if @collection.next_page %>
$('.pagination').replaceWith('<%= j will_paginate(@collection) %>');
<% else %>
<% end %>