Skip to content

Instantly share code, notes, and snippets.

View jonnymaceachern's full-sized avatar

Jonny jonnymaceachern

  • Developer @ Media Mechanics
  • Halifax, NS
  • 13:46 (UTC -03:00)
View GitHub Profile
@jonnymaceachern
jonnymaceachern / printr.sublime-snippet
Created November 5, 2015 18:25
Pre wrap print_r()
<snippet>
<content><![CDATA[
<pre>
<?php print_r(\$${1}); ?>
</pre>
]]></content>
<tabTrigger>pr</tabTrigger>
<description></description>
<scope>text.html.basic, punctuation.whitespace.embedded.leading.php</scope>
</snippet>
<snippet>
<content><![CDATA[
/* =========================================== */
/* MEDIA: IPHONES (RETINA) */
/* =========================================== */
@media only screen and (min-width : 320px) {
git ls-files --deleted -z | xargs -0 git rm
<snippet>
<!-- Example: Hello, ${1:this} is a ${2:snippet}. -->
<content><![CDATA[
/*
---------------------------------------------------------------------------
${1}
---------------------------------------------------------------------------
${2}
// Disable completions of HTML attributes
// with this option disabled, you can get attribute list completions
// inside opening HTML tags.
// WARNING: with this option disabled, Tab key expander will not
// work inside opening HTML attributes
"disable_completions": false,
// With this option enabled, all Emmet's CSS snippets
// will be available in standard auto-complete popup
"show_css_completions": true,
/*
---------------------------------------------------------------------------
Custom colors
---------------------------------------------------------------------------
Sass maps are used to create an associative array that can later be
looped through to dynamically create a class for each item. An example
would be the use of the .fill-facebook class to use facebooks branding
as the background color or stroke of a component.
/**
* Outline all classes.
*/
[class] {
outline: 5px solid lightgrey;
}
/**
* Outline all BEM Elements.
*/
@jonnymaceachern
jonnymaceachern / functions.php
Last active July 17, 2017 17:05
Remove related videos from YouTube embeds
// Remove related videos from youtube embeds
add_filter('embed_oembed_html', 'remove_related_videos_from_yt_oembed', 10, 3);
function remove_related_videos_from_yt_oembed($html, $url, $args = array()) {
if(!stristr($html, 'youtube.com/embed/'))
return $html;
preg_match('/src="(.+?(?="))/', $html, $matches);
if(count($matches) >= 2 && stristr($matches[1], 'youtube.com/embed/'))
{
@jonnymaceachern
jonnymaceachern / index.php
Last active July 17, 2017 16:50
Get YouTube ID by URL
<?php
function get_youtube_id( $url ) {
preg_match( "#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $url, $matches );
return $matches[0];
}
// Test
echo get_youtube_id( "https://youtu.be/MZj1bQtRNdk" ) );
@jonnymaceachern
jonnymaceachern / css-logo-carousel.css
Last active July 14, 2017 18:38
Infinite scrolling image via CSS