Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric Goodwin ericgoodwin

View GitHub Profile
@ericgoodwin
ericgoodwin / api_only_rails_example.rb
Created Dec 4, 2020 — forked from JoshCheek/api_only_rails_example.rb
How to configure API only Rails (esp how to deal with param parsing).
View api_only_rails_example.rb
# I submitted a bug report https://github.com/rails/rails/issues/34244
# b/c Rails was not honouring my `rescue_from` block which was causing my API to
# be inconsistent. I was told this is expected behaviour. I think it's probably
# fine for an HTML app where you control the form inputs. But for an API app,
# the API is public facing and very important, so Rails shouldn't have its own
# special errors that bypass my app's configuration and make my API inconsistent.
#
# Decided it shouldn't be too difficult to handle this myself. So, here is my
# solution. It contains most of the important lessons I've learned about how to
# get a Rails API app setup. It removes Rails' params parsing and adds its own.
@ericgoodwin
ericgoodwin / plug.conn.ex
Created Apr 14, 2020 — forked from jamonholmgren/plug.conn.ex
Typical Elixir Phoenix Plug.Conn struct contents, in an easy-to-read format. By Jamon Holmgren.
View plug.conn.ex
%Plug.Conn{
adapter: {Plug.Adapters.Cowboy.Conn, :...},
assigns: %{
my_assigns: "here"
},
before_send: [
#Function<7.125546534/1 in Phoenix.Controller.fetch_flash/2>,
#Function<1.127904613/1 in Plug.Session.before_send/2>,
#Function<1.43511252/1 in Plug.Logger.call/2>,
#Function<0.70322810/1 in Phoenix.LiveReloader.before_send_inject_reloader/1>
@ericgoodwin
ericgoodwin / rabbitmq.rb
Created Aug 2, 2019
RabbitMQ Version 3.7.16 Homebrew Install
View rabbitmq.rb
class Rabbitmq < Formula
desc "Messaging broker"
homepage "https://www.rabbitmq.com"
url "https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.16/rabbitmq-server-generic-unix-3.7.16.tar.xz"
sha256 "a34011f8ff1682a1601d4b8e0167ad39b91fd8f0fb35b484c41efde9f104ed08"
bottle :unneeded
depends_on "erlang"
@ericgoodwin
ericgoodwin / postgres-import-export-csv.md
Created May 23, 2019 — forked from nepsilon/postgres-import-export-csv.md
Importing and Exporting CSV files with PostgreSQL — First published in fullweb.io issue #19
View postgres-import-export-csv.md

Importing and exporting CSV files with PostgreSQL

Let’s see how to use PostgreSQL to import and export CSV files painlessly with the COPY command.

Import CSV into table t_words:

COPY t_words FROM '/path/to/file.csv' DELIMITER ',' CSV;

You can tell quote char with QUOTE and change delimiter with DELIMITER.

View keybase.md

Keybase proof

I hereby claim:

  • I am ericgoodwin on github.
  • I am goodwin (https://keybase.io/goodwin) on keybase.
  • I have a public key ASCU1RIneT2ncBlQIHVeGCYOUY647ekmq1WqJ5v99whbXQo

To claim this, I am signing this object:

View gist:129e16d7cde20d4424030cfe8ab96033
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Railscasts Extended/Railscasts Extended.tmTheme",
"draw_white_space": "selection",
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
"...",
View yardoc_cheatsheet.md

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

# Namespace for classes and modules that handle serving documentation over HTTP
View config-initializers-elasticsearch.rb
# Use a prefix for the index names that Tire uses so that the test suite doesn't
# stomp on dev data and you can work on multiple apps with ES, but keep tidy
# unadorned names for production.
unless Rails.env.production?
Tire::Model::Search.index_prefix("#{Rails.application.class.parent_name.downcase}_#{Rails.env}")
end