Skip to content

Instantly share code, notes, and snippets.

@caalberts
caalberts / custom-connection-auth0.md
Last active September 18, 2018 01:09
Create custom OAuth2 connection to third party identity providers using Auth0

Custom OAuth2 Connection with Auth0

Understanding Auth0 authentication

Before we start with creating a custom OAuth2 connection in Auth0, it's worth to spend some time understanding the OAuth2 authentication process in Auth0. An OAuth2 authentication process starts with the application requesting Auth0 for authentication and ends with either the browser or the application server having an access token to represent the user. The access token can then be used to call the third party API on behalf of the user.

Pop-up mode Auth0 popup mode

Redirect mode

@caalberts
caalberts / deploy.yml
Last active December 31, 2023 21:04
Ansible Playbook to Deploy Rails to AWS
---
# Deploy rails app from localhost to remote servers
- name: Set up AWS infrastructure
hosts: localhost
connection: local
roles:
- setup_aws
- name: Package app
@caalberts
caalberts / .babelrc
Last active January 10, 2020 16:11
React + Webpack + Rails
{
"presets": ["es2015", "react"]
}
@caalberts
caalberts / getRSVP.js
Created March 15, 2017 01:34
Retrieve list of RSVPs from Meetup.com
document.querySelectorAll('#rsvp-list .member-name > a').forEach(node => console.log(node.textContent.trim()))
@caalberts
caalberts / pattern_matching.ex
Last active August 11, 2017 03:00
Elixir lunch & learn
case HTTPoison.get(url, headers) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
case Poison.decode(body) do
{:ok, decoded} -> {:ok, decoded}
{:error, error} -> {:error, error}
end
{:ok, %HTTPoison.Response{status_code: status_code}} ->
{:error, status_code}
class Service
def initialize(dependency)
@dependency = dependency
end
def exec()
{
success: true,
data: @dependency.call()
}
describe 'service object' do
let(:data) { { a: 1, b: 2 } }
let(:dependency) { double() }
before do
allow(dependency).to receive(:call).and_return(data)
end
it 'wraps data from dependency into a hash' do
result = Service.new(dependency).exec()
class Service
def exec()
{
success: true,
data: @dependency.call().merge!(hello: 'world')
}
end
end
@caalberts
caalberts / redis.go
Last active December 27, 2017 15:06
func (c *Client) HGetAll(key string) *StringStringMapCmd {}
func (c *Client) HMSet(key string, fields map[string]interface{}) *StatusCmd {}
func (cmd *StringStringMapCmd) Result() (map[string]string, error) {
return cmd.val, cmd.err
}