Skip to content

Instantly share code, notes, and snippets.

Avatar
🥰
Love code, hate racism

Martin Szymanski elfacht

🥰
Love code, hate racism
View GitHub Profile
@elfacht
elfacht / elements-last-row.scss
Created Oct 15, 2020
Modify elements in last row
View elements-last-row.scss
// Modify the items in the last row
// @param {Number} $range
// @param {String} $selector
@mixin u-last-row($range: 2, $selector: '.class') {
&:nth-last-child(-n+#{$range}):nth-child(#{$range}n+1),
&:nth-last-child(-n+#{$range}):nth-child(#{$range}n+1) ~ #{$selector} {
@content;
}
}
@elfacht
elfacht / cache-breaker-bookmarklet.js
Last active Oct 8, 2020
🤸🏽‍♀️ Cache Breaker Bookmarklet
View cache-breaker-bookmarklet.js
javascript:(function()%7Bvar%20url%20%3D%20location.protocol%20%2B%20'%2F%2F'%20%2B%20location.host%20%2B%20location.pathname%3Bwindow.location.href%20%3D%20url%20%2B%20'%3F'%20%2B%20Math.floor((Math.random()%20*%20100000000000)%20%2B%201)%7D)()
@elfacht
elfacht / craft-updater.sh
Last active Mar 10, 2021
Update all local Craft CMS installations with one bash script.
View craft-updater.sh
#!/bin/bash
#
# Update all local Craft CMS installations at once
# by adding the folder names and running:
#
# $ ./craft-updater.sh
#
ROOT_PATH="/path/to/local/htdocs/"
@elfacht
elfacht / routes.php
Created May 9, 2019
Multi-Environment Routes in Craft CMS
View routes.php
$routes = array(
// Default routes
);
$stagingRoutes = array(
'<url:(?!api\/).*>' => ['template' => 'index'],
);
if (strpos(CRAFT_ENVIRONMENT, 'staging') !== false) {
$routes = array_merge($routes, $stagingRoutes);
@elfacht
elfacht / craft-svg-localstorage.twig
Created Dec 7, 2018
Get filemtime of file in Twig to use SVG sprite caching in localStorage. https://osvaldas.info/caching-svg-sprite-in-localstorage
View craft-svg-localstorage.twig
{# Get filetime of SVG sprite to set revision #}
{# @see https://osvaldas.info/caching-svg-sprite-in-localstorage #}
{% set svgFile = 'assets/svg/svg.html' %}
{% set filemtime = craft.app.view.evaluateDynamicContent("return filemtime('#{svgFile}');") %}
<script>
var INLINE_SVG_REVISION = {{filemtime}};
var INLINE_SVG_FILE = '{{svgFile}}'
{{ source ('assets/js/app/svg.js', ignore_missing = true) }}
</script>
@elfacht
elfacht / craft-entries-pagination.html
Last active Jun 17, 2018
Display a pagination for entries instead of pages to display on entry detail pages.
View craft-entries-pagination.html
{#
Display a pagination for entries instead of pages
to display on entry detail pages.
This will behave like this:
Post 3
Post 4
Post 5
Post 6 * current
View sass-font-map.scss
////
/// Typography
/// @group typography
///
////
/// Font stack
$font-stack: ('Helvetica', 'Arial', sans-serif);
@elfacht
elfacht / color-palette.scss
Created Jul 10, 2015
Sass color palette function
View color-palette.scss
/// UI colors map for the main theme
///
/// @example
/// .element {
/// color: palette(ui, 'brand');
/// }
$palettes: (
ui: (
'brand': $color-brand,
'brand-dark': mix(black, $color-brand, 20%),
View color-vars--example.scss
// http://codepen.io/erskine/pen/wLclB
// config
$_color-base-grey: rgb(229,231,234);
$palettes: (
purple: (
base: rgb(42,40,80),
light: rgb(51,46,140),
dark: rgb(40,38,65)
),
grey: (
View parallax-header-init.js
window.onload = function () {
parallaxHeader(document.getElementById('header'));
};