Skip to content

Instantly share code, notes, and snippets.

View benspaulding's full-sized avatar

Ben Spaulding benspaulding

View GitHub Profile
@jefftriplett
jefftriplett / capture.py
Created October 27, 2018 15:44
Using Python 3, selenium, and headless chrome ala chromedriver to capture website screenshots
"""
To install:
# python requirements
$ pip install click selenium
# for headless chrome
$ brew install chromedriver
To use:
$ python capture.py https://revsys.com revsys.png
@osopolar
osopolar / com.user.time-machine-exclude-node-modules-job.plist
Last active December 20, 2022 08:44 — forked from peterdemartini/command.sh
Exclude node_modules (and more) from timemachine, use launchd to scan the Project directory on a regular basis, for example meanwhile you are having siesta. Put this file in ~/Library/LaunchAgents and call `launchctl load ~/Library/LaunchAgents/com.user.time-machine-exclude-node-modules-job.plist`
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.time-machine-exclude-node-modules-job</string>
<key>RunAtLoad</key>
<false/>
<key>KeepAlive</key>
<false/>
@nickcernis
nickcernis / readme.md
Last active March 7, 2024 01:43
Exclude node_modules and .git from Backblaze backups on Mac

Exclude node_modules and .git from Backblaze backups on Mac

  1. Edit the file at /Library/Backblaze.bzpkg/bzdata/bzexcluderules_editable.xml.
  2. Add these rules 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="*" />
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/.git/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
@treyhunner
treyhunner / choice_enum.py
Created April 9, 2018 23:49
Enum for use with Django ChoiceField
from enum import Enum, EnumMeta
class ChoiceEnumMeta(EnumMeta):
def __iter__(self):
return ((tag, tag.value) for tag in super().__iter__())
class ChoiceEnum(Enum, metaclass=ChoiceEnumMeta):
"""
@gricard
gricard / webpack4upgrade.md
Last active February 29, 2024 20:23
Just some notes about my attempt to upgrade to webpack 4

If you enjoyed reading this, I'm intending to do more blogging like this over here: https://cdgd.tech

This is not a complaint about Webpack or v4 in any way. This is just a record of my process trying it out so I could provide feedback to the webpack team

Hmm... I don't see any docs for 4.0 on https://webpack.js.org. I guess I'll just wing it. All I need to do is npm i -D webpack@next, right?

+ webpack@4.0.0-beta.2
@hakib
hakib / admin.py
Created December 9, 2017 08:37
Django Admin InputFilter
# common/admin.py
class InputFilter(admin.SimpleListFilter):
template = 'admin/input_filter.html'
def lookups(self, request, model_admin):
# Dummy, required to show the filter.
return ((),)
def choices(self, changelist):
@LeCoupa
LeCoupa / 1_nanobox_cli.sh
Last active October 22, 2023 12:09
Nanobox Cheatsheet: CLI commands and Boxfile --> https://github.com/LeCoupa/awesome-cheatsheets
# *****************************************************************************
# UPDATED VERSION AVAILABLE HERE:
# https://github.com/LeCoupa/awesome-cheatsheets/blob/master/tools/nanobox_cli.sh
# *****************************************************************************
# *****************************************************************************
# LOCAL ENVIRONMENT
# *****************************************************************************
@mixxorz
mixxorz / services.py
Last active January 21, 2020 16:52
Django Service Objects
from django import forms
from django.core.exceptions import ValidationError
from django.db import transaction
class InvalidInputsError(Exception):
def __init__(self, errors, non_field_errors):
self.errors = errors
self.non_field_errors = non_field_errors
@Valian
Valian / profile_middleware.py
Created May 6, 2017 14:13
Detailed Hotshot profiler middleware for Django
# Orignal version taken from http://www.djangosnippets.org/snippets/186/
# Original author: udfalkso
# Modified by: Shwagroo Team and Gun.io
# Further modified by: Jakub Skalecki (https://rock-it.pl)
import hotshot
import hotshot.stats
import textwrap
import os
@captainsafia
captainsafia / usage.md
Last active April 19, 2017 20:03
A poor woman's filesystem watcher

To use watchman, run watchman file-to-watch sleep-time command-to-execute like so.

watchman test.txt 1 echo 'Tada!'