Skip to content

Instantly share code, notes, and snippets.

View krzysztofjeziorny's full-sized avatar

Krzysztof Jeziorny krzysztofjeziorny

View GitHub Profile
@krzysztofjeziorny
krzysztofjeziorny / base.html
Last active December 5, 2023 16:51
Wagtail URL 'shortener' redirecting from /item/id to the page's address
<!-- add to <head> to prevent duplicate content issues in search engine optimization -->
<link rel="canonical" href="{{ page.full_url }}">
@krzysztofjeziorny
krzysztofjeziorny / _icons.scss
Last active October 23, 2022 17:27
gulp workflow for building SVG sprites; bonus: placing symbols in a Django template with a custom tag
.icon {
display: inline-block;
vertical-align: middle;
width: 1rem;
height: 1rem;
stroke: currentcolor;
fill: none;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
@krzysztofjeziorny
krzysztofjeziorny / accordion_block.html
Created May 23, 2021 10:54
Wagtail CMS StreamField collapsing block with Bootstrap accordion
{% load wagtailcore_tags %}
<div id="accordion-{{ forloop.counter }}" role="tablist" aria-multiselectable="false" class="card-collapse">
{% for block in self %}
<div class="card card-plain">
<div class="card-header" role="tab" id="heading-{{ forloop.counter }}">
<a data-toggle="collapse" data-parent="#accordion-{{ forloop.parentloop.counter }}" href="#collapse-{{ forloop.parentloop.counter }}-{{ forloop.counter }}" aria-expanded="false" aria-controls="collapse-{{ forloop.parentloop.counter }}-{{ forloop.counter }}">
{% include_block block.value.question %}
<i class="fa fa-chevron-down"></i>
</a>
@krzysztofjeziorny
krzysztofjeziorny / forms.py
Last active September 9, 2020 18:57
custom django form widgets (toggle)
# forms.py
from django import forms
from . import widgets
class CustomWidgetForm(forms.Form):
working = forms.BooleanField(
required=False,
widget=widgets.ToggleWidget(
// https://nickymeuleman.netlify.app/blog/css-animated-wrapping-underline
// https://codepen.io/jh3y/pen/gOPjBPM
:root {
--underline-width: 5px;
--underline-block-width: 2rem;
--underline-color: hsla(7, 72%, 49%, 0.363);
--underline-color-hover: transparent;
--underline-transition-in: 0.75;
--underline-transition-out: 0.5;
// Take a parameter from the URL ie. /?myparam=value
created() {
let uri = window.location.search.substring(1)
let params = new URLSearchParams(uri)
if (params.get("myparam") !== null) {
console.log(`My URL parameter: ` + params.get("myparam"))
this.something = params.get("myparam")
this.myFunction()
}
}
@krzysztofjeziorny
krzysztofjeziorny / hp-proliant-support-pack.list
Last active December 3, 2018 16:59
HP Enterprise apt repository for Debian 9/Stretch
Use script https://downloads.linux.hpe.com/SDR/add_repo.sh (wget, chmod +x, run) or add manually:
vim /etc/apt/sources.list.d/HP-mcp.list
# HPE Management Component Pack
# Latest, here for Debian stretch:
deb http://downloads.linux.hpe.com/SDR/repo/mcp stretch/current non-free
# for Gen9 and older, use 10.xx dist:
deb http://downloads.linux.hpe.com/SDR/repo/mcp stretch/10.62 non-free
@krzysztofjeziorny
krzysztofjeziorny / django-wagtail-apache_vhost.conf
Created November 27, 2018 09:22
A sample Apache vHost configuration file for a Django/Wagtail project
# A sample Apache vHost configuration file
# Source: http://grimnes.no/blog/how-easily-deploy-wagtail-website/
<VirtualHost *:80>
ServerName www.example.com # your domain name
ServerAlias example.com *.example.com
Define project_name some_project_name #
Define user the_username # who owns the project? /home/the_username/..
@krzysztofjeziorny
krzysztofjeziorny / gulpfile.js
Created November 5, 2018 15:06
gulp scss workflow for styles and service worker w/ sw-precache
// Define dependencies
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var nano = require('gulp-cssnano');
var parker = require('gulp-parker');
var run = require('gulp-run');
const workboxBuild = require('workbox-build');
// Compile sass to compressed css andd add vendor prefixes
@krzysztofjeziorny
krzysztofjeziorny / Apache cache-control for Service Worker file
Last active September 7, 2018 13:58
Apache conf/htaccess for setting Cache-Control option for service worker file
<IfModule mod_headers.c>
<filesmatch "sw.js">
Header set Cache-Control "max-age=0, private"
</filesmatch>
</IfModule>
Check with:
curl -I -L http://www.example.com/sw.js