Skip to content

Instantly share code, notes, and snippets.

View jhnns's full-sized avatar
🧀
When in doubt add cheese!

Johannes Ewald jhnns

🧀
When in doubt add cheese!
View GitHub Profile
@jhnns
jhnns / README.md
Created March 20, 2025 15:02
Bash script to set up an SSH tunnel (in a Github action)

Bash script to set up an SSH tunnel

Starts an SSH tunnel in the background and checks if it is usable. Can be used in a Github action e.g. in order to connect to a Postgres instance that is only reachable via SSH.

You need to set the following env variables

Variable Description
SSH_TUNNEL_HOST The hostname of the machine, e.g. example.com
SSH_TUNNEL_PORT The SSH port you want to connect to (e.g. 22 )
@jhnns
jhnns / app.js
Created March 1, 2019 15:19
Medium code example
import person form "./person.css";
element.innerHTML = `<h1 class="${person.name}">Name</h1>`;
@jhnns
jhnns / person.css
Created March 1, 2019 15:16
Medium code example
.name {
background: hotpink;
}
@jhnns
jhnns / gulpfile.js
Created November 16, 2018 10:51
How to debug a Node.js server written in TypeScript running in Docker
return tsResult.js
.pipe(
sourcemaps.mapSources(function(sourcePath, file) {
return "../../" + sourcePath; // rewrite sourcePath to point to the correct TypeScript file paths
})
)
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest("./dist/src"));
@jhnns
jhnns / launch.json5
Last active November 16, 2018 12:05
How to debug a Node.js server written in TypeScript running in Docker
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Server in Docker",
"port": 9222,
"timeout": 10000,
"stopOnEntry": true,
@jhnns
jhnns / launch.json
Created November 16, 2018 10:36
How to debug a Node.js server written in TypeScript running in Docker
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Docker: Attach to Node",
"port": 9229,
"address": "localhost",
"localRoot": "${workspaceFolder}",
@jhnns
jhnns / Dockerfile
Last active November 16, 2018 11:56
How to debug a Node.js server written in TypeScript running in Docker
FROM node:10.8.0-alpine
WORKDIR /server
COPY package.json package-lock.json ./
RUN npm ci
COPY . /server
CMD [ "npm", "run", "start" ]
@jhnns
jhnns / shadow-dom-example.js
Created August 19, 2018 18:14
shadow-dom-example
customElements.define("my-bubble", class extends HTMLElement {
constructor() {
super();
const template = document.getElementById("my-element-template").content;
const shadowRoot = this.attachShadow({mode: "open"});
shadowRoot.appendChild(template.cloneNode(true));
}
});
@jhnns
jhnns / custom-element-example.js
Last active August 19, 2018 18:08
custom-element-example
customElements.define("my-bubble", class extends HTMLElement {
constructor() {
super();
const template = document.getElementById("my-element-template").content;
const color = this.getAttribute("background") || "white";
template.querySelector(".bubble").style.background = color;
}
});
@jhnns
jhnns / template-example.html
Created August 19, 2018 17:46
Template element example
...
<template id="my-element-template">
<style>
.bubble {
border: .4rem solid black;
border-radius: 2rem;
margin: 1rem;
padding: 1rem .5rem;
cursor: pointer;
font-size: 20px;