Skip to content

Instantly share code, notes, and snippets.

View benspaulding's full-sized avatar

Ben Spaulding benspaulding

View GitHub Profile
@benspaulding
benspaulding / appfiles.py
Last active April 20, 2024 14:11
Script to assign a bunch of file types to a particular macOS app
#!/usr/bin/env python3
"""
Assign file types to be opened by a particular application.
Requires the ``duti`` program::
> brew install duti
> ./appfiles.py --help
TODO
@benspaulding
benspaulding / Application.applicationWillSwitchOut.applescript
Created October 14, 2011 17:56
AppleScript that will save all documents with unsaved changes when BBEdit loses focus.
(*
File:
Application.applicationWillSwitchOut.scpt
Abstract:
This script will automatically save all on-disk text documents with unsaved
changes when BBEdit loses focus.
Version:
@benspaulding
benspaulding / ReadMe.rst
Created October 16, 2011 04:33
Intelligently rename active document in BBEdit.

BBEdit Rename Active Document Script

The script itself has most of the documentation. Just know that there are two scripts here:

  1. A plain-text version (.applescript)
  2. A compiled version (.scpt)
@benspaulding
benspaulding / js-paradigms.md
Created July 28, 2021 19:19
Prototypical vs Classical "inheritance" in JavaScript

Prototypical vs Classical "inheritance" in JavaScript

Prototypical

function Rotorcraft(rotorBlades) {
  this.rotorBlades = rotorBlades;
}
Rotorcraft.prototype = {
  start() {
@benspaulding
benspaulding / ReadMe.rst
Created October 17, 2011 01:24
Scripts for using BBEdit, TextWrangler, or MacVim as default command line EDITOR.

EDITOR Helpers

Author

Ben Spaulding

This is a collection of helper scripts for using popular Mac text editors as your terminal EDITOR.

These are certainly not essential, as all of the editors helped here ship with a powerful command-line utility. However, to properly use them for something like

@benspaulding
benspaulding / LICENSE.txt
Last active April 7, 2020 16:19
macOS LoginHook to make Istation.app use the user cache
BSD 3-Clause License
Copyright (c) 2020, Ben Spaulding
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
@benspaulding
benspaulding / readme.md
Created March 26, 2020 16:20 — forked from nickcernis/readme.md
Exclude node_modules from Backblaze backups on Mac

Exclude node_modules from Backblaze backups on Mac

  1. Edit the file at /Library/Backblaze.bzpkg/bzdata/bzexcluderules_editable.xml.
  2. Add this rule inside the bzexclusions tag:
<!-- Exclude node_modules. -->
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/node_modules/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />

Notes

@benspaulding
benspaulding / ReadMe.md
Last active February 8, 2018 04:55
Simple start for a Python web app on nanobox.io

Test if Nanobox Python is configured properly

Sometimes getting caught up in the configuration of gunicorn or uWSGI with the configuration of nanobox can be confusing. If you are not getting what you expect, starting here can be a good way to know if you have ports configured properly.

local

When running nanobox run remember that:

@benspaulding
benspaulding / README.md
Last active December 1, 2017 22:05
Help scripts for moving data on and off of Nanobox environments

These are works in progress, but they function for me and my uses.

Note that I wrote one in sh and one in fish just for exercise — the sh one will work fine if you use fish. The only time you need to pick one to match your own shell is if the files will be sourced, which is not yet supported.

Ideas

  • Add a script to simply drop you into a shell on host machine with all these environment variables set. That would make it easier to run multiple commands.
  • Add ability to source the files so the individual functions could be used in other places.
@benspaulding
benspaulding / gist:599fd5e49155d8a84827a79fc5f510c2
Created November 13, 2017 19:44
Send nginx server port in host header to upstream only when port is non-standard.
# Send nginx server port in host header to upstream only when port is non-standard.
# Requires nginx >= 0.9.0
map $server_port $host_port {
default $:port;
80 '';
443 '';
}
server {
...