Skip to content

Instantly share code, notes, and snippets.

@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"
@natos
natos / dabblet.css
Created August 7, 2013 15:26
Untitled
h1 {
font-size: 32px
}
@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,
// 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;
<!-- 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 -->
// 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
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"
$(function() {
// Depends on: jQuery, jQuery UI core & widgets (for the autocomplete method)
// Assumes you're already including the FB JS SDK asynchronously...
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxxxxxxx', // App ID
status : true, // check login status
@natos
natos / sortByDateTiem
Last active February 27, 2016 11:01
Sort array by datetime
// Let's say you have collection of things, like:
var collection = [
{name: '#1 thing', time: '2012-03-16T07:22Z'},
{name: '#2 thing', time: '2012-03-15T12:00Z'},
{name: '#3 thing', time: '2012-03-17T20:25Z'},
{name: '#4 thing', time: '2012-03-13T13:45Z'}
];
// the sorting function
function sortByDateTime(a, b) {