Skip to content

Instantly share code, notes, and snippets.

View arpo's full-sized avatar

Mattias Johansson arpo

View GitHub Profile
@arpo
arpo / json-pretty
Created October 9, 2017 11:49
Pretty-print JSON using JavaScript
JSON.stringify(jsObj, null, "\t"); // stringify with tabs inserted at each level
JSON.stringify(jsObj, null, 4); // stringify with 4 spaces at each level
@arpo
arpo / server.js
Created August 14, 2017 09:50
A basic server for node js
var http = require('http');
var fs = require('fs');
var path = require('path');
var port = 3000;
http.createServer(function (request, response) {
//console.log('request starting...');
@arpo
arpo / timelock.js
Created July 26, 2017 07:43
Timelock - Prevent something from being done to often.
var _timelock;
if (_timelock) window.clearTimeout(_timelock);
_timelock = window.setTimeout(function () {
console.log('My timeout function');
}, 500);
@arpo
arpo / 0_reuse_code.js
Created February 11, 2016 07:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console