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
// Adapted from: http://bateru.com/news/2011/11/improved-code-for-javascript-decimal-to-fraction/ | |
function gcd(a, b) { | |
return (b) ? gcd(b, a % b) : a; | |
} | |
var decimalToFraction = function (_decimal) { | |
var top = _decimal.toString().replace(/\d+[.]/, ''); | |
var bottom = Math.pow(10, top.length); | |
if (_decimal > 1) { |
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 | |
//Magento DB connection | |
include("/path/to/app/Mage.php"); | |
$app = Mage::app('default'); | |
$db = Mage::getSingleton('core/resource')->getConnection('core_read'); | |
?> |
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
/** | |
* We're going to create an infinite loading table view. Whenever you get close to the bottom, we'll load more rows. | |
*/ | |
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); | |
var isAndroid = Ti.Platform.osname === 'android'; | |
/** | |
* Create our UI elements. | |
*/ | |
var table = Ti.UI.createTableView({ top: 0, right: 0, bottom: 0, left: 0 }); |
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 calculateResize (_params) { | |
var ratio = 0; | |
var output = { | |
width : _params.current_width, | |
height : _params.current_height | |
}; | |
if(_params.current_width > _params.max_width){ | |
ratio = _params.max_width / _params.current_width; | |
output.width = parseInt(_params.max_width, 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
<!-- US States Drop Down Select List --> | |
<select id="ddl_state" name="ddl_state"> | |
<option value="AL" selected="selected">Alabama</option> | |
<option value="AK">Alaska</option> | |
<option value="AZ">Arizona</option> | |
<option value="AR">Arkansas</option> | |
<option value="CA">California</option> | |
<option value="CO">Colorado</option> | |
<option value="CT">Connecticut</option> |
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
$('#myField').bind('keyup', function (e) { | |
$(this)[0].value = $(this)[0].value.replace(/[^0-9\.]/g, ''); | |
}); |
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 headers = [ | |
{"Authentication" : "AUTH_KEY"}, | |
{"rememberMe" : true} | |
]; | |
// =============================================================== | |
for (var i = 0, j = headers.length; i < j; i = i + 1) { | |
Object.keys(headers[i]).forEach(function (header) { | |
console.log(header + ' = ' + headers[i][header]); |
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
tail -f filename.log |
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
<!-- US States Drop Down Select List --> | |
<select id="ddl_state" name="ddl_state"> | |
<option value="Alabama" selected="selected">Alabama</option> | |
<option value="Alaska">Alaska</option> | |
<option value="Arizona">Arizona</option> | |
<option value="Arkansas">Arkansas</option> | |
<option value="California">California</option> | |
<option value="Colorado">Colorado</option> | |
<option value="Connecticut">Connecticut</option> |
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
mysqldump --opt -u dbuser -p dbname > filename.back.dump |
NewerOlder