Skip to content

Instantly share code, notes, and snippets.

View danew's full-sized avatar

Dane Wilson danew

View GitHub Profile
@danew
danew / verifierAndChallenge.js
Created March 21, 2019 16:03
PKCE in the browser
// https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_3_%E2%80%93_rewrite_the_DOMs_atob()_and_btoa()_using_JavaScript's_TypedArrays_and_UTF-8
const base64 = require('base64-js');
const urlSafe = (buffer) => {
const bytes = new Uint8Array(buffer);
return base64.fromByteArray(bytes)
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
};
@danew
danew / Mastermind.js
Created October 8, 2018 00:33
Small sample for the Mastermind problem solving game
class Mastermind {
constructor() {
this.answer = [];
this.blocks = [
'green',
'red',
'blue',
'yellow',
];
}
@danew
danew / cssMock.js
Created January 9, 2018 20:08
Jest mock for CSS that supports multiple CSSModules
module.exports = new Proxy({}, { get: () => 'cssMock' });
@danew
danew / ses-smtp-password.py
Created November 13, 2017 01:06
Ansible filter to create AWS SES SMTP password from aws access secret
#!/usr/bin/env python
import base64
from Crypto.Hash import HMAC, SHA256
class PasswordEncoder:
def encode(self, secret):
signature = self._hmac_sha256(b'SendRawEmail', secret)
byte_array = self._version_signature(signature)
return self._base64_encode(byte_array)

Keybase proof

I hereby claim:

  • I am danew on github.
  • I am daneo (https://keybase.io/daneo) on keybase.
  • I have a public key ASCKVoT9q0qq3_xB5kbMietw0twxS6yt0dVDPFFkAk7aDwo

To claim this, I am signing this object: