Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeremy Rose nornagon

View GitHub Profile
@nornagon
nornagon / index.js
Created Jun 17, 2021
test electron crash reporter
View index.js
const { app, crashReporter } = require('electron')
console.log('crashDumps:', app.getPath('crashDumps'))
crashReporter.start({ uploadToServer: false })
app.whenReady().then(() => {
process.crash()
})
@nornagon
nornagon / microtracery-example.html
Created Jan 24, 2021
Example of microtracery usage
View microtracery-example.html
<body>
<script>
// Micro-size tracery implementation by @nornagon: https://twitter.com/nornagon/status/1322718632481153025
function tracery(data, s='#origin#') {return s.replace(/#([^#]+?)#/g, (_,m) => (_=data[m]??[`((${m}))`],tracery(data, _[(Math.random()*_.length)|0])))}
// Example usage
const text = tracery({
origin: ["#a#", "#b#"],
a: ["a1", "a2"],
b: ["b1", "b2"],
View index.mjs
import('./test.mjs') // async import needed to allow for webpack download+compile
View hexrotations.js
// How many unique tiles are required to represent all possible road
// connections on a grid, given that rotations are allowed?
//
// e.g. for a square grid, the tiles look like this:
//
// +---+ +-|-+ +-|-+ +-|-+ +-|-+ +-|-+
// | | | | | | | | | | | | | | | | |
// | | | o | | +-- | | | | +-- --+--
// | | | | | | | | | | | | | | |
// +---+ +---+ +---+ +-|-+ +-|-+ +-|-+
@nornagon
nornagon / github-check-colors.user.js
Created Jun 18, 2019
Make GitHub Checks UI readable
View github-check-colors.user.js
// ==UserScript==
// @name GitHub Check Colors
// @version 1
// @include https://github.com/*
// @grant none
// ==/UserScript==
for (const li of document.querySelectorAll('[data-channel^="check_runs:"] .container-md li')) {
if (/Failed/.test(li.textContent)) {
li.style.color = 'red'
@nornagon
nornagon / find-deps.js
Last active Dec 20, 2018
List transitive dynamic library dependencies on macOS
View find-deps.js
#!/usr/bin/env node
const child_process = require('child_process')
const printTree = require('print-tree')
const depsOf = (lib) => {
const res = child_process.spawnSync('otool', ['-L', lib])
if (res.status !== 0) {
throw new Error(`Failed to run otool on ${lib}:\n${res.stderr}`)
}
return res.stdout.toString()
@nornagon
nornagon / reverse-ssh.md
Created Dec 18, 2018
SSHing into a machine that can't open listening ports
View reverse-ssh.md

How to get SSH access to a machine that can't open listening ports

This will work on any machine that can freely connect to outside ports, but can't listen for incoming connections.

In particular, Azure DevOps CI agents have no "Rebuild with SSH" option (like CircleCI does), so this technique can be handy for debugging CI issues.

Requirements

  1. You must be able to run arbitrary commands on the remote host, ideally including installing an SSH server.
  2. You need a machine on the internet that's able to open a listening port. I used my Linode. You could use an AWS free tier t2.micro, or open a port to your local machine. Anything works as long as it runs SSH and can receive packets from the target machine. We'll call this machine the 'bounce server'.
@nornagon
nornagon / index.html
Created Dec 4, 2018
Electron Fiddle Gist
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
@nornagon
nornagon / index.html
Created Nov 28, 2018
Electron Fiddle Gist
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
@nornagon
nornagon / index.html
Created Nov 28, 2018
Electron Fiddle Gist
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,