Skip to content

Instantly share code, notes, and snippets.

View zerolab's full-sized avatar
🖖
Live long and prosper

Dan Braghiș zerolab

🖖
Live long and prosper
View GitHub Profile
@tomdyson
tomdyson / wagtail-import-data.md
Last active May 7, 2024 12:35
Create 35k Wagtail pages of Wikipedia film plots

Create Wagtail pages programmatically

This short recipe demonstrates how to create Wagtail pages programmatically. It may also be useful for testing Wagtail development against a reasonable volume of page data (about 35,000 film plots, from English Wikipedia).

Instructions

In a virtualenv:

<?php
use Behat\Mink\Driver\GoutteDriver;
use Behat\Mink\Exception\ElementNotFoundException;
use Behat\Mink\Exception\ExpectationException;
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Behat\Behat\Context\SnippetAcceptingContext;
/**
* Defines application features from the specific context.
@tomdyson
tomdyson / wagtail-on-zappa.md
Last active June 20, 2023 02:22
Wagtail on AWS Lambda, with Zappa

Wagtail on AWS Lambda, with Zappa

Install Wagtail and Zappa, and create an empty site:

pip install wagtail zappa zappa-django-utils
pip install pip==9.0.3 # see https://github.com/Miserlou/Zappa/issues/1471
wagtail start foo
@paulirish
paulirish / what-forces-layout.md
Last active November 15, 2024 16:45
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@frankwiles
frankwiles / blocks.py
Created May 17, 2015 03:13
Code and Markdown blocks for Wagtail 1.0 StreamField
from django.utils.safestring import mark_safe
from markdown import markdown
from pygments import highlight
from pygments.formatters import get_formatter_by_name
from pygments.lexers import get_lexer_by_name
from wagtail.wagtailcore import blocks
class CodeBlock(blocks.StructBlock):
@bgrace
bgrace / gist:a5216b4059007924a75c
Last active February 16, 2018 18:35
Mixed navigation menus for Wagtail CMS
# Notes:
# Python 3 assumed, but shouldn't be hard to backport to Python 2
# Cobbled together from two slightly different implementations, sorry for any inconsistencies.
# This creates two models, NavigationMenu, and NavigationMenuItem. A site can have many NavigationMenus, which are referenced from
# the template by location. E.g., 'footer', 'left_nav'. You can also create single-item lists for special purpose links/buttons,
# such a privacy_policy or homepage_cta. This helps to reduce hard coding in templates.
# NavigationMenuItem mixes in some different link types (Page, Document, URL) and presents them in a consistent way. It provides
# the ability to override the title of the referenced object.
@sergejmueller
sergejmueller / ttf2woff2.md
Last active March 9, 2024 13:37
WOFF 2.0 – Learn more about the next generation Web Font Format and convert TTF to WOFF2
@guillaumepiot
guillaumepiot / gist:8860701
Created February 7, 2014 10:58
Django Weekend - Good practices

#Good practices for project management in Django

#Setting up the environment

Each Django project should be encapsulated in its own virtual environment, allowing us to manage the requirements and dependencies independently.

If you don't have Virtualenv installed, please visit this page and download the virtualenv package. For a simple installation:

@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active November 11, 2024 22:46
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@maxfenton
maxfenton / a-new-mac-setup.md
Last active April 17, 2024 10:55
System setup stuff for a new OLD mac (a/o 2020)

New computer setup

a/o 2020-05-29

--

Format the drive

  1. Restart with Cmd-R or Cmd-D
  2. Erase drive / 3x if second-hand
  3. Reinstall MacOS