Skip to content

Instantly share code, notes, and snippets.

# Rest of file skipped!
release :myapp do
set config_providers: [
{EnvironmentConfigProvider, %{env_var_name: "SERVICE_ENVIRONMENT", persist: [:myapp, :service_environment]}}
]
end
@jfornoff
jfornoff / environment_config_provider.ex
Last active April 18, 2019 11:53
Distillery config provider
defmodule EnvironmentConfigProvider do
use Mix.Releases.Config.Provider
@impl Provider
def init(%{env_var_name: var_name, persist: [app, config_variable]}) do
value = System.get_env(var_name) || raise "No value provided for ENV variable #{var_name}"
Application.put_env(app, config_variable, value, persistent: true)
end
end
@jfornoff
jfornoff / config.exs
Last active January 20, 2019 17:21
Naive dynamic config loading
use Mix.Config
# This does not always work!
config :myapp, service_environment: System.get_env("SERVICE_ENVIRONMENT")
@jfornoff
jfornoff / vimrc
Created August 18, 2018 15:26
Function that allows using vim-test inside umbrella projects
function! UmbrellaElixirTestTransform(cmd) abort
if a:cmd !~ 'apps/'
return a:cmd
endif
let testCommand = join(split(a:cmd)[0:-2])
let umbrellaTestFilePath = split(a:cmd)[-1]
let pathFragments = split(umbrellaTestFilePath, "/")
let appName = pathFragments[1]
let localTestPath = join(pathFragments[2:], "/")
@jfornoff
jfornoff / after.ex
Created July 29, 2017 14:51
Before and after exformat (Multiline Maps)
defmodule Maps do
def shortmap do
%{a: "b", c: "d"}
end
def longmap do
x = %{
foo: "bar",
baz: "1",
app:
build: .
volumes:
- /qgen/public
environment:
- RAILS_ENV=production
env_file:
- envfile.${ENV}
proxy:
@jfornoff
jfornoff / Authentication.js
Created October 17, 2014 06:41
Angular.js Authentication Error Handling with HTTP Interceptor
app.factory('Authentication', function($http, $rootScope, $location, $timeout){
var Auth = {};
Auth.unsetUser = function() {
$rootScope.user = {};
};
Auth.setUser = function(data) {
$rootScope.user = data;
@jfornoff
jfornoff / Angular_array_movement.js
Created June 23, 2014 06:35
This is some common element moving functionalitywithin JS Arrays, packaged in a Angular.js factory
app.factory('ArrayService', function(){
return {
deleteElement: function(array, element) {
var index = array.indexOf(element);
if(index == -1){
return false;
}
array.splice(index, 1);