Skip to content

Instantly share code, notes, and snippets.

Avatar

Mattias Johansson arpo

View GitHub Profile
@arpo
arpo / json-pretty
Created Oct 9, 2017
Pretty-print JSON using JavaScript
View json-pretty
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 Aug 14, 2017
A basic server for node js
View server.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 Jul 26, 2017
Timelock - Prevent something from being done to often.
View timelock.js
var _timelock;
if (_timelock) window.clearTimeout(_timelock);
_timelock = window.setTimeout(function () {
console.log('My timeout function');
}, 500);
@arpo
arpo / 0_reuse_code.js
Created Feb 11, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console