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
// Run with node server.js | |
var cfg = { | |
http: { | |
port: 3333, | |
host: '127.0.0.1' | |
} | |
} | |
var http = require('http'); | |
http.createServer(function(req, res) { |
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://stackoverflow.com/a/1830844/129698 | |
if ( !isNaN(parseFloat(variable)) && isFinite(variable) ) { | |
// Do something | |
} |
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
// From JSON | |
var jsObject = JSON.parse(jsonString); | |
// To JSON | |
var jsonString = JSON.stringify(foo); |
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
RequestHeader set Authorization "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" |
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
/* | |
* base64.js: An extremely simple implementation of base64 encoding / decoding using node.js Buffers | |
* | |
* (C) 2010, Nodejitsu Inc. | |
* | |
*/ | |
var base64 = exports; | |
base64.encode = function (unencoded) { |
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
RewriteRule \.(css|jpe?g|gif|png)$ - [L] | |
... | |
RewriteCond %{REQUEST_FILENAME} !-f | |
... |
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
App.prototype.settings = { | |
linkSelector: 'a', | |
formSelector: 'form', | |
throwErrors: true, | |
handleRouteNotFound: false, | |
generateRequestOnPageLoad: true | |
}; |
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
<img class="hires" alt="" src="search.png" width="100" height="100" /> | |
<script type="text/javascript"> | |
$(function () { | |
if (window.devicePixelRatio == 2) { | |
var images = $("img.hires"); | |
// loop through the images and make them hi-res | |
for(var i = 0; i < images.length; i++) { |
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
// Asynchronously load and execute a script from a specified URL | |
// Lifted from JavaScript: The Definitive Guide, 6th edition, p. 320 | |
function loadasync(url) { | |
var head = document.getElementsByTagName("head")[0]; // Find document <head> | |
var s = document.createElement("script"); // Create a <script> element | |
s.src = url; // Set its src attribute | |
head.appendChild(s); // Insert the <script> into head | |
} |
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 can define variables to be used in media queries | |
@singleQuery: ~"(max-width: 500px)"; | |
@media screen, @singleQuery { | |
set { | |
padding: 3 3 3 3; | |
} | |
} | |
// Which can lead to inline media queries that use variables for targets | |
@device1: ~'min-width: 768px AND max-width: 999px'; |
OlderNewer