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
| /** | |
| * @author Joshua Heller | |
| */ | |
| function hasClass(ele, cls) { | |
| return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')); | |
| } | |
| function addClass(ele, cls) { | |
| if (!this.hasClass(ele, cls)) | |
| ele.className += " " + cls; |
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
| /** | |
| * toggleClass() | |
| * Expects parameters | |
| * elem = DOM element (object, instanceof HTMLElement) | |
| * cl = Class name (string) | |
| */ | |
| var toggleClass = function(elem, cl) { | |
| if (elem.className.indexOf(cl) != -1) { | |
| elem.className = elem.className.replace(cl, ''); | |
| } else { |
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
| add_filter('the_content', 'remove_empty_p', 20, 1); | |
| function remove_empty_p($content){ | |
| $content = force_balance_tags($content); | |
| return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content); | |
| } |
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
| To find the largest 10 files (linux/bash): | |
| find . -type f -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {} | |
| To find the largest 10 directories: | |
| find . -type d -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {} | |
| Alternatively or a quick view: |
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
| List open ports on Mac OS X | |
| sudo lsof -i -P | grep -i "listen" | |
| --- Suspende node servers --- | |
| ctrl-z suspends it, which means it can still be running. | |
| ctrl-c will actually kill it. |
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 grep -qIP '\r\n' {} ';' -exec perl -pi -e 's/\r\n/\n/g' {} '+' |
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 ~/Sites/testsite -type f -exec dos2unix {} + |
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
| wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains thewebsite.com --no-parent www.thewebsite.com | |
| wget --recursive --no-clobber --page-requisites --html-extension --convert-links www.thewebsite.com |
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 | |
| /* | |
| Plugin Name: Instrument Hooks for WordPress | |
| Description: Instruments Hooks for a Page. Outputs during the Shutdown Hook. | |
| Version: 0.1 | |
| Author: Mike Schinkel | |
| Author URI: http://mikeschinkel.com | |
| */ | |
| if (isset($_GET['instrument']) && $_GET['instrument']=='hooks') { |
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
| // Avoid `console` errors in browsers that lack a console. | |
| if (!(window.console && console.log)) { | |
| (function() { | |
| var noop = function() {}; | |
| var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn']; | |
| var length = methods.length; | |
| var console = window.console = {}; | |
| while (length--) { | |
| console[methods[length]] = noop; | |
| } |
OlderNewer