This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.
— Erik
/** | |
* Set of funcitons that trims a string in Javascipt :) | |
**/ | |
function trim(stringToTrim) { | |
return stringToTrim.replace(/^\s+|\s+$/g,""); | |
} | |
function ltrim(stringToTrim) { | |
return stringToTrim.replace(/^\s+/,""); | |
} |
<?php | |
function _mem($val = null) | |
{ | |
$val = ($val) ? $val : memory_get_peak_usage(true) | |
$unit=array('B','KB','MB','GB','TB','PB'); | |
return @round($val/pow(1024,($i=floor(log($val,1024)))),2).' '.$unit[$i]; | |
} | |
echo _mem(); |
Most times you can get a reference to an object using document.getElementById("myID"). However, there are certain situations where an alternate method is required. For example, if there is no ID because the object you are trying to retrieve isn't an HTML element and perhaps the name of the object isn't known until run-time. | |
If the object name is known at design-time, you can easily refer to the object using dot notation. Dot notation is a way to traverse the Document Object Model (DOM) to find the object you're looking for. For example: | |
CODE | |
document.formName.fieldName.value | |
What you may not be aware of is that you can also refer to objects like you would with an associative array: | |
CODE | |
document.formName["fieldName"].value | |
Or: |
var normalize = (function() { | |
var from = "ÃÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛãàáäâèéëêìíïîòóöôùúüûÑñÇç", | |
to = "AAAAAEEEEIIIIOOOOUUUUaaaaaeeeeiiiioooouuuunncc", | |
mapping = {}; | |
for(var i = 0, j = from.length; i < j; i++ ) | |
mapping[ from.charAt( i ) ] = to.charAt( i ); | |
return function( str ) { | |
var ret = []; |
// en jquery... | |
var newObj = jQuery.extend(true, {}, oldObj), | |
// en js... | |
http://stackoverflow.com/questions/728360/most-elegant-way-to-clone-a-javascript-object |
# Mensajes de los commits entre fechas por usuario :) | |
git log --pretty=format:'%s' --author='oscar' --since "JUL 29 2010" --until="JUL 10 2013" ; | |
# Reset a commit (con remote repo incluido :)) | |
git reset HEAD^ # remove commit locally | |
git push origin +HEAD # force-push the new HEAD commit |
The OSX PHP is located in /usr/bin/php and /usr/bin is in PATH variable by default. | |
One way to make OSX use MAMP PHP is to add /Applications/MAMP/bin/php/php5.x.x/bin/ to your PATH variable (before /usr/bin): | |
Simply edit ~/.profile (ie. open Terminal.app, type vim ~/.profile) and add the following line to end of the file: | |
export PATH=/Applications/MAMP/bin/php/php5.x.x/bin/:$PATH | |
Note that you should replace xs in php5.x.x with the MAMP Pro PHP version |
var BrowserDetect = { | |
init: function () { | |
this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; | |
this.version = this.searchVersion(navigator.userAgent) | |
|| this.searchVersion(navigator.appVersion) | |
|| "an unknown version"; | |
this.OS = this.searchString(this.dataOS) || "an unknown OS"; | |
}, | |
searchString: function (data) { | |
for (var i=0;i<data.length;i++) { |
var lastScrollLeft = 0; | |
$(window).scroll(function() { | |
var documentScrollLeft = $(document).scrollLeft(); | |
if (lastScrollLeft != documentScrollLeft) { | |
console.log('scroll x'); | |
lastScrollLeft = documentScrollLeft; | |
} | |
}); |