Skip to content

Instantly share code, notes, and snippets.

View awesomephant's full-sized avatar
😤

Max Kohler awesomephant

😤
View GitHub Profile
@robweychert
robweychert / ap-style-month-strftime-liquid.md
Last active February 18, 2020 14:35
AP style month abbreviations with strftime in Liquid

AP style month abbreviations with strftime in Liquid

AP style is particular about how dates are formatted in various circumstances. strftime uses %b for month abbreviations, but its format (the first three letters of the month: Jan, Feb, etc) differs from AP style’s preferred abbreviations for some months. This Liquid snippet converts strftime’s month abbreviations to AP style:

{{ object | date: '%b. %e, %Y' | replace: 'Mar.', 'March' | replace: 'Apr.', 'April' | replace: 'May.', 'May' | replace: 'Jun.', 'June' | replace: 'Jul.', 'July' | replace: 'Sep.', 'Sept.' }}

For example, this Liquid code…

@mikowl
mikowl / oneliners.js
Last active March 28, 2024 20:52
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
@verticalgrain
verticalgrain / image-srcset.twig
Created January 9, 2017 18:53
Timber + Twig srcset image partial
{# Include in views like so: {% include 'partials/image-srcset.twig' with {image_id: post.get_field('hero_background_image'), class: 'hero__background'} %} #}
{# To print image object: {{post.get_field('hero_background_image')|print_r}} #}
<img class="{{class}}" alt="{{TimberImage(image_id).alt}}"
src="{{ TimberImage(image_id).src('large') }}"
srcset="{{ TimberImage(image_id).src('xlarge') }} {{ image_id['sizes']['xlarge-width'] }}w,
{{ TimberImage(image_id).src('hero') }} {{ image_id['sizes']['hero-width'] }}w,
{{ TimberImage(image_id).src('large') }} {{ image_id['sizes']['large-width'] }}w
" />
@Phlow
Phlow / jeykll-post-counter.liquid
Last active November 22, 2019 00:27
Counter: This code snippet just counts your jekyll posts and spits out the result
{% comment %}
*
* Counter: This include counts your jekyll posts
*
{% endcomment %}{% assign counter = 0 %}{% for item in site.posts %}{% unless item.published == false %}{% assign counter=counter | plus:1 %}{% endunless %}{% endfor %}{{ counter }}
@mastastealth
mastastealth / sass-animation
Created April 16, 2013 14:30
Some SASS mixins for animation stuff
@mixin animation ($animations) {
-moz-animation: $animations;
-o-animation: $animations;
-webkit-animation: $animations;
animation: $animations;
}
@mixin animation-fill-mode ($mode) {
-moz-animation-fill-mode: $mode;
-o-animation-fill-mode: $mode;