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 UsersController extends AppController { | |
[...] | |
$this->User->setValidationRule('account'); | |
[...] | |
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 | |
/** | |
* 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 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 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 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 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 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 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 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 |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>CSS drop-shadows</title> | |
<style> | |
body { | |
padding:20px 0 30px; | |
font:14px/1.5 Arial, sans-serif; | |
text-align:center; |