Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Spaulding benspaulding

View GitHub Profile
@benspaulding
benspaulding / LICENSE.txt
Last active Apr 7, 2020
macOS LoginHook to make Istation.app use the user cache
View LICENSE.txt
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 Mar 26, 2020 — forked from nickcernis/readme.md
Exclude node_modules from Backblaze backups on Mac
View readme.md

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 Feb 8, 2018
Simple start for a Python web app on nanobox.io
View ReadMe.md

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 / gist:599fd5e49155d8a84827a79fc5f510c2
Created Nov 13, 2017
Send nginx server port in host header to upstream only when port is non-standard.
View gist:599fd5e49155d8a84827a79fc5f510c2
# 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 {
...
@benspaulding
benspaulding / README.md
Last active Dec 1, 2017
Help scripts for moving data on and off of Nanobox environments
View README.md

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 / hashless-pipenv-reqs.sh
Last active Oct 30, 2017
`pipenv lock --requirements` without hashes
View hashless-pipenv-reqs.sh
# This works on macOS, and on some Linux distros. If it is failing you may need
# to change the sed option `-E` to `-r`.
pipenv lock --requirements | sed -E 's/[[:space:]]+--hash=[a-z0-9]+:[a-z0-9]+//g'
@benspaulding
benspaulding / appfiles.py
Last active Nov 25, 2017
Script to assign a bunch of file types to a particular macOS app
View appfiles.py
#!/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 / README.md
Created Oct 23, 2017
Attempt to install Python packages and Pip data in special location on Nanobox
View README.md

Simple Python WSGI app for testing some Nanobox stuff

The boxfile is simple, setting up only the bare minimum for this test. You will see that the engine is also very simple. I wanted one that didn’t do any magic or sniffing to install system or Python packages.

I wanted to see if I could put all the pip files and Python packages in a custom, cacheable location. For what it's worth, this all seems to work for me. You can run each command below to see the output. But I think, if this actually does work, all of these steps could be put in the Python engine.

@benspaulding
benspaulding / example.py
Last active Apr 28, 2017
Python class vs instance attributes
View example.py
>>> class Foo(object):
... # Immutable objects are fine as class attrs.
... mystr = 'a'
... myint = 1
... mytpl = (1,)
...
... # But mutable objects often surprise you.
... mylst = []
... mydct = {}
>>> foo = Foo()
View keybase.md

Keybase proof

I hereby claim:

  • I am benspaulding on github.
  • I am benspaulding (https://keybase.io/benspaulding) on keybase.
  • I have a public key whose fingerprint is 20B3 BFB1 AD12 033F 0774 85F5 970F 8167 377B 92A4

To claim this, I am signing this object:

You can’t perform that action at this time.