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
// You are looking for the /.../s modifier, also known as the dotall modifier. It forces the dot . to also match newlines, which it does not do by default. | |
// The bad news is that it does not exist in Javascript. The good news is that you can work around it by using a character class (e.g. \s) and its negation (\S) together, like this: | |
var htmlStringWithScriptTags = "sdf <script>test fsajkdfn</script> a sdasda <script> sdfsdfsdf \n \ | |
sdfsdfsd </script> sjkndfjkasnd <script> sdfsdfsdf \n \ | |
sdfsdfsd </script>sjkndfjkasnd <script> sdfsdfsdf \n \ | |
sdfsdfsd </script>"; | |
// incorrect | |
htmlStringWithScriptTags.replace(/<script.*?<\/script>/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
/** | |
* Truncate paragraph with an ellipsis, while specifying exactly how many lines you want | |
* source: http://dropshado.ws/post/1015351370/webkit-line-clamp | |
*/ | |
#content-body { | |
overflow : hidden; | |
text-overflow: ellipsis; | |
display: -webkit-box; |
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
sudo killall -HUP mDNSResponder |
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
<link rel="stylesheet" type="text/css" href="/css/main.<?php echo filemtime('/path/to/css/main.css'); ?>.css" /> | |
<script language="javascript" src="/js/common.<?php echo filemtime('/path/to/js/common.js'); ?>.js"> | |
</script> | |
# Add a rewrite in apache | |
RewriteRule ^(css|js)/(.*)\.[0-9]+\.(.*)$ /$1/$2.$3 [L] | |
# nginx | |
rewrite ^(css|js)/(.*)\.[0-9]+\.(.*)$ /$1/$2.$3 last; |
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
# http://blog.firsthand.ca/2011/05/compare-git-branches-compare-two-files.html | |
# diff two branches | |
$ git diff --name-status branch1..branch2 | |
# diff of a specific file between two commits/branchs | |
$ git diff feature-branch master -- myfile.css | |
$ git diff eaa241d 4d49814 -- myfile.css |
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
text-rendering: optimizeLegibility; |
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
// @example | |
// <iframe src="/form.html" id="infographic-iframe"></iframe> | |
document.getElementById('infographic-iframe').style.height = $('#infographic-iframe').contents().height() + 'px'; | |
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 | |
ini_set('display_errors',1); | |
ini_set('display_startup_errors',1); | |
error_reporting(-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
var html = '<iframe width="420" height="315" src="https://www.youtube.com/embed/cwhLueAWItA" frameborder="0" allowfullscreen></iframe>'; | |
var width = html.match( /(?:.*width="(.*?)".*)?/i ).pop(); | |
var height = html.match( /(?:.*height="(.*?)".*)?/i ).pop(); | |
var src = html.match( /(?:.*src="(.*?)".*)?/i ).pop(); | |
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 multiLiner = String() + | |
'<section>' + | |
'<div class="content-wrapper">' + | |
'<a href="#" class="js-link">Click Here</a>' + | |
'</div>' + | |
'</section>'; | |