View multilinestrings.js
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
/** | |
* See: https://github.com/isaacs/node-tap/blob/master/bin/tap.js#L65 | |
*/ | |
console.log({/* | |
This is a multiline string. | |
That is, a single string, spread out over many lines, | |
without the need to escape quotes or end-of-line | |
characters. |
View gitzip.sh
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"; } |
View test-21-actual.html
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> |
View actual-output-2.html
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> |
View drupal-sf-touch.js
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"); | |
View gist:3417835
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' ); |
View uploadables.php
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' | |
); |
View sweet-git-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
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 |
View print_gh_markdown.js
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:(function(e,a,g,h,f,c,b,d)%7Bif(!(f=e.jQuery)%7C%7Cg>f.fn.jquery%7C%7Ch(f))%7Bc=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function()%7Bif(!b&&(!(d=this.readyState)%7C%7Cd=="loaded"%7C%7Cd=="complete"))%7Bh((f=e.jQuery).noConflict(1),b=1);f(c).remove()%7D%7D;a.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window,document,"1.3.2",function($,L)%7B$('%23header, .pagehead, .breadcrumb, .commit, .meta, %23footer, %23footer-push, .wiki-actions, %23last-edit, .actions, .header, .repository-sidebar, .file-navigation, .site-footer, .repository-meta, .overall-summary, .files-bubble').remove(); $('%23files, .file').css(%7B"background":"none", "border":"none"%7D); $('link').removeAttr('media');%7D);void(0); |
View hsl2rgb
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
HOW TO RETURN hsl.to.rgb(h, s, l): | |
SELECT: | |
l<=0.5: PUT l*(s+1) IN m2 | |
ELSE: PUT l+s-l*s IN m2 | |
PUT l*2-m2 IN m1 | |
PUT hue.to.rgb(m1, m2, h+1/3) IN r | |
PUT hue.to.rgb(m1, m2, h ) IN g | |
PUT hue.to.rgb(m1, m2, h-1/3) IN b | |
RETURN (r, g, b) |
OlderNewer