Skip to content

Instantly share code, notes, and snippets.

View scolton99's full-sized avatar
🐢

Spencer Colton scolton99

🐢
  • Northwestern University
  • Chicago, IL
View GitHub Profile
#lang racket
(define coins
(list (cons 25 'quarter)
(cons 10 'dime)
(cons 5 'nickel)
(cons 1 'penny)))
(define (make-change cents)
(if (= cents 0)
.data
q: .string "QUARTER"
n: .string "NICKEL"
d: .string "DIME"
p: .string "PENNY"
f: .string "%s, "
fai: .string "FAILURE"
el: .string "\n"
pts: .quad q, d, n, p, 0
const COINS = {
25: 'QUARTER',
10: 'DIME',
5: 'NICKEL',
1: 'PENNY'
};
const COIN_VALUES = Object.keys(COINS).sort((a, b) => b - a);
class LL {
@scolton99
scolton99 / Tree.js
Last active April 26, 2022 14:55
Check to see if a tree is symmetric about the root.
module.exports = class Tree {
left = null;
right = null;
value = null;
constructor(v, l = null, r = null) {
this.value = v;
this.left = l;
this.right = r;
}
@scolton99
scolton99 / sso-2.spec.js
Created February 25, 2022 04:17
Passing test for Cypress test project.
it('this one succeeds', () => {
cy.visit('https://sso.local.domain:8443/');
cy.intercept({
method: 'POST',
url: 'https://sso.local.domain:8443/'
}, cookieFixer);
cy.get('#username').type('username');
cy.get('#password').type('password');
@scolton99
scolton99 / cookieFixer.js
Created February 25, 2022 04:16
Function to fix the set-cookie header for Cypress test project.
const cookieFixer = req => {
req.continue(res => {
// Add the desired SameSite and Secure flags to the end of the header setting the cookie
res.headers['set-cookie'][0] += '; SameSite=None; Secure';
});
};
@scolton99
scolton99 / sso-1.spec.js
Created February 25, 2022 04:09
Failing test case for Cypress test project.
describe('SSO login test', () => {
it('this one fails', () => {
cy.visit('https://sso.local.domain:8443/');
cy.get('#username').type('username');
cy.get('#password').type('password');
cy.get('#submit').click();
cy.location('pathname').should('include', 'callback');
@scolton99
scolton99 / index.js
Created February 25, 2022 03:53
Mock server starter for Cypress test project.
const sso = require('./sso');
const mfa = require('./mfa');
mfa(() => {
console.log('MFA listening...');
sso(() => {
console.log('SSO listening...');
});
});
@scolton99
scolton99 / mfa-client.js
Created February 25, 2022 03:53
Mock MFA UI script for Cypress test project.
setTimeout(() => {
window.location.assign(window.redirect);
}, 3000);
@scolton99
scolton99 / mfa.pug
Created February 25, 2022 03:50
Mock MFA UI for Cypress test project.
doctype html
html
head
script window.redirect = "#{redirect}";
script
include ../public/js/mfa.js
body Doing MFA things...