This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function displayage( yr, mon, day, unit, decimal, round ) { | |
//Sample usage | |
//displayage (year, month, day, unit, decimals, rounding) | |
//Unit can be "years", "months", or "days" | |
//Decimals specifies demical places to round to (ie: 2) | |
//Rounding can be "roundup" or "rounddown" | |
//displayage(1997, 11, 24, "years", 0, "rounddown") | |
today = new Date(); | |
yr = parseInt(yr, 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); | |
class MY_DB_mysql_driver extends CI_DB_mysql_driver { | |
final public function __construct($params) { | |
parent::__construct($params); | |
} | |
/** | |
* Insert_On_Duplicate_Update_Batch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Trigger any custom bindings on after | |
(function($) { | |
var origAfter = $.fn.after; | |
$.fn.after = function () { | |
return origAfter.apply(this, arguments).trigger("after"); | |
}; | |
})(jQuery); | |
// Bind 'after' and then use it to trigger function_to_trigger() | |
$('.element').bind("after", function() { function_to_trigger(); } }).after('<ul></ul>'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set the local time offset to display time values in the users local time | |
*/ | |
function setTimeOffset() { | |
// Create all the dates necessary | |
var now = later = d1 = d2 = new Date(), | |
set = { 'offset': now.getTimezoneOffset(), 'dst': 0 } | |
// Set time for how long the cookie should be saved - 1 year | |
later.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); | |
// Date one is set to January 1st of this year |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Key Terms | |
* | |
* Determines the key terms in a provided $content string and returns the $return most popular terms. This works by | |
* clearing all the most common words from the content and counting the number of occurrences of what's left. We then | |
* find all phrases that contain any of those words that occurred more than once in an attempt to isolate the most | |
* important phrases. The number of terms returned can also be set or set to 0 to return all matches. If there's room | |
* for more returned results ($results has to be greater than zero) then we gather the most used words not in an | |
* existing phrase and fill the returned array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* IP Address Match | |
* | |
* Takes an $ipAddress as a string and an array of IP Addresses and/or IP wildcards $toMatch it with, returns boolean | |
* true if a match is found and false otherwise | |
* | |
* @param string $ipAddress | |
* @param array $toMatch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$env = $app->detectEnvironment(function(){ | |
// For artisan commands, default to localhost | |
$serverName = 'localhost'; | |
if ( isset($_SERVER["SERVER_NAME"]) && strlen($_SERVER["SERVER_NAME"]) > 0 ){ | |
$serverName = $_SERVER["SERVER_NAME"]; | |
} | |
// List of environments with the server name as the key | |
$serverNames = array( | |
'staging.net' => 'staging', | |
'productionserver.com' => 'production' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dd(DB::getQueryLog()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return an error if $value day is today | |
Validator::extend('before_today', function($attribute, $value, $parameters) { | |
if ( strtotime( $value ) >= strtotime( date("Y-m-d") ) ) { | |
return false; | |
} | |
return true; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return an error if $value was found in a record from today | |
Validator::extend('unique_today', function($attribute, $value, $parameters) { | |
if ( $this->findAll( null, array( $attribute => $value, 'from' => date('Y-m-d') ) )->count() ) { | |
return false; | |
} | |
return true; | |
}); | |
Validator::replacer('unique_today', function($message, $attribute, $rule, $parameters) { | |
return Lang::get('error_enteredtoday', array('attribute' => $attribute)); | |
}); |
OlderNewer