Skip to content

Instantly share code, notes, and snippets.

Lee Goddard leegee

View GitHub Profile
@leegee
leegee / x.json
Created Feb 15, 2018
vs code workspace colours
View x.json
{
"editor.fontFamily": "Source Code Pro",
"editor.tokenColorCustomizations": {},
"window.zoomLevel": 1,
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 120,
"editor.cursorStyle": "block",
"eslint.alwaysShowStatus": true,
@leegee
leegee / gist:5e44b0205ef820925d2e659cf6f33991
Created Feb 13, 2018
webpackge.devserver.proxy.config.js
View gist:5e44b0205ef820925d2e659cf6f33991
config.APIS.endpoints.reduce((acc, cv) => {
acc[`/onewssi/${cv}/v1`] = {
secure: false,
headers: config.APIS.proxyHeaders,
bypass: (req, res, proxyOptions) => {
// May re-write, rather than bypass, to serve mock data basd on req URI
let rv = false;
let found = true;
if (req.url.indexOf('/mock') == -1
@leegee
leegee / language-chooser.css
Created Dec 22, 2017
CSS List item bullets with CSS background images
View language-chooser.css
// Where flags.png is a sprite of 25x15 px images
// <nav id="language-selection"><ul><li class='en'>
#language-selection {
margin-left: 2em;
}
#language-selection ul {
list-style-type: none;
margin-left: 0;
padding-left: 0;
@leegee
leegee / jwt.js
Last active Nov 16, 2017
Google Auth with Node.js JWT
View jwt.js
const fetch = require('node-fetch');
const FormData = require('form-data');
const JSONWebToken = require('jsonwebtoken');
const getAuthToken = async function (args){
args.duration = args.duration || 60;
args.scope = args.scope instanceof Array? args.scope.join(' ') : args.scope;
let form = new FormData();
form.append('grant_type', 'urn:ietf:params:oauth:grant-type:jwt-bearer');
form.append('scope', args.scope);
@leegee
leegee / eg.pl
Created Nov 13, 2017
Verify Google User with Perl
View eg.pl
# @see https://developers.google.com/identity/sign-in/web/backend-auth
sub verify_with_google {
my $self = shift;
my $res = LWP::UserAgent->new()->get(
'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token='
. $self->{id_token}
);
if ($res->is_success() and
$res->decoded_content =~ /"aud"\s*:\s*"$self->{client_id}"/
) {
@leegee
leegee / jwt.pl
Last active Nov 13, 2017
Google REST API with Perl JSON::WebToken
View jwt.pl
use strict;
use warnings;
require JSON::XS;
require JSON::WebToken;
require LWP::UserAgent;
my $google_ua = signin_with_google(
service_account_id => $SERVICE_AC_ID,
private_key => $PRIVATE_KEY,
@leegee
leegee / login-with-google.js
Last active Nov 9, 2017
Protractor Google OAuth2 Manual Sign-in
View login-with-google.js
loginWithGoogle(
process.env.PROJ_TEST1_GMAIL_USER,
process.env.PROJ_TEST1_GMAIL_PASS
)
/**
* Uses the dreaded `sleep` method because finding the password
* by any css selector tried fails.
* @param {string} username - A Google username.
* @param {string} passphrase - A Google passpharse.
View not-so-tiny-wizard.js
var Wizard = function (state) {
this.state = {};
// pageName: null,
// lastPageName: null
// window.history.popstate();?
Object.keys(state).forEach((key) => {
this.state[key] = state[key];
});
this.pageEl = null;
this.el = {
@leegee
leegee / eg.js
Created Nov 2, 2017
Handlebars template to include other templates from DOM
View eg.js
el.main.innerHTML = Handlebars.compile(
el.innerHTML.toString()
)(
{ myContext: this }
);
// {{#includeDomTemplate "publish-tables-and-skus"}}{{/includeDomTemplate}}
Handlebars.registerHelper('includeDomTemplate', function(templateId) {
var html = Handlebars.compile(
document.getElementById(templateId).innerHTML.toString()
View tinywizard.js
var Wizard = function (access_token) {
this.access_token = access_token;
this.page = 0;
this.el = {
main: document.getElementById('main'),
pageNumber: document.getElementById('pageNumber')
};
this.el.pageNumber.setAttribute('style', 'display:block"');
}
You can’t perform that action at this time.