Skip to content

Instantly share code, notes, and snippets.

View iantearle's full-sized avatar
💭
I may be slow to respond.

Ian Tearle iantearle

💭
I may be slow to respond.
View GitHub Profile
@iantearle
iantearle / Routes.php
Created May 28, 2014 07:21
PHP Routes Class
<?php
/**
* Routes class.
* Copyright Ian Tearle (c) 2014
*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
@iantearle
iantearle / jquery.exists.js
Created June 18, 2014 14:37
jQuery exists function
jQuery.fn.exists = function(fn) {
if(this.length>0) {
var f = arguments[0];
arguments[0] = function(e) {
f(e);
}
fn.apply( this, arguments );
return fn ? this.bind(name, fn) : this.trigger(name);
} else {
return this.length>0;
@iantearle
iantearle / BootstrapResponsiveImages.js
Last active July 29, 2016 14:06
Bootstrap responsive images script to fetch the appropriate sized image based on the breakpoint and column width.
function findBootstrapEnvironment() {
var envs = ['xs', 'sm', 'md', 'lg'];
var $el = $('<div>');
$el.appendTo($('body'));
for (var i = envs.length - 1; i >= 0; i--) {
var env = envs[i];
$el.addClass('hidden-'+env);
function $(elem) {
return document.querySelector(elem);
}
// let getElement = $('#element');
function hasClass(el, className) {
return el.classList ? el.classList.contains(className) : new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
}
// if(hasClass($('#element'), '.element'))
@iantearle
iantearle / ffmpeg super scripts
Last active January 11, 2023 16:46
MP4 ffmpeg useful options
# convert mp4 to webm
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -speed 3 -pix_fmt yuv420p -color_primaries 1 -color_trc 1 -colorspace 1 -movflags +faststart -an output.webm
# reduce file szie of mp4
ffmpeg -i input.mp4 -c:v libx265 -crf 23 -tag:v hvc1 -pix_fmt yuv420p -color_primaries 1 -color_trc 1 -colorspace 1 -movflags +faststart -an output.mp4