Skip to content

Instantly share code, notes, and snippets.

Avatar
Coffee.

Aubrey Taylor aubricus

Coffee.
View GitHub Profile
@aubricus
aubricus / pyenv-mojave.sh
Last active Jan 29, 2019 — forked from excenter/rune.bash
Mojave pyenv update
View pyenv-mojave.sh
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 Nov 20, 2018 — forked from gilzow/put-inside-functions.php
Removes user endpoints from WordPress REST API
View put-inside-functions.php
<?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 Dec 7, 2017
FocusPoint JS Using Picture Element
View example.html
<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 Oct 15, 2017
De-Dupe / Return Draft DjangoCMS Plugin Instances
View admin.py
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 Jun 23, 2017
Hook a fixed position element into the DjangoCMS toolbar expanded / collapsed states
View example.scss
// 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 Sep 5, 2017
Some helpful .gitconfig aliases for following a commit format
View .gitconfig
# 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 Nov 11, 2017
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.
View reset_db.py
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 Apr 23, 2017
Example Heroku compatible S3 CORS.json config
View cors.json
{
"CORSRules": [
{
"AllowedOrigins": ["*.herokuapp.com"],
"AllowedHeaders": ["Authorization"],
"AllowedMethods": ["GET"],
"MaxAgeSeconds": 3000
}
]
}
View django-app-settings.py
"""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__)
View minimal_django_env.py
# 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()