Skip to content

Instantly share code, notes, and snippets.

View smashwilson's full-sized avatar
🤖
HAPPINESS IS MANDATORY

Ash Wilson smashwilson

🤖
HAPPINESS IS MANDATORY
  • GitHub Staff
  • 01:34 (UTC -04:00)
View GitHub Profile
@smashwilson
smashwilson / electron-trace.js
Created April 18, 2019 13:32
Collect tracing data from Electron that may be loaded into the Chrome devtools
const TRACEOPTS = {
categoryFilter: [
'-*', 'devtools.timeline', 'disabled-by-default-devtools.timeline',
'disabled-by-default-devtools.timeline.frame', 'toplevel', 'blink.console',
'disabled-by-default-devtools.timeline.stack',
'disabled-by-default-v8.cpu_profile', 'disabled-by-default-v8.cpu_profiler',
'disabled-by-default-v8.cpu_profiler.hires'
].join(','),
traceOptions: 'record-until-full',
options: 'sampling-frequency=10000'
@smashwilson
smashwilson / review-map.md
Last active October 4, 2018 20:05
Rough map of the files changed within atom/github#1512

Map of the review

Package metadata

I've bumped up the minimum Atom version to 1.32 so we're sure to include the custom line-number gutter work I did in core. I'm also using underscore-plus for keystroke normalization and adding a package setting to toggle the gutter decorations.

  • package.json
  • package-lock.json

Models

@smashwilson
smashwilson / init.js
Created May 2, 2018 17:10
Init script to refactor @autoBind to autobind helper calls
atom.commands.add('atom-text-editor', 'me:copy-autobinds', event => {
const editor = event.target.closest('atom-text-editor').getModel()
const text = editor.getText();
const methodNames = [];
const rx = /@autobind\s*(async\s*)?([a-zA-Z_]+)/g
let match = rx.exec(text)
while (match !== null) {
methodNames.push(match[2])
@smashwilson
smashwilson / init.js
Last active April 29, 2020 17:45
Init script blurb to fold mocha, jasmine, or minitest tests down to the "it" blocks
atom.commands.add('atom-text-editor', 'me:fold-to-it', event => {
const editor = event.target.closest('atom-text-editor').getModel()
const languageMode = editor.getBuffer().getLanguageMode()
if (!languageMode.tree) return
editor.unfoldAll()
const startsWith = (node, text) => {
const startPosition = new Point(node.startPosition.row, node.startPosition.column)
const endPosition = startPosition.traverse([0, text.length])
@smashwilson
smashwilson / init.js
Created February 13, 2018 19:10
Atom init.js
const util = require('util')
const {watchPath} = require('atom')
const commands = {}
function focusTracer (event) {
console.log('window.focus =', event.target)
}
commands['me:trace-focus'] = () => window.addEventListener('focusin', focusTracer)
@smashwilson
smashwilson / thread-notes.md
Created October 3, 2017 01:45
Brainstorming possible Thread race conditions.

Thread states:

  • STOPPED

No state transitions are possible without the main thread initiating them. Sent messages are handled "offline." Depending on thread implementation, the offline command handler may:

  1. Alter private Thread state directly and acknowledge a command directly by producing an ack message on its output queue.
  2. Enqueue the command on the input queue and transition the Thread to STARTING.
  • STARTING
@smashwilson
smashwilson / ssh-pinentry.sh
Last active March 14, 2017 18:44
Use the GPG pinentry-mac app for SSH keys
#!/bin/sh
#
# chmod +x this script and set it as SSH_ASKPASS.
set -euo pipefail
urldecode() {
python -c 'import sys, urllib; sys.stdout.write(urllib.unquote(sys.stdin.read()))'
}
@smashwilson
smashwilson / keybase.md
Created November 17, 2016 16:07
keybase.md

Keybase proof

I hereby claim:

  • I am smashwilson on github.
  • I am smashwilson (https://keybase.io/smashwilson) on keybase.
  • I have a public key ASDLshtqX8WiFOwtiFfYbPxYTGL3C7GyWNdtPDlfPtGBhwo

To claim this, I am signing this object:

@smashwilson
smashwilson / localhost.py
Last active March 3, 2020 09:10
Dynamic inventory that sets ansible_python_interpreter for localhost correctly, even within a virtualenv
#!/usr/bin/env python
# Generate a "localhost" entry dynamically that uses a local connection and
# the same Python interpreter that's being used to execute this inventory
# script, which will work properly within a virtualenv.
import argparse
import json
import os
import sys
@smashwilson
smashwilson / nexus-deletion.md
Last active June 3, 2016 13:30
Content enumeration and deletion from Nexus

Prerequisites

Listing content

Before deleting content in production, it's a good idea to make sure you know what you're about to delete. You can list the content IDs that are currently present in Nexus by visiting the /content/ endpoint: