Skip to content

Instantly share code, notes, and snippets.

@eoghanobrien
eoghanobrien / laracasts-series-time-calculator.js
Created February 13, 2018 18:36
Bookmarklet source code to calculate the length of a series on Laracasts.com
// Bookmarklet created using http://chriszarate.github.io/bookmarkleter/
var time = $('.running-time').map(function () {
return $(this).text().replace(/([^0-9:]+)/gi, '').split(':').reverse().reduce(function (prev, curr, i) {
return prev + curr * Math.pow(60, i)
}, 0);
}).get().reduce(function (a, b) {
return a + b
}, 0);
function format(time) {

Keybase proof

I hereby claim:

  • I am eoghanobrien on github.
  • I am eoghanobrien (https://keybase.io/eoghanobrien) on keybase.
  • I have a public key whose fingerprint is B456 8F9E E822 E5D2 E43B 173A 291C 8BAD B8AF A33E

To claim this, I am signing this object:

@eoghanobrien
eoghanobrien / ee_modify_timestamp.php
Created August 3, 2013 10:09
ExpressionEngine's Localize class currently lacks a method to modify a timestamp while keeping the member's localization settings in-tact. Adding this method around line 90 to to the file /system/expressionengine/libraries/Localize.php fixes that issue. Usage: $tomorrow = ee()->localize->modify_timestamp('+1 day');
/**
* Given a modification like +1 day or -2 weeks and a Unix timestamp,
* returns the modified timestamp in the specified timezone or member's
* current timezone.
*
* @param string Modificiation like +1 day
* @param int Unix timestamp
* @param bool Return date localized or not
* @return string Formatted date
*/
@eoghanobrien
eoghanobrien / asana-status-board-display.php
Last active December 17, 2015 06:19
Grabbing Project Tasks from Asana API
<table id="projects">
<?php foreach ($data as $project): ?>
<tr>
<td class="projectName">
<?php echo $project['name']; ?>
</td>
<td class="projectVersion noresize">
<?php echo sprintf('%s/%s', $project['completedCount'], $project['totalCount']); ?>
</td>
<td class="projectsBars">
@eoghanobrien
eoghanobrien / install_laravel_boilerstrap.sh
Created February 9, 2013 19:40
Install the laravel-boilerstrap via shell
#!/bin/bash
echo "Please enter the directory you want to git clone laravel-boilerstrap into:"
read target_dir
git clone git@github.com:eoghanobrien/laravel-boilerstrap.git $target_dir
cd $target_dir
@eoghanobrien
eoghanobrien / Fresh\View
Created October 20, 2012 14:27
PHP View Class
<?php
/**
* Fresh Framework (http://framework.freshmedia.ie/)
*
* @link http://github.com/eoghanobrien/fresh for the canonical source repository
* @copyright Copyright (c) 2005-2012 Fresh Media (http://www.freshmedia.ie)
* @license http://framework.freshmedia.ie/license/new-bsd New BSD License
* @package Fresh_View
*/
@eoghanobrien
eoghanobrien / gist:2653112
Created May 10, 2012 13:50
recursive array search,
function recursive_array_search($array, $key_string) {
foreach (explode('/', $key_string) as $key) {
if (preg_match('@(?<=\[)([0-9]+)(?=\])@', $key, $key_indexes)) {
$key_index = $key_indexes[0];
$array = (isset($array[$key_index])) ? $array[$key_index] : "";
} else {
$array = (isset($array[$key])) ? $array[$key] : "";
}
}
return $array;
@eoghanobrien
eoghanobrien / toSlug
Created May 5, 2012 13:44
Modifies a string to remove all non ASCII characters and spaces.
/**
* Modifies a string to remove all non ASCII characters and spaces.
* Note : Works with UTF-8
*
* @param string $string The text to slugify
* @return string The slugified text
*/
function toSlug ($string) {
$string = utf8_decode($string);
$string = html_entity_decode($string);
@eoghanobrien
eoghanobrien / google-chart-column.html
Created February 21, 2012 00:13
Google Chart API Column Chart
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Google Chart API - Column Chart</title>
</head>
<body>
<div id="chart-div-days"></div>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
@eoghanobrien
eoghanobrien / staticBlock.php
Created November 2, 2011 18:15
Adding a static block to a template
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('identifier')->toHtml() ?>