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
/* | |
Given a date, tzAbbr returns a short, friendly name for the | |
user's time zone on that date, or an empty string if their | |
client's Intl support is missing or incomplete. | |
For example, a user in New York might see: | |
tzAbbr(new Date()) // => "EST" | |
Time zones are locale-dependent. Users traveling outside of |
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 | |
App::uses('FormAuthenticate', 'Controller/Component/Auth'); | |
class HashFormAuthenticate extends FormAuthenticate { | |
/** | |
* Find a user record given a username and unhashed password. | |
* | |
* @param string $username The username/identifier. | |
* @param string $password The unhashed password. |
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 | |
/** | |
* Custom Route class that restricts a route to a single extension. | |
* Enables you to build controller actions that are only applied to specific | |
* extensions, e.g., '/posts.json' goes to PostsController::index_json while | |
* '/posts' goes to PostsController::index. | |
* | |
* To use, drop this into app/libs/routes/extension_specific_route.php and add | |
* the following to the top of app/config/routes.php: | |
* |
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 | |
/** | |
* Behavior to stop CakePHP from including virtual fields unless they're | |
* explicitly requested in the fields array. | |
* | |
* To find out more about virtual fields, consult the documentation in the | |
* manual here: | |
* | |
* http://book.cakephp.org/view/1608/Virtual-fields | |
* |
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 | |
/** | |
* Behavior to enhance CakePHP ContainableBehavior by respecting default Model order | |
* | |
* Makes ContainableBehavior respect Model::order when no other order is specified in | |
* the containment. Must be placed before ContainableBehavior in the actsAs array of | |
* the Model being queried, like so: | |
* | |
* var $actsAs = array('OrderedContainable', 'Containable'); | |
* |
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
// jQuery plugin based on .load() for use with innerShiv | |
// http://jdbartlett.github.com/innershiv for more info | |
// $('selector').loadShiv('example.html selector'); | |
jQuery.fn.loadShiv = function (url, params, callback) { | |
var off, selector, self, type; | |
if (!this.length || typeof url !== 'string') { | |
return this; | |
} |
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
# This is a template .gitignore file for git-managed WordPress projects. | |
# | |
# Fact: you don't want WordPress core files, or your server-specific | |
# configuration files etc., in your project's repository. You just don't. | |
# | |
# Solution: stick this file up your repository root (which it assumes is | |
# also the WordPress root directory) and add exceptions for any plugins, | |
# themes, and other directories that should be under version control. | |
# | |
# See the comments below for more info on how to add exceptions for your |
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
var suffix = function(n) { | |
var d = (n|0)%100; | |
return d > 3 && d < 21 ? 'th' : ['th', 'st', 'nd', 'rd'][d%10] || 'th'; | |
}; | |
// suffix(1) => "st" | |
// suffix(102) => "nd" | |
// suffix(113) => "th" |
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
var to12Hr = function(n, r /* round to nearest r minutes */) { | |
if (!n || n >= 24) return '12:00 AM'; | |
var m = (Math.round(n%1 * (r = (r ? 60/r : 60))) / r) * 60 | 0; | |
return ((n = (m>59 ? n+1 : n))>=13 ? (n|0)-12 : n|0) + ':' + (m>9 ? (m>59 ? '00' : m) : '0'+m) + (n>=12 && m<60 ? ' PM' : ' AM'); | |
} | |
// to12Hr(6.5) => "6:30 AM" | |
// to12Hr(13.19) => "1:11 PM" | |
// to12Hr(13.19, 15) => "1:15 PM" (rounds to 15 mins) |
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 | |
class TimezonesHelper extends AppHelper { | |
function show() { | |
$zones = array( | |
'Pacific/Apia' => 'Apia, Upolu, Samoa', // UTC-11:00 | |
'US/Hawaii' => 'Honolulu, Oahu, Hawaii, United States', // UTC-10:00 | |
'US/Alaska' => 'Anchorage, Alaska, United States', // UTC-09:00 | |
'US/Pacific' => 'Los Angeles, California, United States', // UTC-08:00 | |
'US/Mountain' => 'Phoenix, Arizona, United States', // UTC-07:00 |
NewerOlder