Skip to content

Instantly share code, notes, and snippets.

View brentjanderson's full-sized avatar

Brent Anderson brentjanderson

View GitHub Profile
@brentjanderson
brentjanderson / README.md
Created June 14, 2022 15:53
Elixir runtime-controlled supervision tree using feature flags (circuit breaker)

These snippets provide a foundation for starting and stopping supervision trees at runtime using feature flags (e.g. Launch Darkly).

Some things to note when adapting these snippets:

  1. application.ex needs to be adapted into an existing application. The important part is that each child spec provided is compliant, and that there is a feature flag (ld_key) specified.
  2. As written, if a feature flag fails for some reason, it defaults to starting all children. There is room for adaptation here as needed.
  3. This implementation will still require a FeatureFlags module to be available that implements is_on?/2. Adjust as needed to accomodate your own feature flag setup.
@brentjanderson
brentjanderson / Howto.md
Created February 20, 2018 17:55
SSH Tunneling with Firefox

Sometimes it is useful to route traffic through a different machine for testing or development. At work, we have a VPN to a remote facility that we haven't bothered to fix for routing, so the only way to access a certain machine over that VPN is via an SSH tunnel to a machine that is reachable over the VPN. Other times, I have used this technique to test internet-facing requests against sites I am developing. It is pretty easy, and if you don't use firefox regularly, you can treat Firefox as your "Proxy" browser and other browsers can use a normal configuration (Although you can also configure an entire system to use the proxy, other articles exists that discuss this potential).

  1. Open a terminal
@brentjanderson
brentjanderson / Procfile
Last active August 23, 2023 07:21
Running RedwoodJS on Heroku
release: yarn rw prisma migrate deploy
web: bin/start-nginx node index.js
@brentjanderson
brentjanderson / .env.local
Created January 25, 2023 20:06
Knock In-app Notifications with NextAuth/AuthJS
# These values all come from the dashboard
NEXT_PUBLIC_KNOCK_PUBLIC_API_KEY=pk_test_1234567890_abcdefghijklmnop
NEXT_PUBLIC_KNOCK_FEED_ID=b935c367-2347-43b1-8f28-867330a2a636
# Replace each line break with `\n` and then wrap the whole thing in JSON. JSON.parse will properly decode all of it.
KNOCK_SIGNING_KEY='{"key": "-----BEGIN RSA PRIVATE KEY-----\n<The rest of the key goes here>\n-----END RSA PRIVATE KEY-----"}'
@brentjanderson
brentjanderson / Readme.md
Last active April 16, 2021 22:25
Running graphql-codegen on Redwood

I'm assuming you're using Apollo. This can be changed

  1. Install a few dependencies: yarn add -WD @graphql-codegen/cli @graphql-codegen/typescript @graphql-codegen/typescript-operations @graphql-codegen/typescript-react-apollo @graphql-codegen/typescript-resolvers npm-run-all ts-node

  2. In my setup, I also threw in npm-run-all and made some edits to my root package.json "scripts": yarn add -WD npm-run-all

     "dev": "npm-run-all --parallel dev:**",

"dev:rw": "rw dev",

@brentjanderson
brentjanderson / adapter.js
Last active October 23, 2019 19:12
NOTE: Not updated since early 2013 - likely will not work with modern EmberData. Ember.JS, ember-data, and socket.io adapter. Not as primitive as the initial version and it supports object creation/deletion/etc. Does not support bulk updates like the first one just to keep it simple. Does support ember-data revision 11 and does support queries/f…
/*jshint browser:true */
/*global DS:true, io:true, App:true */
(function() {
'use strict';
// Initializer for Models
window.Models = {};
console.warn("Don't pollute the global namespace with Models!");
@brentjanderson
brentjanderson / README.md
Last active June 8, 2018 19:41
Example Dockerfiles for phoenix app packaged with distillery (Production ready image and testing image)

Note that these dockerfiles depend on:

  • Having Docker installed on your machine
  • Rebuilding the image every time you want to try your latest code
  • Passing necessary environment variables when you docker run
  • Your app includes distillery and coveralls

Make modifications as needed to meet those requirements.

Note that multi-stage builds can be used to combine the prod and test files described below, I haven't updated the gist yet to reflect that option.

@brentjanderson
brentjanderson / .eslintrc.js
Created March 2, 2018 23:03
Standards .eslintrc.js
module.exports = {
env: {
es6: true,
node: true
},
plugins: ["prettier"],
extends: ["plugin:prettier/recommended"],
parserOptions: {
sourceType: "module"
},
@brentjanderson
brentjanderson / ISC_LICENSE
Created January 28, 2018 03:08
Sample ISC License
Copyright 2018
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@brentjanderson
brentjanderson / Vagrantfile
Created August 8, 2013 22:30
Vagrant configuration file for a jekyll installation.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :forwarded_port, host: 4000, guest: 4000
end