Skip to content

Instantly share code, notes, and snippets.

View aubricus's full-sized avatar
Coffee.

Aubrey Taylor aubricus

Coffee.
View GitHub Profile
@aubricus
aubricus / pyenv-mojave.sh
Last active January 29, 2019 00:10 — forked from excenter/rune.bash
Mojave pyenv update
export LDFLAGS="-L/usr/local/opt/sqlite/lib -L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/sqlite/include -I/usr/local/opt/zlib/include"
xcode-select --install
brew update
brew upgrade
brew install zlib
pyenv install 3.7.1
pyenv global 3.7.1
@aubricus
aubricus / put-inside-functions.php
Created November 20, 2018 02:41 — forked from gilzow/put-inside-functions.php
Removes user endpoints from WordPress REST API
<?php
/**
* Remove API Endpoints
*
* Clobber API routes to remove them from public access.
*/
function remove_wp_json_api_endpoints($endpoints) {
$toRemove = array(
"/oembed/1.0/embed",
"/wp/v2/users",
@aubricus
aubricus / example.html
Created December 7, 2017 04:14
FocusPoint JS Using Picture Element
<div class="focuspoint"
role="presentation"
data-focus-x-sm="-0.27" data-focus-y-sm="0.98" data-image-w-sm="992" data-image-h-sm="685"
data-focus-x-md="-0.29" data-focus-y-md="1.00" data-image-w-md="1102" data-image-h-md="809"
data-focus-x-lg="-0.05" data-focus-y-lg="1.00" data-image-w-lg="1600" data-image-h-lg="879"
>
<picture class="img-presentation">
<source media="(min-width: 1200px)" srcset="http://cdn.com/path/to/marquee-lg.jpg">
<source media="(min-width: 992px)" srcset="http://cdn.com/path/to/marquee-md.jpg">
@aubricus
aubricus / admin.py
Last active October 15, 2017 10:19
De-Dupe / Return Draft DjangoCMS Plugin Instances
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "my_plugin_fk":
kwargs["queryset"] = models.MyPluginModel.objects.filter(
Q(placeholder__static_draft__isnull=False) |
Q(placeholder__page__publisher_is_draft=True)
)
return super().formfield_for_foreignkey(db_field, request, **kwargs)
@aubricus
aubricus / example.scss
Last active June 23, 2017 00:45
Hook a fixed position element into the DjangoCMS toolbar expanded / collapsed states
// Hook a fixed position element into the DjangoCMS toolbar expanded / collapsed states
.fixed-element {
position: fixed;
top: 0;
left: 0;
width: 100%
.cms-toolbar-expanding &,
.cms-toolbar-expanded & {
top: 46px;
@aubricus
aubricus / .gitconfig
Last active September 5, 2017 23:54
Some helpful .gitconfig aliases for following a commit format
# Commit with scope / message shortcuts
# Remember to quote $2 if it contains spaces
#
# Usage:
# git <alias> <scope> "<Commit Message>"
#
# Example:
# git chore docs "Update README.md"
chore = "!f() { git commit -m \"chore($1): $2\"; }; f"
fix = "!f() { git commit -m \"fix($1): $2\"; }; f"
@aubricus
aubricus / reset_db.py
Last active November 11, 2017 11:32
django_extensions reset_db is incompatible with any .py file that accesses the database that's loaded during a `./manage.py` system checks cycle. This gist simply overrides the default `reset_db` command to disable these checks.
from django_extensions.management.commands.reset_db import Command as ResetDBCommand
class Command(ResetDBCommand):
requires_system_checks = False
help = "Override django-extensions reset_db and disable system_checks."
def handle(self, *args, **options):
self.stdout.write("Executing customized version of reset_db that disables system checks.")
super().handle(*args, **options)
@aubricus
aubricus / cors.json
Created April 23, 2017 22:17
Example Heroku compatible S3 CORS.json config
{
"CORSRules": [
{
"AllowedOrigins": ["*.herokuapp.com"],
"AllowedHeaders": ["Authorization"],
"AllowedMethods": ["GET"],
"MaxAgeSeconds": 3000
}
]
}
"""Collect settings for this app from django settings."""
from django.core.exceptions import ImproperlyConfigured
class NotSetButRequired(object):
def __repr__(self):
return '<{0}>'.format(self.__class__.__name__)
# See: https://github.com/joke2k/django-environ/blob/v0.4.1/environ/environ.py#L48
class NoValue(object):
def __repr__(self):
return '<{0}>'.format(self.__class__.__name__)
# https://github.com/joke2k/django-environ/blob/v0.4.1/environ/environ.py#L67
NOTSET = NoValue()