Skip to content

Instantly share code, notes, and snippets.

// early experiments with node had mysterious double requests
// turned out these were for the stoopid favicon
// here's how to short-circuit those requests
// and stop seeing 404 errors in your client console
var http = require('http');
http.createServer(function (q, r) {
// control for favicon
<!-- Favicons and touch icons -->
<!-- For retina-display iPads -->
<link href="/assets/images/apple-touch-icon-xlarge.png" rel="apple-touch-icon-precomposed" sizes="144x144" type="image/png"/>
<!-- For retina-display iPhones -->
<link href="/assets/images/apple-touch-icon-large.png" rel="apple-touch-icon-precomposed" sizes="114x114" type="image/png"/>
<!-- For iPad 1 -->
<link href="/assets/images/apple-touch-icon-medium.png" rel="apple-touch-icon-precomposed" sizes="72x72" type="image/png"/>
<!-- For iPhone 3G, iPod Touch and Android -->
<link href="/assets/images/apple-touch-icon-small.png" rel="apple-touch-icon-precomposed" type="image/png"/>
<!-- For Nokia -->
// currying example
function add(n) {
// save results
var r = 0;
// the real deal
function _add(n) {
r += n;
document.getElementById('r').innerHTML = r;
// return add interface
return _add;
@natos
natos / api_example.js
Last active February 27, 2016 11:40
JavaScript API example
var API = (function () {
// private scope
var API_PREFIX = 'http://api.myapp.com';
// request helper
function _request (method, resource, data, succes, error) {
// use your favorite library here
// or just vanilla...
var options = {
url: API_PREFIX + resource,
type: method,
@natos
natos / dabblet.css
Created August 7, 2013 15:26
Untitled
h1 {
font-size: 32px
}
@natos
natos / nodejs
Last active August 29, 2015 14:08
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"