Skip to content

Instantly share code, notes, and snippets.

View chrismcg's full-sized avatar

Chris McGrath chrismcg

View GitHub Profile
@aaronjensen
aaronjensen / drain_stop.ex
Last active November 28, 2022 06:59
Phoenix Drain Stop
# ATTENTION: This is now supported in plug_cowboy as of 2.1.0:
# https://hexdocs.pm/plug_cowboy/Plug.Cowboy.Drainer.html
defmodule DrainStop do
@moduledoc """
DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown
occurs. It first shuts down the acceptor, ensuring that no new requests can be
made. It then waits for all pending requests to complete. If the timeout
expires before this happens, it stops waiting, allowing the supervision tree
to continue its shutdown order.
@TheBB
TheBB / loading.org
Last active June 22, 2023 11:53
Loading in Spacemacs

Emacs packages, features, files, layers, extensions, auto-loading, require, provide, use-package… All these terms getting you confused? Let’s clear up a few things.

Files

Emacs files contains code that can be evaluated. When evaluated, the functions, macros and modes defined in that file become available to the current Emacs session. Henceforth, this will be termed as loading a file.

One major problem is to ensure that all the correct files are loaded, and in the

@evanwhalen
evanwhalen / gist:f74879e0549b67eb17bb
Last active February 18, 2018 18:54
circleci-parallel-codeclimate
#!/usr/bin/env ruby
require "codeclimate-test-reporter"
branch = ENV['CIRCLE_BRANCH']
node_index = ENV['CIRCLE_NODE_INDEX'].to_i
node_total = ENV['CIRCLE_NODE_TOTAL'].to_i
artifacts_dir = ENV['CIRCLE_ARTIFACTS']
coverage_dir = File.join("..", "..", "..", ENV['CIRCLE_ARTIFACTS'], "coverage")
filename = '.resultset.json'
anonymous
anonymous / config.exs
Created June 2, 2015 00:46
config :logger, :console,
format: "time=$dateT$timeZ level=$level $metadata$message\n",
metadata: [:request_id],
utc_log: true
anonymous
anonymous / logger.ex
Created June 2, 2015 00:02
defmodule Saturn.Logger do
use Timex
require Logger
alias Plug.Conn
@behaviour Plug
def init(opts) do
Keyword.get(opts, :log, :info)
end
@rbishop
rbishop / README.md
Last active April 26, 2022 15:38
A super simple Elixir server for sending Server Sent Events to the browser.

Generate a new Elixir project using mix and add cowboy and plug as dependencies in mix.exs:

  defp deps do
    [
      {:cowboy, "~> 1.0.0"},
      {:plug, "~> 0.8.1"}
    ]
  end
@atmos
atmos / shell_output.txt
Created July 19, 2013 01:54
how to iterate quickly on gems without cutting releases.
$ rails new foo
create
create README.rdoc
...
~$ cd foo
~/foo$ git init
Initialized empty Git repository in /Users/atmos/foo/.git/
~/foo$ git add .
~/foo$ git commit -m "initial import"
[master (root-commit) c3392c9] initial import
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active March 27, 2024 06:36
A badass list of frontend development resources I collected over time.
@nihilismus
nihilismus / chruby-ruby-build-mksh.md
Last active January 30, 2017 01:30
chruby + ruby-build / mksh

chruby + ruby-build / mksh

  1. Install chruby and ruby-build with git. I keep their repo at ~/.chrb, their installation inside ~/local and my rubies at ~/.chrb/rubies.
  2. Copy this in your ~/.mkshrc file
# chruby + ruby-build
chrb() {
    source ~/local/share/chruby/chruby.sh
    unset RUBIES
    RUBIES=$(ls -d ~/.chrb/rubies/* 2> /dev/null)
@jamesgary
jamesgary / gist:5485061
Last active December 16, 2015 19:29
Testing HTTP APIs in Ruby - @shaiguitar - RailsConf 2013

Testing HTTP APIs in Ruby

@shaiguitar

  • Everything as a service
  • Test it!
  • Problem statement: Testing a server/client HTTP API
  • Good plan:
    • Create API
    • Build client lib that can be used in confusmer apps
  • Make it easy for consumer apps to test w/ our client library