Skip to content

Instantly share code, notes, and snippets.

View benspaulding's full-sized avatar

Ben Spaulding benspaulding

View GitHub Profile
@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 / 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 / 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 {
...
@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 / hashless-pipenv-reqs.sh
Last active October 30, 2017 12:19
`pipenv lock --requirements` without hashes
# 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 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 / README.md
Created October 23, 2017 05:37
Attempt to install Python packages and Pip data in special location on Nanobox

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 April 28, 2017 16:10
Python class vs instance attributes
>>> 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()