Skip to content

Instantly share code, notes, and snippets.


Jonny MacEachern jonnymaceachern

View GitHub Profile
jonnymaceachern / list.twig
Created Feb 18, 2020
Twig macro for converting list to sentence-like string (e.g. ["apples", "bananas, "carrots] becomes "apples, bananas, and carrots")
View list.twig
{# Loop through all items in a list, comma-separate them, but use "and" before the last item
e.g. ["apples", "bananas, "carrots] becomes "apples, bananas, and carrots" #}
{% macro to_sentence(items) %}
{% for item in items %}
{# First item #}
{% if loop.first %}
<span>{{ item }}{% if items|length > 2 %},{% endif %}</span>
{% else %}
jonnymaceachern / php.json
Last active Feb 14, 2020
VS Code php snippets
View php.json
"Dump variable": {
"prefix": "pr",
"body": [
"echo '<pre>';",
"echo '</pre>';"
jonnymaceachern / scss.json
Created Jan 21, 2020
VS Code snippets for SCSS files
View scss.json
"@include media-breakpoint-only(xs)": {
"description": "Bootstrap media query for 'xs' only",
"prefix": "=xs",
"body": [
"@include media-breakpoint-only(xs) {",
jonnymaceachern /
Created Aug 28, 2019
Batch convert mp4 to webm using ffmpeg
for i in *.mp4;
do name=`echo "$i" | cut -d'.' -f1`
echo "$name"
ffmpeg -i "$i" -acodec libvorbis -aq 5 -ac 2 -qmax 25 -threads 2 "${name}.webm"
jonnymaceachern / _show-bootstrap-breakpoints.scss
Last active Jan 6, 2021
Always display current breakpoint using Bootstrap 4's media breakpoint SCSS variables
View _show-bootstrap-breakpoints.scss
body {
&:after {
content: "< #{map-get($grid-breakpoints, sm)} (xs)";
position: fixed;
z-index: 99999;
padding: 2px 15px;
bottom: 0;
left: 0;
border-top-right-radius: 5px;
background: blue;
View git-commands
.gitignore file
To see the file in folder make 'ls a', to modify do 'vi .gitignore file'. Use this file to insert there full pathes and names of folders/files/objects you would not want to commit to the repo.
git init
To create a new, empty repository in the current directory
git status
Shows status of current repo
git log
View beaver-module-field-types.php
/* text */
'my-field-1' => array(
'type' => 'text',
'label' => __( 'Text Field 1', 'fl-builder' ),
/* textarea */
'my_textarea_field' => array(
'type' => 'textarea',
webdevsuperfast / vc_custom_icon_set.php
Created Nov 12, 2017 — forked from zecka/vc_custom_icon_set.php
Add a custom icon set from icomoon to visual composer vc_icon shortcode
View vc_custom_icon_set.php
// Add new custom font to Font Family selection in icon box module
function zeckart_add_new_icon_set_to_iconbox( ) {
$param = WPBMap::getParam( 'vc_icon', 'type' );
$param['value'][__( 'IcoMoon', 'total' )] = 'icomoon';
vc_update_shortcode_param( 'vc_icon', $param );
add_filter( 'init', 'zeckart_add_new_icon_set_to_iconbox', 40 );
AustinGil / functions.php
Last active Jan 23, 2020
Only load scripts and styles if a specific shortcode is present in the content when the page/post is saved
View functions.php
* This first function maps shortcodes to their respective resources,
* then checks whether those shortcodes exist in the content,
* then stores the required resource handles in a custom field.
* This way, we aren't running resource-intensive functions on every page load.
function check_post_shortcodes($post_id) {
// Map conditional shortcodes to their respective resource handle
// Remember to manually dequeue resource handles below as well.
garvs / ure-edit-posts-access-id-list.php
Created Jan 7, 2017
ure_edit_posts_access_id_list filter
View ure-edit-posts-access-id-list.php
add_filter('ure_edit_posts_access_id_list', 'ure_edit_posts_access_set_id_list');
function ure_edit_posts_access_set_id_list($list) {
$list .= ',1584';
return $list;