Skip to content

Instantly share code, notes, and snippets.

Avatar
🇮🇪

T.J. Fogarty tjFogarty

🇮🇪
View GitHub Profile
View skip-unavailable-dates.js
// given a date range
// and some unavailable dates
// construct multiple allocations to fit around them
// e.g., 21st - 28th with 23rd & 24th unavailable
// gives us 2 allocations: 21st - 22nd and 25th - 28th
import moment from 'moment';
function getDatesInRange(startDate, endDate) {
const dates = [];
@tjFogarty
tjFogarty / Gruntfile.js
Last active Jun 18, 2020
Gruntfile that I use for projects
View Gruntfile.js
// 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 / gulpfile.js
Created Oct 17, 2014
Example Gulp file
View gulpfile.js
var gulp = require('gulp');
var spawn = require('child_process').spawn;
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var runSequence = require('run-sequence');
var penthouse = require('penthouse');
var cleanCSS = require('clean-css');
var fs = require('fs');
// load plugins
View Upvotes.svelte
<script>
import { onMount } from 'svelte'
import { records, record } from './stores'
import * as api from './api'
export let currentRecord
export let hasBeenClicked = false
record.subscribe(value => {
currentRecord = value
@tjFogarty
tjFogarty / wiredep.js
Created Aug 8, 2015
Gulp + Wiredep + Timber + Twig
View wiredep.js
var gulp = require('gulp');
var config = require('../config');
var wiredep = require('wiredep').stream;
gulp.task('wiredep', function () {
gulp.src(config.wiredep_file)
.pipe(wiredep({
directory: 'assets/lib',
ignorePath: '..',
fileTypes: {
View keybase.md

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 3061 7481 280C 07B5 4542 02E2 AB51 0170 42A9 956C

To claim this, I am signing this object:

@tjFogarty
tjFogarty / class.formhandler.php
Last active Feb 7, 2018
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.
View class.formhandler.php
<?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 / class.vimeothumbnail.php
Last active Jan 26, 2018
Get Vimeo thumbnail from video URL
View class.vimeothumbnail.php
<?php
/**
* Vimeo class to fetch thumbnails
* @example
* $video = new VimeoThumbnail(array(
* 'video_url' => $url
* ));
* echo $video->thumbnail;
*/
View cookie-policy.js
View penthouse-gulp.js
var penthouse = require('penthouse');
var fs = require('fs');
var cleanCSS = require('clean-css');
gulp.task('penthouse', ['styles'], function () {
penthouse({
url: ['http://chadwicks.dev'],
css: 'assets/css/application.css',
width: 480,
height: 800