Skip to content

Instantly share code, notes, and snippets.

View espoelstra's full-sized avatar

Ethan Spoelstra espoelstra

View GitHub Profile
@espoelstra
espoelstra / fix-chrome-session.sh
Created March 19, 2020 02:08
Disable Chrome automatic recovery when a crash happens by fixing the state before it starts
# Find exited cleanly and set it to true
sed -i 's%"exited_cleanly"%c"exited_cleanly": true' ~/.config/chromium/Default/Preferences
# could potentially run chrome || sed or add it to the desktop shortcut before launching chrome
@espoelstra
espoelstra / esc_ctrl.json
Last active March 18, 2020 00:19
karabiner elements esc inside VM where outer host has Caps remapped already `open 'karabiner://karabiner/assets/complex_modifications/import?url=https://gist.githubusercontent.com/espoelstra/7457c97a09d966e4cb62c6bc406b0422/raw/esc_ctrl.json'`
{
"title": "esc double mapping",
"rules": [
{
"description": "left Ctrl is remapped to Cmd, need esc when held to simulate other ctrl",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "escape",
@espoelstra
espoelstra / tabs_outliner.json
Last active August 6, 2019 19:42
Add custom Tabs Outliner overrides for "rux616/karabiner-windows-mode" `karabiner://karabiner/assets/complex_modifications/import?url=https://gist.githubusercontent.com/espoelstra/53c747a274a7b2b81652ab1cd74a13da/raw/tabs_outliner.json`
{
"title": "Tabs Outliner overrides",
"rules": [
{
"description": "X (Ctrl+Shift) [Only Chrome]",
"manipulators": [
{
"from": {
"key_code": "x",
"modifiers": { "mandatory": ["control", "shift"]}
@espoelstra
espoelstra / !new-machine-setup.sh
Last active April 27, 2020 01:23
New macOS setup for flexibility and productivity
# Check the dock settings
# Future plan is automatic removal of unwanted items and addition of only necessary items using dockutil/Ansible
# plutil -p Library/Preferences/com.apple.dock.plist
# Enable SSH server for remote management/configuration
sudo systemsetup -setremotelogin on
# Install Homebrew (if it isn't already available)
hash brew || /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@espoelstra
espoelstra / azure-pipelines.yml
Last active April 2, 2019 18:29
Azure DevOps Docker for Mac installation
pool:
vmImage: 'macOS-10.13'
steps:
- bash: |
brew cask install docker # grabs Docker for Mac
set -x
echo "Running xattr" # I think brew is supposed to do this but I was still prompted to "trust" it if I didn't
xattr -d -r com.apple.quarantine /Applications/Docker.app
echo "Running Docker as root to install helpers"
@espoelstra
espoelstra / README.md
Last active April 2, 2019 16:00 — forked from fkorotkov/nanka.xml
Use the xml to enabled nested virtualization with the Anka command line installation instructions like `sudo installer -applyChoiceChangesXML nanka.xml -pkg AnkaBuild-1.4.3.104.pkg -target /`

README

Save this XML somewhere like $HOME/Downloads alongside the Anka .pkg file. Install/reinstall using this xml to enabled nested virtualization with the Anka command line installation instructions:

  • sudo installer -applyChoiceChangesXML nanka.xml -pkg AnkaBuild-1.4.3.104.pkg -target / If your hardware supports things properly, you should be able to install Docker for Mac inside the VM and use it.
@espoelstra
espoelstra / fix-desktop-launcher.sh
Created February 6, 2019 21:25 — forked from stuaxo/fix-desktop-launcher.sh
Launch desktop files instead of opening them in gedit.
$ sudo apt-get install dex
$ /usr/bin/dex -c /usr/bin/dex -t ~/.local/share/applications/
@espoelstra
espoelstra / !notes.md
Last active February 8, 2019 17:45
Jetbrains IntelliJ IDEA RubyMine WebStorm PhpStorm PyCharm HiDPI on ChromeOS experiments

Finding optimal settings for rapidly scalable ChromeOS UI

Official documentation

https://www.reddit.com/r/Crostini/wiki/howto/adjust-display-scaling

"Best" method in Chrome v73+

The BEST way to do this in ChromeOS is to right click the application icon and choose "Use low density", then either allow ChromeOS to restart the app or say "Not now" and do it yourself. Upon starting the application again you should have a readable UI without monkeying with the Java VM options or the properties of whichever app your are using.

@espoelstra
espoelstra / .moving-domain-joined-drives.md
Last active October 1, 2018 16:52
Moving hard drive between computers when joined to an AD/SSSD domain

When imaging a computer to speed up the process and avoid prompts but also prevent duplicate names on the network, you will typically configure your image to pull out some unique identifier from the hardware and use that as part of the hostname. This could be the system serial number or the MAC address of the on board network controller (highly unlikely to change without a new motherboard) or something else like that.

The trouble with moving a hard drive that has been imaged this way is that it doesn't magically adopt the unique attributes from the new system, and if you reimage the old system with another drive, there is now an "evil" twin on the network, which causes no end of fun and frivolity when suddenly one becomes untrusted and you can't log into any AD accounts from it.

The solution is that immediately after moving the drive to a new computer, you should login, then unjoin the domain (requires domain admin permissions) so you can rename and rejoin once you know what unique identifier you will use i

@espoelstra
espoelstra / .bats-advice.md
Created September 30, 2018 02:20
Bats testing advice, pitfalls, and behaviors to watch out for

You can test almost anything with Bats, assuming it accepts input and produces output or an exit code. Bats is commonly used to test scripts, but it can also be used to wrap characterization or integration tests or API "contract" tests around an executable (eg run my-thing.bin -h ; assert_exit_code == 0 or to run a series of commands and test the results across various parts of the system (eg docker ps | grep bats ; assert_line 'bats/bats:latest').

When testing a shell script with bats there are multiple ways to perform the tests. You can do a "blackbox" style run my-script.sh --some option --other-flag and assert certain outputs and status codes and check for the presence or absence of temporary files in /tmp (if it was supposed to create or clean them up), or the absence of oh-poop.log files if the script triggers logging when it hits an error. Or you can do individual function testing and examine the environment variables after executing individual functions to check for any state that you are t