Skip to content

Instantly share code, notes, and snippets.

View MarcelloDiSimone's full-sized avatar

Marcello di Simone MarcelloDiSimone

  • Synios.de
  • Hamburg Germany
View GitHub Profile
@MarcelloDiSimone
MarcelloDiSimone / Gruntfile.js
Last active December 17, 2015 15:28
Modular Grunt.js config
'use strict';
var path = require('path'),
fs = require('fs'),
matchdep = require('matchdep');
module.exports = function (grunt) {
var gruntConfig = {
pgk: grunt.file.readJSON('package.json');
};
@MarcelloDiSimone
MarcelloDiSimone / gist:5532665
Last active December 14, 2021 22:50
Display elements inside a specific position range
<!DOCTYPE html>
<html>
<head>
<style>
html,
body {
height: 100%;
width: 100%;
}
.wrapper {
@MarcelloDiSimone
MarcelloDiSimone / array_traverse.js
Last active May 8, 2022 21:26
Taverse an Array circularly in both direction by adding prev and next methods to the Array prototype
function ExtendedArray() {
let arr = [];
arr.push.apply(arr, arguments);
arr.pos = 0;
arr.prev = function () {
return this[this.pos = (this.pos || this.length)-1];
};
arr.next = function () {
return this[this.pos = (++this.pos % this.length)];
};
@MarcelloDiSimone
MarcelloDiSimone / Prototyper.js
Last active December 11, 2015 11:19
A prototype inheritance helper
Prototyper = {};
Prototyper.create = function (base) {
var empty = function () {};
empty.prototype = base;
return new empty();
};
Prototyper.xtends = function (parent, instance) {
instance.prototype = this.create(parent.prototype);
instance.prototype.constructor = instance;
instance.prototype.__super__ = parent;