Skip to content

Instantly share code, notes, and snippets.

View jkup's full-sized avatar

Jon Kuperman jkup

View GitHub Profile
@jkup
jkup / Notes.md
Last active February 5, 2018 20:46
Docker Question

My Setup:

  1. I have a Node app running locally with Express + React + etc.
  2. I have an /etc/hosts entry mapping 127.0.0.1 to a necessary hostname 127.0.0.1 really.important.mycompany.com
  3. I have a standalone Docker image running selenium with standalone Chrome (https://hub.docker.com/r/selenium/standalone-chrome/)
  4. I have a webdriverio (http://webdriver.io/) suite of tests that need to run against the really.important.mycompany.com local hostname.

My process:

  1. I start the Docker image with: docker run --name mycompany-selenium --add-host -d --rm -p 4444:4444 selenium/standalone-chrome
interface Admin {
id: string;
role: string;
}
interface User {
email: string;
}
function redirect(usr: Admin | User) {
if("role" in usr) {
// I was amazed TS knew this was an Admin type
@jkup
jkup / index.html
Created June 25, 2021 00:53
CSS Specificity
<!DOCTYPE html>
<html>
<head>
<style>
.foo {
color: blue;
}
#bar {
color: red;
}
@jkup
jkup / auth-middleware.ts
Last active May 2, 2023 04:12
Building a video app with Cloudflare
export const cfTeamsAccessAuthMiddleware = async ({request, data, env, next}) => {
try {
const userEmail = request.headers.get("cf-access-authenticated-user-email")
if (!userEmail) {
throw new Error("User not found, make sure application is behind Cloudflare Access")
}
// Pass user info to next handlers
data.user = {
@jkup
jkup / README.md
Last active May 14, 2024 09:47
Source Maps Milestones

Milestones

Milestone Status Notes
S
@jkup
jkup / InternedString.js
Created October 23, 2024 12:55
InternedStrings
// Class
class InternedString {
static internedStrings = new Map();
static nextId = 0;
constructor(value) {
this.id = InternedString.nextId++;
this.value = value;
}