Skip to content

Instantly share code, notes, and snippets.

View bkonkle's full-sized avatar

Brandon Konkle bkonkle

View GitHub Profile
@bkonkle
bkonkle / Google Auth (Part 4).js
Created November 27, 2016 23:51
Electron Google Authentication (Part 4)
export async function fetchAccessTokens (code) {
const response = await axios.post(GOOGLE_TOKEN_URL, qs.stringify({
code,
client_id: GOOGLE_CLIENT_ID,
redirect_uri: GOOGLE_REDIRECT_URI,
grant_type: 'authorization_code',
}), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
@bkonkle
bkonkle / Google Auth (Part 3).js
Created November 27, 2016 23:46
Electron Google Authentication - Part 3
function handleNavigation (url) {
const query = parse(url, true).query
if (query) {
if (query.error) {
reject(new Error(`There was an error: ${query.error}`))
} else if (query.code) {
// Login is complete
authWindow.removeAllListeners('closed')
setImmediate(() => authWindow.close())
@bkonkle
bkonkle / Google Auth (Part 2).js
Last active December 15, 2022 11:32
Electron Google Authentication - Part 2
export function signInWithPopup () {
return new Promise((resolve, reject) => {
const authWindow = new remote.BrowserWindow({
width: 500,
height: 600,
show: true,
})
// TODO: Generate and validate PKCE code_challenge value
const urlParams = {
@bkonkle
bkonkle / Google Auth (Part 1).js
Last active December 15, 2022 11:31
Electron Google Authentication - Part 1
import {parse} from 'url'
import {remote} from 'electron'
import axios from 'axios'
import qs from 'qs'
const GOOGLE_AUTHORIZATION_URL = 'https://accounts.google.com/o/oauth2/v2/auth'
const GOOGLE_TOKEN_URL = 'https://www.googleapis.com/oauth2/v4/token'
const GOOGLE_PROFILE_URL = 'https://www.googleapis.com/userinfo/v2/me'
export async function googleSignIn () {
@bkonkle
bkonkle / app-svc.yaml
Last active October 27, 2016 15:00
Helm Load Balancer example
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
@bkonkle
bkonkle / app-rc.yaml
Last active October 27, 2016 14:59
Helm Replication Controller example
apiVersion: v1
kind: ReplicationController
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
@bkonkle
bkonkle / values.yaml
Last active October 27, 2016 14:59
Helm values.yaml file example
imageName: "node"
imageTag: "boron"
cpu: 100m
memory: 256Mi
port: 3000
replicas: 1
@bkonkle
bkonkle / Chart.yaml
Last active October 27, 2016 14:43
Helm Chart.yaml example
name: node
version: 1.0.0
description: Chart for derivatives of the official Node images
keywords:
- node
- application
home: https://nodejs.org/en/
sources:
- https://github.com/kubernetes/charts
- https://github.com/docker-library/node
@bkonkle
bkonkle / _helpers.tpl
Created October 27, 2016 14:30
Helm template helpers
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 24 -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
@bkonkle
bkonkle / Client.purs
Last active September 14, 2016 05:21
Ygor build config for PureScript
module SelectFrom.Client (init) where
import Prelude
import Control.Monad.Eff (Eff)
import DOM (DOM)
import DOM.HTML (window)
import DOM.HTML.Document (body)
import DOM.HTML.Types (htmlElementToNode, htmlDocumentToDocument)
import DOM.HTML.Window (document)
import DOM.Node.Document (createElement) as Document