Skip to content

Instantly share code, notes, and snippets.

View nodejs
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"
View dabblet.css
h1 {
font-size: 32px
}
@natos
natos / api_example.js
Last active Feb 27, 2016
JavaScript API example
View api_example.js
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,
View currying_example.js
// 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;
View favicon.html
<!-- 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 -->
View favicon-interceptor.js
// 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
View nginx.conf
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;
View nodejs
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"
View gist:4486127
$(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 Feb 27, 2016
Sort array by datetime
View sortByDateTiem
// 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) {