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
#!/bin/bash | |
## | |
## I usually put this in my .bashrc | |
## | |
## When in a git project dir, run 'gitzip foo' to get a 'foo.zip' in the parent | |
## directory. | |
gitzip() { git archive HEAD --format=zip --prefix="$*/" > ../"$*.zip"; } |
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
## Auto-restart PHP when it's returning errors | |
# | |
# Make sure that http://localhost/test.php is an actual PHP script. If it starts returning | |
# 500 errors, restart the PHP-FPM service | |
* * * * * /usr/bin/curl --head -sf http://localhost/test.php -o /dev/null || /usr/sbin/service php5-fpm restart |
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
javascript:$=jQuery;if(0!==$("#myogdiv").length)$("#myogdiv").hide().remove();else{var%20myogdiv=$('<div%20id="myogdiv"/>');$("body").append(myogdiv);$('head%20meta[property^="og:"],head%20meta[property^="fb:"],head%20meta[name^="twitter:"]').each(function(d,b){var%20a=$(b).attr("property"),c=$(b).attr("content");void%200==a&&(a=$(b).attr("name"));$(myogdiv).append("<div><b>"+a+":</b>"+c+"</div>");"og:image"==a&&$(myogdiv).append('<br/><img%20src="'+c+'"%20style="max-width:250px"/>');"twitter:image"==a&&$(myogdiv).append('<br/><img%20src="'+c+'"%20style="max-width:250px"/>')});$(myogdiv).css("position","absolute").css("top","0").css("zIndex",9999999).css("padding","0.5em").css("border","1px%20solid%20red").css("backgroundColor","white")}void%200; |
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
/** | |
* encode to handle invalid UTF | |
* | |
* If Chrome tells you "Could not decode a text frame as UTF-8" when you try sending | |
* data from nodejs, try using these functions to encode/decode your JSON objects. | |
* | |
* see discussion here: http://code.google.com/p/v8/issues/detail?id=761#c8 | |
* see also, for browsers that don't have native JSON: https://github.com/douglascrockford/JSON-js | |
* | |
* Any time you need to send data between client and server (or vice versa), encode before sending, |
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
<div id="entries"> | |
<div class="entry"> | |
<div class="created">2001-01-01</div> | |
<div class="user"> | |
<div class="name">John Q. User</div> | |
<div class="city">Atlanta</div> | |
<div class="state">GA</div> | |
</div> | |
<div class="custid"></div> | |
</div> |
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
<div id='complex'> | |
<div class='one'>subvalue one</div> | |
<div class='two'>subvalue two</div> | |
</div> | |
<div id='simple'></div> | |
<div id='simple'>simple value</div> |
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://snippets.webaware.com.au/snippets/make-css-drop-down-menus-work-on-touch-devices/ | |
Drupal.behaviors.touchdevice_dropdowns = function(context) { | |
// see whether device supports touch events (a bit simplistic, but...) | |
var hasTouch = ("ontouchstart" in window); | |
// hook touch events for drop-down menus | |
if (hasTouch && document.querySelectorAll) { | |
var i, len, element, | |
dropdowns = document.querySelectorAll(".sf-menu .menuparent > a"); | |
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
/** | |
* Get a single text value for a post custom field in WordPress, bypassing the normal array return. | |
* | |
* From a discussion on Twitter, which prompted me to post this. Many people seem to be | |
* unaware of PHP's `list()` operator (it's not, technically, a function). | |
* | |
* If you are not in the loop, you can pass a post ID as a second parameter. | |
*/ | |
list( $val ) = get_post_custom_values( 'key' ); |
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
/** | |
* Add uploadable mime types / file extensions | |
*/ | |
function dc_add_uploadables($arr = array()) { | |
$new = array( | |
// Add file extension => mime type mapping here | |
'keynote|key' => 'application/vnd.apple.keynote', | |
'numbers' => 'application/vnd.apple.numbers', | |
'pages' => 'application/vnd.apple.pages' | |
); |
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
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative" | |
# use: git lg |
OlderNewer