Skip to content

Instantly share code, notes, and snippets.

View sbaechler's full-sized avatar

Simon Bächler sbaechler

View GitHub Profile
@sbaechler
sbaechler / machine.js
Last active March 23, 2021 09:12
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@sbaechler
sbaechler / create-html-container.ts
Last active February 20, 2020 22:16
Enzyme (Jest) helper: Creates a HTML context for testing elements that contain a DOM reference (e.g. getElementById) such as the Reactstrap Tooltip.
/**
* Creates a HTML context for testing elements that require a DOM
* such as the Tooltip.
*
* @returns A tuple with the DOM container and a cleanup function.
*
* @example
* ```typescript
* let container: HTMLElement;
* let cleanup: () => void;
@sbaechler
sbaechler / gist:4ddecc84475473156b20
Created November 21, 2014 13:57
This snippet can be used to pull up anchor tags so they are not covered by a fixed header. You can use anchor tags within floated elements and you are still able to click on links above the anchor if the header is hidden.
/**
* This snippet can be used to pull up anchor tags so they are not covered by a fixed header.
* You can use anchor tags within floated elements and you are still able to click on links above the anchor
* if the header is hidden.
*/
// dont' style anchors
a[name]:not([href]), a[name]:not([href]):hover {
color: $body-font-color;
font-family: $sansFontFamily;
@sbaechler
sbaechler / adform_tracking.py
Created August 27, 2014 10:19
Feincms Adform tracking extension
# coding: utf-8
"""
Add the necessary tracking information to track each page with Adform.
Add ADFORM_PM to settings. Alternatively you could leave out the pm field and just
write it directly into the template.
<script type="text/javascript">
{% if feincms_page and feincms_page.adform_id > 0 %}
var _adftrack = {
pm: {{ feincms_page.adform_pm }},
@sbaechler
sbaechler / feincms_sorl_thumbnailer.py
Last active August 29, 2015 14:05
A replacement thumbnailer function for FeinCMS that uses sorl
# coding: utf-8
"""
Thumbnailer class for FeinCMS. Allows using sorl thumbnail as default thumbnailer.
Use this if you have mediafiles stored on S3.
Add this line to your settings:
FEINCMS_MEDIALIBRARY_THUMBNAIL = 'feincms_sorl_thumbnailer.thumbnailer'
"""
from __future__ import unicode_literals
@sbaechler
sbaechler / bosg_tags.py
Last active December 19, 2015 02:28
Opening Hours Display Tag
WEEKDAYS = (('mon', _('Montag')),
('tue', _('Dienstag')),
('wed', _('Mittwoch')),
('thu', _('Donnerstag')),
('fri', _('Freitag')),
('sat', _('Samstag')),
('sun', _('Sonntag')),
)
class OpeningHoursNode(template.Node):
@sbaechler
sbaechler / foundation_paginator.py
Last active November 20, 2017 22:00
Django Template Tag for pretty pagination with the Foundation framework.
# -*- coding: utf-8 -*-
"""
Based on http://blog.localkinegrinds.com/2007/09/06/digg-style-pagination-in-django/
and http://djangosnippets.org/snippets/2680/
Recreated by Haisheng HU <hanson2010@gmail.com> on Jun 3, 2012
Updated by Simon Bächler for Foundation on Apr. 28, 2015
http://foundation.zurb.com/docs/components/pagination.html
"""
@sbaechler
sbaechler / feincms_ajax.js
Created September 12, 2011 09:10 — forked from schmidsi/feincms_ajax.js
FeinCMS ajax client side
var ajax_links_selector = 'a.ajax';
var content_selector = '#content';
var first_call = true;
var navilevel_substring = 3; // how many chars from pathname are static (3 for languagecode like /de/)
/* needs jquery address loaded: http://www.asual.com/jquery/address/
*
* needs feincms to be ajax-enabled:
*
* feincms/views/base.py: