Skip to content

Instantly share code, notes, and snippets.

@urlsangel
urlsangel / Pipfile
Last active July 14, 2022 08:31
Adding an advanced table block to Wagtail
...
wagtailtinymce = {git = "https://github.com/Junatum/wagtailtinymce.git"}
bleach = {extras = ["css"], version = "*"}
@urlsangel
urlsangel / mixins.py
Last active July 9, 2022 14:54
Google-friendly sitemaps for multilingual Wagtail sites
from wagtail.models import Page
from translation.utils import get_translated_sitemap_urls
class ExtendedPage(Page):
class Meta:
abstract = True
def get_sitemap_urls(self, request):
page = self.localized
default_data = [{
@urlsangel
urlsangel / .dockerfile
Last active October 30, 2017 21:48
Run python with docker-compose
FROM python:3.6.2
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r requirements.txt
ENV PYTHONUNBUFFERED 1
@urlsangel
urlsangel / loadDesktopImages.js
Last active December 25, 2015 11:58
loadDesktopImages.js
// loadDesktopImages is looking for spans with a data-img-src attribute, whose parent is visible
// Any parent visible with CSS will trigger the replacement of the span with an image tag
// We use gridset m-hide on images we want to hide from small devices
// <noscript> is there as a backup
/*
<div class="m-hide">
<span title="" class="media__image" data-img-src="http://fillmurray.com/200/300" style=""></span>
<noscript><img title="" alt="" class="media__image" src="http://fillmurray.com/200/300" style=""></noscript>
</div>
@urlsangel
urlsangel / initWebinars.php
Last active December 17, 2015 03:59
Citrix API Helper - some functionality to call the API, and a speicalised webinar call to get webinars, optionally filtered by keyword and optionally limited to a max number to return.
// create a webinar interface
$interface = new WebinarInterface();
// get the webinar data, pass filter and limit (null if not required)
$data = $interface->getWebinars('aCloud', 3);
@urlsangel
urlsangel / wiki.rb
Created April 18, 2013 08:15
Automatically syncing Gollum wiki when used as a web service. I've added the lines at 43, 44 to do a pull/push on the repo to automatically sync on git commit. Is there a cleaner way to do this? And what are the potential issues regarding conflicts?
# Public: Write a new version of a page to the Gollum repo root.
#
# name - The String name of the page.
# format - The Symbol format of the page.
# data - The new String contents of the page.
# commit - The commit Hash details:
# :message - The String commit message.
# :name - The String author full name.
# :email - The String email address.
# :parent - Optional Grit::Commit parent to this update.