Skip to content

Instantly share code, notes, and snippets.

View brentjanderson's full-sized avatar

Brent Anderson brentjanderson

View GitHub Profile
@brentjanderson
brentjanderson / .env.local
Created January 25, 2023 20:06
Knock In-app Notifications with NextAuth/AuthJS
View .env.local
# 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
Created June 14, 2022 15:53
Elixir runtime-controlled supervision tree using feature flags (circuit breaker)
View README.md

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 / Readme.md
Last active April 16, 2021 22:25
Running graphql-codegen on Redwood
View Readme.md

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 / Procfile
Last active August 23, 2023 07:21
Running RedwoodJS on Heroku
View Procfile
release: yarn rw prisma migrate deploy
web: bin/start-nginx node index.js
@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)
View README.md

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
View .eslintrc.js
module.exports = {
env: {
es6: true,
node: true
},
plugins: ["prettier"],
extends: ["plugin:prettier/recommended"],
parserOptions: {
sourceType: "module"
},
@brentjanderson
brentjanderson / Howto.md
Created February 20, 2018 17:55
SSH Tunneling with Firefox
View Howto.md

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 / ISC_LICENSE
Created January 28, 2018 03:08
Sample ISC License
View 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.
View how_to_upload_local_db_to_meteor_app.sh
# How to upload local db to meteor:
# -h = host, -d = database name, -o = dump folder name
mongodump -h 127.0.0.1:3002 -d meteor -o meteor
# get meteor db url, username, and password
meteor mongo --url myapp.meteor.com
# Response will be something like this:
# mongodb://client:f8f6d5aa-1213-008f-31c8-e9e059515615@production-db-a3.meteor.io:27017/myapp_meteor_com
@brentjanderson
brentjanderson / keybase.md
Created March 1, 2014 07:29
Verification for Keybase
View keybase.md

Keybase proof

I hereby claim:

  • I am brentjanderson on github.
  • I am bja (https://keybase.io/bja) on keybase.
  • I have a public key whose fingerprint is D359 6E7E B5E2 E574 AD75 B1BF 17EB 15C0 C056 E7BF

To claim this, I am signing this object: