Skip to content

Instantly share code, notes, and snippets.

View jonnymaceachern's full-sized avatar

Jonny jonnymaceachern

  • Developer @ Media Mechanics
  • Halifax, NS
  • 13:47 (UTC -03:00)
View GitHub Profile
@jonnymaceachern
jonnymaceachern / batch-convert-mp4-webm.sh
Created August 28, 2019 14:59
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"
done
@jonnymaceachern
jonnymaceachern / _show-bootstrap-breakpoints.scss
Last active April 8, 2023 11:17
Always display current breakpoint using Bootstrap 4's media breakpoint SCSS variables
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;
@jonnymaceachern
jonnymaceachern / mobile-resize-check.js
Created September 4, 2015 14:29
A resize event is triggered when a mobile browsers address bar drops down (when changing directions in a scroll). This will let you check for only width resizes. From http://stackoverflow.com/questions/10750603/jquery-detect-a-window-width-change-but-not-a-height-change
var width = $(window).width();
$(window).resize(function(){
if($(this).width() != width){
width = $(this).width();
console.log(width);
// your code
}
});
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday;
# │ │ │ │ │ 7 is also Sunday on some systems)
# │ │ │ │ │
# │ │ │ │ │
# * * * * * command_to_execute
@jonnymaceachern
jonnymaceachern / png-to-jpg.sh
Created February 1, 2021 19:05
JPG to PNG batch convert using ImageMagick
for i in *.png ; do convert "$i" "${i%.*}.jpg" ; done
@jonnymaceachern
jonnymaceachern / editor.php
Created February 25, 2020 17:07 — forked from justinwhall/gist:1997780
PHP: WordPress | tinyMCE editor style dropdown menu
<?php
/**
* Filter TinyMCE Buttons
*
* Here we are filtering the TinyMCE buttons and adding a button
* to it. In this case, we are looking to add a style select
* box (button) which is referenced as "styleselect". In this
* example we are looking to add the select box to the second
* row of the visual editor, as defined by the number 2 in the
@jonnymaceachern
jonnymaceachern / list.twig
Created February 18, 2020 19:32
Twig macro for converting list to sentence-like string (e.g. ["apples", "bananas, "carrots] becomes "apples, bananas, and carrots")
{# 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
jonnymaceachern / php.json
Last active February 14, 2020 02:43
VS Code php snippets
{
"Dump variable": {
"prefix": "pr",
"body": [
"echo '<pre>';",
"print_r($1);",
"echo '</pre>';"
]
}
}
@jonnymaceachern
jonnymaceachern / scss.json
Created January 21, 2020 19:44
VS Code snippets for SCSS files
{
"@include media-breakpoint-only(xs)": {
"description": "Bootstrap media query for 'xs' only",
"prefix": "=xs",
"body": [
"@include media-breakpoint-only(xs) {",
"\t$1",
"}"
]
},
{
"Dump variable": {
"prefix": "dump",
"body": [
"<pre>",
"\t{{dump($1)}}",
"</pre>"
]
}
}