Skip to content

Instantly share code, notes, and snippets.

View nachodd's full-sized avatar

Ignacio Durand nachodd

  • Expero
  • Rosario, Santa Fé, Argentina
View GitHub Profile
// On PhpStorm, when ussing with laravel mix, for Alias path resolving in components you have to:
// - create a webpack.config.js file separately like:
const path = require('path')
const webpack = require('webpack')
module.exports = {
...
resolve: {
extensions: ['.js', '.json', '.vue'],
<?php
class helpers {
public function uniqueCode($length = 10) {
$characters = '0123456789';
$charactersLength = strlen($characters);
while (true) {
// uniqid gives 13 chars, but you could adjust it to your needs.
if (function_exists("random_bytes")) {
$bytes = random_bytes($length);
} elseif (function_exists("openssl_random_pseudo_bytes")) {
@nachodd
nachodd / recursive_explore.php
Created November 17, 2016 13:43
Recursively walks a Collection or Array that contains children of the same kind and flatten into an single dimesion Collection or Array
<?php
// Recursively walks a Collection or Array that contains children of the same kind and flatten into an single dimesion Collection or Array.
// Example:
// We have:
// A
// |_B
// |_C
// |_D
// We want:
This is question is old but I found you can do this based on information from a tutorial by Tejas Jasani: http://www.theappguruz.com/blog/upgrading-from-laravel-4-2-to-5-in-web
Here are the key steps:
1 - Add the app/Http/Controllers directory to the "autoload" classmap directive of your composer.json file.
"autoload": {
"classmap": [
"database",
"app/Http/Controllers"
],
<?php
function utf8_converter($array) {
array_walk_recursive($array, function(&$item, $key){
if(!mb_detect_encoding($item, 'utf-8', true)){
$item = utf8_encode($item);
}
});
return $array;
}
@nachodd
nachodd / replaceClass.js
Created April 25, 2014 17:50
jQuery plugin para reemplazar una clase css
// Closure para el evitar conflicto de variables, se le pasa el obj jQuery
(function ( $ ) {
/**
* Elimina la clase que empieza con "startsWith" y añade la clase newClass (o no hace nada, si es vacia)
* @param {[string]} startsWith string con el que debe comenzar la clase a eliminar
* @param {[string]} newClass string con la nueva clase, o string vacio
* @return {[jQobj]} Objeto jQuery
*/
$.fn.replaceClass = function( startsWith, newClass ) {
// A cada uno de los elementos de la selecion ( this ), le aplica la funcion..
@nachodd
nachodd / example-modal.js
Created December 16, 2013 04:01
modal bootstrap & javascript objects
//Modal cargando
var dialogs = (function () {
var cargandoDiv = $('#cargandoDialog');
var avisoDiv = $('#modalAviso');
return {
showCargando: function() {
cargandoDiv.modal();
},
hideCargando: function () {
cargandoDiv.modal('hide');
@nachodd
nachodd / rotate.js
Created October 4, 2013 18:42
Function that shifts array positions. (see example) Funcion que rota las posiciones de un array. (ver ejemplo) FUENTE: http://stackoverflow.com/questions/1985260/javascript-array-rotate CREDITOS: http://stackoverflow.com/users/48015/christoph
/*
FUENTE: http://stackoverflow.com/questions/1985260/javascript-array-rotate
CREDITOS: http://stackoverflow.com/users/48015/christoph
*/
Array.prototype.rotate = (function() {
var unshift = Array.prototype.unshift,
splice = Array.prototype.splice;
return function(count) {
var len = this.length >>> 0,
@nachodd
nachodd / toFixedDown.js
Created October 4, 2013 18:38
Extends the Number object, adding a method to fix down some value. Extiende al objeto Number, añadiendo un metodo para redondear para abajo un valor.
Number.prototype.toFixedDown = function(digits) {
var n = this - Math.pow(10, -digits)/2;
n += n / Math.pow(2, 53); // added 1360765523: 17.56.toFixedDown(2) === "17.56"
return n.toFixed(digits);
}
@nachodd
nachodd / checkEmail.js
Created October 4, 2013 18:36
Function that checks email with regular expressions. Funcion que chequea un email a traves de una expresion regular
function checkEmail(email) {
email = email.toLowerCase();
if(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/.test(email)==false ) {
return false;
}
return t