Skip to content

Instantly share code, notes, and snippets.

View emilford's full-sized avatar

Eric Milford emilford

View GitHub Profile
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@eebs
eebs / sql_statement_profiling.rb
Created December 17, 2019 21:29
spec/support/sql_statement_profiling.rb
RSpec.configure do |config|
example_sql_counts = Hash.new(0)
config.around(:example) do |procsy|
sql_count = 0
callback = ->(*args) { sql_count +=1 }
ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do
procsy.call
end
@erdostom
erdostom / Dockerfile
Last active November 25, 2022 14:53
Good starter Dockerfile + docker-compose.yml for Rails 6.
FROM ruby:2.6.5-alpine
RUN apk add --update --no-cache bash build-base nodejs sqlite-dev tzdata postgresql-dev yarn
RUN gem install bundler:2.1.4
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn install --check-files
@romainl
romainl / grep.md
Last active July 1, 2024 13:53
Instant grep + quickfix

FOREWORDS

I don't mean the snippet at the bottom of this gist to be a generic plug-n-play solution to your search needs. It is very likely to not work for you or even break things, and it certainly is not as extensively tested and genericised as your regular third-party plugin.

My goal, here and in most of my posts, is to show how Vim's features can be leveraged to build your own high-level, low-maintenance, workflows without systematically jumping on the plugins bandwagon or twisting Vim's arm.


Instant grep + quickfix

@mattslack
mattslack / pre-commit
Last active March 10, 2020 19:38
git hooks
#!/bin/bash
# Built off of Standard JS's pre-commit example: https://standardjs.com/#is-there-a-git-pre-commit-hook
# Ensure all files staged for commit pass standard code style
function xargs-r() {
# Portable version of "xargs -r". The -r flag is a GNU extension that
# prevents xargs from running if there are no input files
if IFS= read -r -d $'\n' path; then
{ echo "$path"; cat; } | xargs $@
@bazzel
bazzel / README.md
Last active July 27, 2024 16:48
Webpacker and I18n
$ rails new my-i8n --webpack

Gemfile

gem 'i18n-js'
@romainl
romainl / tags.md
Last active March 25, 2022 07:00
Tags

Tags

Setup

Tell Vim to look for tags files:

  • in the directory of the current file,
  • in the working directory,
  • and in every parent directory, recursively,
@romainl
romainl / macros.md
Last active May 15, 2023 07:33
What to do with macros?

What to do with macros?

"Macro", you say? Or is that "recording"?

What people refer to as a "macro" is often actually a "recording".

You press qa to start recording your commands into register a, you do your thing, you stop your recording with q, and you play that recording back with @a.

Yes, what you just recorded is a macro, but macros are not necessarily recorded or even stored in registers.

@keithpitt
keithpitt / database_state_loader.rb
Last active June 10, 2022 16:32
Note that this code only works with PostgreSQL, but it wouldn’t be too hard to adapt our approach for other relational databases.
# Add to `spec/support/database_state_loader.rb`
class DatabaseStateLoader
class EnvironmentError < RuntimeError; end
def self.load(path)
new(path).load
end
def initialize(path)