This file contains hidden or 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 | |
// Includes text RGB to show text as white or black. This value was calculated using; | |
// $brightness = sqrt( (R * R * .299) + (G * G * .587) + (B * B * .114) ) | |
// If $brightness was greater than 130, then the text was set to white | |
$ral_colours => array( | |
'RAL 1000' => array( | |
'rgb' => '190,189,127', | |
'name' => 'Green Beige', |
This file contains hidden or 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 UsersController extends AppController { | |
[...] | |
$this->User->setValidationRule('account'); | |
[...] | |
This file contains hidden or 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 | |
/** | |
* Pretty accurate way of calculating the Luma (Brightness) value | |
* | |
* @param array|int|false $r | |
* @param int|false $g | |
* @param int|false $b | |
* @return int | |
*/ |
This file contains hidden or 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 | |
// Sorting a multi-dimensional array (of objects), by price | |
usort($products, function($a, $b) { | |
$a = (object) $a; | |
$b = (object) $b; | |
if ($a->price == $b->price) { | |
return 0; | |
} else { | |
// return $a->price > $b->price ? -1 : 1; // DESC | |
return $a->price > $b->price ? 1 : -1; // ASC |
This file contains hidden or 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
<a href="delete?id=1" class="confirm">Delete 1</a> | |
<a href="delete?id=2" class="confirm">Delete 2</a> | |
<a href="delete?id=3" class="confirm">Delete 3</a> | |
<div class="modal hide fade" id="confirm-delete" role="dialog" aria-labelledby="confirm-delete-header" aria-hidden="true"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | |
<h3 id="confirm-delete-header">Delete Confirmation</h3> | |
</div> | |
<div class="modal-body"> |
This file contains hidden or 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
find . -type f -exec chmod 644 {} \; | |
find . -type d -exec chmod 755 {} \; | |
chmod 550 pear | |
chmod 550 mage | |
chmod -R 777 media var |
This file contains hidden or 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
version=1.7.0.2 | |
wget http://www.magentocommerce.com/downloads/assets/$version/magento-$version.tar.gz | |
tar -zxvf magento-$version.tar.gz | |
mv magento/* magento/.htaccess . | |
chmod -R o+w media var | |
chmod o+w app/etc | |
rm -rf magento/ magento-$version.tar.gz | |
rm -rf index.php.sample LICENSE.txt LICENSE.html LICENSE_AFL.txt php.ini.sample RELEASE_NOTES.txt |
This file contains hidden or 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
$.ajax({ | |
url: 'http://www.website.com/ajax', | |
data: '&ajaxcmd=getSomeInfo&id=' + id, | |
dataType: 'html', | |
success:function(output){ | |
var regex = /^\s*$/; | |
if(regex.test(output)) { | |
alert('Empty response'); | |
} else { | |
alert('Not empty'); |
This file contains hidden or 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
/* | |
The jQuery Mobile "loading" message allows users to click on UI items around it | |
Using Mike Alsup's BlockUI, we can stop this | |
http://jquery.malsup.com/block/#download | |
Thanks to MorningZ | |
https://gist.github.com/MorningZ | |
*/ | |
// Add this right before the closing <body> tag |
This file contains hidden or 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
// www.website.com/page?id=100 | |
$('#pageLink').attr('href', $('#pageLink').attr('href').replace(/((\?|&)id\=)[0-9]*/, '$1' + '123')); | |
// www.website.com/page?id=123 |