This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adaptação de http://www.east5th.co/blog/2017/05/08/graphql-authentication-with-elixir-and-absinthe/ | |
defmodule DemoWeb.AuthContext do | |
@moduledoc false | |
@behaviour Plug | |
import Plug.Conn | |
alias Guardian.Plug.Pipeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Languafy.Web.Context do | |
@behaviour Plug | |
import Plug.Conn | |
alias Languafy.User | |
def init(opts), do: opts | |
def call(conn, _) do | |
case build_context(conn) do | |
{:ok, context} -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function useFormik(props) { | |
// useState to keep the same observable around without recreating it on each render | |
const [formik] = React.useState(() => | |
mobx.observable({ | |
values: props.initialValues || {}, | |
touched: {} | |
}) | |
) | |
// just mutate state, this function itself can be considered an action+reducer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
####################################################################### | |
# This script performs deployment of ECS Service using AWS CodeDeploy | |
# | |
# Heavily inspired by https://github.com/silinternational/ecs-deploy , | |
# which unfortunately can't be used to deploy ECS service when `deployment_option=ECS` | |
# | |
# Author: Anton Babenko | |
# URL: https://github.com/antonbabenko |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# IMPORTANT: Make sure your VM's network security rules allows access over TCP Port 80. | |
# This is required to pass the HTTP challenge. | |
# Download: curl -o setup.sh <raw URL of this gist> | |
# Enable execution: sudo chmod +x setup.sh | |
# Run: ./setup.sh -d "yourdomain.tld" -e "youremail@yourdomain.tld" | |
while getopts d:e: option |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for multiple requests | |
let isRefreshing = false; | |
let failedQueue = []; | |
const processQueue = (error, token = null) => { | |
failedQueue.forEach(prom => { | |
if (error) { | |
prom.reject(error); | |
} else { | |
prom.resolve(token); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Because we're using an ORM (Objection), it's a pain to add a tsvector when inserting, | |
// since tsvectors and FTS aren't supported by Objection. Instead, I've added a hook that | |
// fires on insert which auto-generates the tsvector field for each newly inserted entry. | |
// This is an example knex migration file for said behavior. | |
const addUserIndex = ` | |
ALTER TABLE public.user ADD "document" tsvector; | |
CREATE FUNCTION my_trigger_function() | |
RETURNS trigger AS $$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install dependencies that nginx was originally compiled with | |
sudo apt install libperl-dev libgeoip-dev libgd-dev | |
# Get the nginx source | |
wget https://nginx.org/download/nginx-1.14.0.tar.gz | |
tar zxf nginx-1.14.0.tar.gz | |
# Get the module source | |
wget https://github.com/fdintino/nginx-upload-module/archive/master.zip | |
unzip master.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-keygen -t rsa -b 4096 -e SHA512 -f jwtRS512.key | |
# Don't add passphrase | |
openssl rsa -in jwtRS512.key -pubout -outform PEM -out jwtRS512.key.pub | |
cat jwtRS512.key | |
cat jwtRS512.key.pub |