Skip to content

Instantly share code, notes, and snippets.

Jeremy Apthorp nornagon

Block or report user

Report or block nornagon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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>,
@nornagon
nornagon / index.html
Created Nov 9, 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 Oct 16, 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 Oct 16, 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>,
You can’t perform that action at this time.