Skip to content

Instantly share code, notes, and snippets.

View easherma's full-sized avatar
👋

Eric Sherman easherma

👋
View GitHub Profile
@zerolab
zerolab / menu_children.html
Last active February 24, 2020 22:45
Wagtail "native" menus
# myapp/templates/tags/menu_children.html
{% load wagtailcore_tags %}
<ul class="primary-children">
{% for child in menuitems_children %}
<li{% if child.is_active %} class="active"{% endif %}><a href="{% pageurl child %}">{{ child.title }}</a></li>
{% endfor %}
</ul>
@gaearon
gaearon / modern_js.md
Last active April 14, 2025 19:22
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@pjho
pjho / example.py
Created October 9, 2016 21:08
Wagtail Related Inline Model
from modelcluster.fields import ParentalKey
from wagtail.wagtailcore.models import Page, Orderable
# The Parent/Consuming page
class ExamplePage(Page):
content_panels = Page.content_panels + [
InlinePanel('related_sub_model_label', label="Ui Heading for inline model"),
]
# The abstract class defining the fields. Can be named whatever.
@vkurup
vkurup / generate_factories.py
Last active April 16, 2021 20:03 — forked from tobiasmcnulty/generate_factories.py
Django management command to generate factory-boy boilerplate factory definitions for all the models in a given app. The code is not intended to be usable right off the bat, it just provides a few sane defaults based on the structure of your models.
from django.core.management.base import BaseCommand
from django.db.models import get_models, get_app, fields
from django.db.models.fields import related
class Command(BaseCommand):
help = """Generate factory-boy factories for the given app"""
def handle(self, *args, **options):
assert len(args) == 1, 'Must specify app name as first and only argument'
@cobyism
cobyism / gh-pages-deploy.md
Last active April 12, 2025 09:10
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).