Skip to content

Instantly share code, notes, and snippets.

View dvanderbeek's full-sized avatar

David Van Der Beek dvanderbeek

  • San Francisco, CA
View GitHub Profile
@dvanderbeek
dvanderbeek / sortable_lists.rb
Last active April 10, 2019 15:17
Rails sortable lists with jquery ui
# Make sure to add :position to permitted params in questions controller
# Sortable items need data-update-url and data-param-key attributes
# coffeescript
$(document).on 'turbolinks:load', ->
$('.sortable').sortable
axis: 'y'
handle: '.handle'
update: (e, ui) ->
defmodule FreecomWeb.Router do
use FreecomWeb, :router
pipeline :api do
plug :accepts, ["json"]
end
scope "/", FreecomWeb do
pipe_through :api
$ mix phx.gen.context Chat Customer customers name:string
$ mix phx.gen.context Chat Agent agents image_url:string slack_user_id:string slack_user_name:string
$ mix phx.gen.context Chat Conversation conversations agent_id:references:agents customer_id:references:customers slack_channel_index:integer
$ mix phx.gen.context Chat Message messages agent_id:references:agents conversation_id:references:conversations text:string
$ mix ecto.migrate
$ mix phx.new freecom --no-brunch --no-html
$ cd freecom
$ mix deps.get
$ mix ecto.setup
@dvanderbeek
dvanderbeek / mix.exs
Last active December 11, 2017 16:30
absinthe-dependencies
{:absinthe, "~> 1.4.0"},
{:absinthe_phoenix, "~> 1.4.0"},
{:absinthe_plug, git: "https://github.com/absinthe-graphql/absinthe_plug.git", ref: "c2bcef26360f9b31f122e25ac0cbfdd1b76455f7", override: true}

Keybase proof

I hereby claim:

  • I am dvanderbeek on github.
  • I am dvanderbeek (https://keybase.io/dvanderbeek) on keybase.
  • I have a public key ASDILtUF5bnkIyjlJ0n67XvBVG2z9ir96mD3qVPs1xIJtAo

To claim this, I am signing this object:

begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
@dvanderbeek
dvanderbeek / hexagonal_example.rb
Last active December 22, 2015 17:40
An example of the "Hexagonal Rails" concept from Matt Wynne
# Tell, Don't Ask.
# Easily plug in new listeners that respond to the API we have defined:
# create_succeeded, create_failed
# Benefits:
# * Clean controller
# * Small classes with single responsibilities
# * Easy to test each individually
# * No need for model-level callbacks, just plug in the relevant listeners
# * No if statements - easy to follow logic
@dvanderbeek
dvanderbeek / gist:2c22828b98a755ecf789
Created August 16, 2014 13:21
NEW - Devise Request Spec Setup
# in spec_helper.rb
include Warden::Test::Helpers
Warden.test_mode!
# in a request spec
user = FactoryGirl.create(:user)
login_as(user, :scope => :user)