Skip to content

Instantly share code, notes, and snippets.

View naoxink's full-sized avatar
😃
Coding

J. Gabriel Corpas naoxink

😃
Coding
View GitHub Profile
@naoxink
naoxink / createIterator.js
Last active July 11, 2018 07:46
Simple iterator in Javascript
function createIterator(array){
var index = -1
var hasNext = function(){
return (index + 1) < array.length
}
var hasPrev = function(param){
return (index - 1) < array.length && (index - 1) > -1
}
@naoxink
naoxink / customElements.html
Created July 12, 2018 10:20
TEST Custom Web Elements
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>TEST Custom Elements</title>
<style>body{text-align: center;}</style>
</head>
<body>
<template id="clickBtn">
@naoxink
naoxink / addVirtualProperty.js
Created July 17, 2018 08:44
`Object.defineProperty` calculated property test
function addVirtualProperty(options){
if(!options.obj || typeof options.obj !== 'object'){
throw new Error('Expected `obj`[Object object]')
}
if(!options.prop){
throw new Error('Expected `prop`')
}
Object.defineProperty(options.obj, options.prop, {
get(){
return options.getter.call(options.obj)
@naoxink
naoxink / print_array.php
Last active July 17, 2018 08:54
print_array PHP
<?php
/**
* Imprime un array en consola con otro formato
* @param array $array
* @param integer $lvl
* @param integer $keylen
* @param integer $actual_spaces
*/
function print_array($array, $lvl = 0, $keylen = 0, $actual_spaces = 0){
if($lvl == 0){
@naoxink
naoxink / getType.js
Last active September 26, 2018 12:13
Utility to check variable types easy
function getType(x){
return Object.prototype.toString.call(x).toLowerCase().replace(/\[(.*)\s|\]$/g, '')
}
// Types (all strings):
//
// number
// string
// boolean
// date