Skip to content

Instantly share code, notes, and snippets.

View bran921007's full-sized avatar
🏠
Working from home

Fran Perez bran921007

🏠
Working from home
View GitHub Profile
<?php
/* connect to gmail */
$hostname = '{email.linc.do:993/imap/ssl/novalidate-cert}INBOX';
$username = '[email protected]';
$password = '593musica';
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Linc: ' . imap_last_error());
/* grab emails */
@bran921007
bran921007 / gist:6d3fee720e5627b0c001
Created January 28, 2015 00:33
Snippet - Libreria en Javascript
//Self-Executing Anonymous Function (Función anónima auto-ejecutable)
(function(grupo, $, undefined){
// Propiedad privada
var PasswordAdministrator = "adivina";
// Propiedades publicas
grupo.Nombre = "Developers Dominicanos";
grupo.CantidadMiembros = 0;
@bran921007
bran921007 / gist:97a631416d3c40801e02
Created January 28, 2015 01:00
Regular Expression notes
-> matches any character
+ -> means match 1 or more times
* -> means match 0 or more times
{5} -> means match {n} times
{3,5} -> means 3 or up to 5 times
^ -> means NOT
[] -> character set
\ -> escape a special meaning
\s -> represents a space ( matches space, tab or line break )
\w -> represents a word character ( lower or uppercase letter or a number )
@bran921007
bran921007 / gist:24bbbd4a39df999bc20c
Created January 31, 2015 23:53
Extraer urls con PHP - expresion regular
<?php
$cadena = file_get_contents('http://www.taringa.net');
function extraerURLs($cadena){
$regex = '/https?\:\/\/[^\" ]+/i';
preg_match_all($regex, $cadena, $partes);
return ($partes[0]);
}
// Llamamos a la función y le pasamos la cadena a buscar
@bran921007
bran921007 / gist:c4a8038db0009386e6fb
Created February 1, 2015 05:50
PHP: calcular espacio disponible del servidor
$bytes = disk_free_space("/");
$base = 1024;
$libre = ($bytes/$base)/$base; // en MB
echo $libre.' MB<br>'; // Imprime por ej: 54477.0546875 MB
@bran921007
bran921007 / gist:88f9042ce2ca9fb3cd7b
Created February 1, 2015 06:03
PHP: Validas DNI espanol
function validar_dni($dni){
$letra = substr($dni, -1);
$numeros = substr($dni, 0, -1);
if ( substr("TRWAGMYFPDXBNJZSQVHLCKE", $numeros%23, 1) == $letra && strlen($letra) == 1 && strlen ($numeros) == 8 ){
echo 'valido';
}else{
echo 'no valido';
}
}
1. Ocultar esas imagenes:
$("img").error(function(){
$(this).hide();
});
2. Reemplazar esas imágenes por una por defecto.
$("img").error(function() {
$( this ).hide();
Aquí vemos claramente una imagen en donde si la analizamos con detenimiento y a profundidad podemos observar que a partir de los distintos puntos de discrepancia y comparación se puede llegar a la idea central que se aleja del argumento principal, de lo cual concluimos que este comentario no tiene sentido alguno.
@bran921007
bran921007 / gist:89b0a7523c4a5052f209
Created February 7, 2015 22:35
Detectar país del usuario con jQuery
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$.getJSON('http://api.wipmania.com/jsonp?callback=?', function (data) {
alert('País: ' + data.address.country);
});
</script>
@bran921007
bran921007 / gist:f28486a122a4130c77a1
Created April 4, 2015 21:21
Funcion recursiva - Problema de la bacteria y termino An de la sucesion
Problema:
The XYZ bacteria is studied by a Harvard student
The bacterium is a hermaphrodite, it is able to reproduce itself by him without the intervention of a bacterium of the opposite sex.
It has been discovered that under temperate climatic conditions this bacterium is reproduced twice at full life creating two new microbes.
A constraint to consider is that, for reasons not yet discovered the first bacteria populations of microbes is replicated five times, creating 5 new microbes.