Skip to content

Instantly share code, notes, and snippets.

View tjFogarty's full-sized avatar
🇮🇪

T.J. Fogarty tjFogarty

🇮🇪
View GitHub Profile
@tjFogarty
tjFogarty / environment.php
Created October 6, 2013 12:45
Manage assets based on current environment
/**
* Environment
* Lets us manage assets based on current environment
*/
class Environment {
/**
* @param $localEnvironment (default value is 'localhost' if nothing is passed)
* @return boolean
*/
@tjFogarty
tjFogarty / class.formhandler.php
Last active February 7, 2018 11:36
Targets form fields with prefixes to their name, e.g. <input type="text" name="prefix_name"> it will collect all data will "prefix_" in the name, or any prefix you specify in the example.
<?php
/**
* FormHandler takes care of automatically collecting form data and sending the data to a specified email address
*
* @example:
* $form = new FormHandler($from = 'guess@what.com', $to = 'what@isit.com', $subject = $_POST['form-name'], $post_data_prefix = 'obf_');
*/
class FormHandler {
public $mail;
@tjFogarty
tjFogarty / Gruntfile.js
Last active June 18, 2020 15:35
Gruntfile that I use for projects
// http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
module.exports = function(grunt) {
/**
* Saves having to declare each dependency
*/
require( "matchdep" ).filterDev( "grunt-*" ).forEach( grunt.loadNpmTasks );
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
@tjFogarty
tjFogarty / ajax-partial.js
Created February 27, 2014 11:15
Load in sections of a site via AJAX - recommended on non-essential items like a megamenu that might not be used on mobile
/**
* Template
* This allows fetching of non-essential assets via AJAX
* e.g. megamenu
* @param object, configuration parameters
*/
function Template(config) {
this.fetchFile = config.fetchFile;
this.partialsDir = config.partialsDir || '/partials/';
this.fetchURL = this.partialsDir + this.fetchFile;
@tjFogarty
tjFogarty / image-performance.js
Last active August 29, 2015 14:02
This doesn't include checks to see if this is supported on certain browsers.
/**
* Detects using window.performance
* We can serve small images first, then upgrade on faster connections
* See: http://mattandrews.info/talks/port80-2013/#/
*/
(function () {
var perf = window.performance,
start = perf.timing.requestStart, // just before page is requested
end = perf.timing.responseStart, // first byte received
@tjFogarty
tjFogarty / class.vimeothumbnail.php
Last active January 26, 2018 03:12
Get Vimeo thumbnail from video URL
<?php
/**
* Vimeo class to fetch thumbnails
* @example
* $video = new VimeoThumbnail(array(
* 'video_url' => $url
* ));
* echo $video->thumbnail;
*/
### Keybase proof
I hereby claim:
* I am tjFogarty on github.
* I am fogarty (https://keybase.io/fogarty) on keybase.
* I have a public key whose fingerprint is F16E EE8B 30A4 6EA4 8B9B 3293 9C3D FA76 F916 7210
To claim this, I am signing this object:
// inject bower components
gulp.task('wiredep', function () {
gulp.src('./partials/*.php')
.pipe(wiredep({
directory: './bower_components/'
}))
.pipe(gulp.dest('./partials'));
});
@tjFogarty
tjFogarty / foundation-mq.js
Last active August 29, 2015 14:05
Check Foundation Media Queries
/* globals $, jQuery, Foundation */
/* jshint node:true */
'use strict';
window.MQ = (function(MQ, $, queries) {
/**
* $cache elements
* @type {Object}