Skip to content

Instantly share code, notes, and snippets.

View nicholasjhenry's full-sized avatar

Nicholas Henry nicholasjhenry

View GitHub Profile
@nicholasjhenry
nicholasjhenry / clutter-free-vscode.jsonc
Created January 3, 2024 06:39 — forked from kamilogorek/_screenshot.md
Clutter-free VS Code Setup
// Required Plugin: https://marketplace.visualstudio.com/items?itemName=drcika.apc-extension
// settings.json
{
// Remove left-side icons
"workbench.activityBar.location": "hidden",
// Remove bottom status bar
"workbench.statusBar.visible": false,
// Remove position indicator in the editor's scrollbar
"editor.hideCursorInOverviewRuler": true,
defmodule Executable do
@moduledoc """
Executables are either commands or queries.
They should declare a struct that dictates the shape and defaults of their
parameters and a `handle_execute/1` function that takes that struct and does
something in response.
"""
use Behaviour
@nicholasjhenry
nicholasjhenry / application.ex
Created May 5, 2020 19:32 — forked from gvaughn/application.ex
Cowboy 2.5 proxy, used to bind a single port (on Heroku) for umbrella Phoenix applications. It supports HTTPS and websockets properly.
defmodule MasterProxy.Application do
alias MyApp.Endpoint, as: MyAppEndpoint
alias MyApp.UserSocket, as: MyAppUserSocket
alias MyOtherApp.Endpoint, as: MyOtherAppEndpoint
alias MyOtherApp.UserSocket, as: MyOtherAppUserSocket
alias Phoenix.LiveReloader.Socket, as: LiveReloadSocket
alias Plug.Cowboy
@nicholasjhenry
nicholasjhenry / 2017-10-21-how-to-connect-and-debug-elixir-or-phoenix-app-at-heroku.md
Created October 22, 2017 12:23
How to connect and debug Elixir or Phoenix App at Heroku?

How to connect and debug Elixir or Phoenix App at Heroku?

Heroku has a great feature called heroku ps:exec which allows you to connect to running nodes. You can use this command to connect your elixir nodes easily. And debug your nodes like in your network.

Step 1

Let's start with Procfile To run a named app at heroku your procfile should specify the app name like:

web: MIX_ENV=prod elixir --sname coolelixirapp -S mix run --no-halt
@nicholasjhenry
nicholasjhenry / run.sh
Created August 24, 2017 19:20 — forked from djo/run.sh
Handling of UNIX-signals in Erlang/Elixir is not supported, this script provides start-stop management with handling TERM signal for Docker installation.
#!/usr/bin/env bash
set -x
term_handler() {
echo "Stopping the server process with PID $PID"
erl -noshell -name "term@127.0.0.1" -eval "rpc:call('app@127.0.0.1', init, stop, [])" -s init stop
echo "Stopped"
}
trap 'term_handler' TERM INT
@nicholasjhenry
nicholasjhenry / create_projection_versions.ex
Created December 28, 2016 13:19 — forked from slashdotdash/create_projection_versions.ex
Building projections with Ecto using Commanded event handlers
defmodule Projections.Repo.Migrations.CreateProjectionVersions do
use Ecto.Migration
def change do
create table(:projection_versions, primary_key: false) do
add :projection_name, :text, primary_key: true
add :last_seen_event_id, :bigint
timestamps
end
@nicholasjhenry
nicholasjhenry / example_server.ex
Last active August 24, 2017 18:47 — forked from camshaft/start.sh
elixir startup script with graceful shutdown
defmodule Example.Server do
use GenServer
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, :ok, opts)
end
def init(state) do
Process.flag(:trap_exit, true) # must trap exit for terminate call back to work
IO.inspect "Starting server..."

Requirements

  • Docker Machine + Docker
  • curl
  • A Virtualbox-driven Docker Machine called "default" docker-machine create --driver virtualbox default (this is the default with Docker toolkit).

Usage

The git.io URL (http://git.io/vsk46) is a shortened form of the raw url of the plist.

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

@nicholasjhenry
nicholasjhenry / 0_reuse_code.js
Created January 15, 2014 21:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console