Skip to content

Instantly share code, notes, and snippets.

View itsalb3rt's full-sized avatar
🐋

Albert E. Hidalgo Taveras itsalb3rt

🐋
View GitHub Profile
@itsalb3rt
itsalb3rt / 404_img_validator.js
Last active August 23, 2018 22:40
Cómo verificar la URL de la imagen 404 usando JavaScript
$(document).ready(function(){
/**
* Determinar si una imagen existe por la propiedad naturalHeight
* la cual sera diferente de 0 si esta existe
**/
$('img').each(function(){
if($(this)[0].naturalHeight == 0){
//Reemplazar el src con la imagen que queremos presentar
$(this).attr('src','images/image_not_found.jpg');
}
@itsalb3rt
itsalb3rt / gist:e76d9d7643174528877b3f17afd9518d
Created September 7, 2018 14:43 — forked from liamcurry/gist:2597326
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@itsalb3rt
itsalb3rt / gist:ca42372ebed045c53afb9fd4a143191f
Created November 18, 2018 03:43
Filter a html table using simple javascript, vanilla
<input type="text" id="search_input" placeholder="Search..." onkeyup="search_on_table()">
function search_on_table() {
var input, filter, table, tr, td, cell, i, j;
input = document.getElementById("search_input");
filter = input.value.toUpperCase();
table = document.getElementById("table");
tr = table.getElementsByTagName("tr");
for (i = 1; i < tr.length; i++) {
// Hide the row initially.
$obj_merged = (object) array_merge((array) $obj1, (array) $obj2);
//La documentacion oficial no indica uso
const params = new URLSearchParams();
params.append('name', name);
params.append('foo', bar);
params.append('description', description);
axios({
method: 'post',
url: 'http://localhost/controller/action',
@itsalb3rt
itsalb3rt / html
Created December 18, 2018 00:26
simple vanilla javascript slider using css
<img class="slide_image" src="some_url_img.jpg" alt="imagen login1">
<img class="slide_image" src="some_url_img.jpg" alt="imagen login2">
@itsalb3rt
itsalb3rt / css.css
Created December 18, 2018 00:44
Javascript and css slider 2
.img_container{
overflow: hidden;
max-height: 300px;
border-radius: 4px;
-webkit-box-shadow: 2px 0px 5px -2px rgba(128, 128, 128, 0.76);
-moz-box-shadow: 2px 0px 5px -2px rgba(128, 128, 128, 0.76);
box-shadow: 2px 0px 5px -2px rgba(128, 128, 128, 0.76);
}
.mySlides {display: none;}
@itsalb3rt
itsalb3rt / number_format.js
Created December 28, 2018 18:59
colocar comas a cantidades que pasen del mil
function number_format (num) {
if (!num || num == 'NaN') return '-';
if (num == 'Infinity') return '&#x221e;';
num = num.toString().replace(/\$|\,/g, '');
if (isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num * 100 + 0.50000000001);
cents = num % 100;
num = Math.floor(num / 100).toString();
@itsalb3rt
itsalb3rt / date_time.js
Created December 28, 2018 22:18
obtener fecha y tiempo con javascript
/**
* Reotorna fecha en formato yyyy-mm-dd hh:ii:ss
**/
function get_date_time(){
let date = new Date().toISOString().slice(0, 10);
let time = new Date();
let hours = time.getHours();
let minutes = time.getMinutes();
let seconds = time.getSeconds();
return date + ' ' + hours + ':' + minutes + ':' + seconds;
@itsalb3rt
itsalb3rt / Postgres_Conecttion_Test_class
Created January 16, 2019 16:04
Clase test para probar la conexion a base de datos postgres
<?php
/**
* Clase creada con la intencion de realizar pruebas de conexion
* a base de datos Postgres
*
* User: Albert Eduardo Hidalgo Taveras
* Date: 16/1/2019
* Time: 11:16 AM
*/