This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BubleSort { | |
BubleSort (int ... array) { | |
long time_start, time_end; | |
time_start = System.currentTimeMillis(); | |
for(int i = 0; i < array.length; i++) { | |
for(int j = i + 1; j < array.length; j++) { | |
if(array[j] < array[i]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS `comuna_cl`; | |
/*!40101 SET @saved_cs_client = @@character_set_client */; | |
/*!40101 SET character_set_client = utf8 */; | |
CREATE TABLE `comuna_cl` ( | |
`id_co` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID unico de la comuna', | |
`id_pr` int(11) NOT NULL COMMENT 'ID de la provincia asociada', | |
`str_descripcion` varchar(30) COLLATE latin1_spanish_ci DEFAULT NULL COMMENT 'Nombre descriptivo de la comuna', | |
PRIMARY KEY (`id_co`,`id_pr`) | |
) ENGINE=InnoDB AUTO_INCREMENT=347 DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci COMMENT='Lista de comunas por provincias'; | |
/*!40101 SET character_set_client = @saved_cs_client */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Creación de la tabla | |
CREATE TABLE IF NOT EXISTS `paises` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID único del país', | |
`name` varchar(30) COLLATE latin1_spanish_ci NOT NULL COMMENT 'Nombre descritivo', | |
`iso_name` varchar(30) COLLATE latin1_spanish_ci NOT NULL COMMENT 'Nombre standard ISO', | |
`alfa2` varchar(2) COLLATE latin1_spanish_ci NOT NULL COMMENT 'Código de 2 caracteres', | |
`alfa3` varchar(3) COLLATE latin1_spanish_ci NOT NULL COMMENT 'Código de 3 caracteres', | |
`numerico` int(3) NOT NULL COMMENT 'Código único por país', | |
PRIMARY KEY (`id`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Validador de RUT Chileno | |
/// Hace uso del algoritmo Modulo 11 | |
/// | |
/// Chilean ID Number validator | |
/// Use the algorithm called Module 11 | |
/// </summary> | |
class Rut { | |
/// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function limpiaParametros( $param ) { | |
$cross_site_scripting = array ( '@<script[^>]*?>.*?</script>@si', // Remover javascript | |
'@<[\/\!]*?[^<>]*?>@si' ); // Remover etiquetas HTML | |
$inyeccion_sql = array ( '/\bAND\b/i', '/\bOR\b/i', '/\bSELECT\b/i', | |
'/\bFROM\b/i', '/\bWHERE\b/i', '/\bUPDATE\b/i', | |
'/\bDELETE\b/i', '/\b\*\b/i', '/\bCREATE\b/i' ); | |
$retorno = preg_replace ( $inyeccion_sql, "", $param ); | |
$retorno = preg_replace ( $cross_site_scripting, "", $retorno ); | |
$retorno = htmlentities( $retorno, ENT_QUOTES ); // Acá es importante verificar la codificación (ISO o UTF-8) | |
return trim( $retorno ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Debuging { | |
private $filePath; #Ruta del archivo log | |
private $fileName; #Nombre del archivo que invoca el debug | |
/** | |
* Clase de debugeo | |
* @param string $fileName nombre del archivo que invoca la clase | |
* @param string $filePath nombre del archivo donde se almacenará la traza | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Helper { | |
/** | |
* Función de validación de un rut basado en el algoritmo chileno | |
* el formato de entrada es ########-# en donde deben ser sólo | |
* números en la parte izquierda al guión y número o k en el | |
* dígito verificador | |
*/ | |
static function validaRut ( $rutCompleto ) { | |
if ( !preg_match("/^[0-9]+-[0-9kK]{1}/",$rutCompleto)) return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Valida la forma del email, no su existencia en un servidor | |
function validaEmail ( $var = '' ) { | |
return preg_match("/^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/", $var); | |
} | |
// Ejemplo de uso | |
echo validaEmail ('email@correcto.cl') ? 'Veo que es un bonito e-mail' : 'Esto no es dirección de email!!!'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Código actualizado a Swift 3.0.1 | |
print("Esto es para estudio de estructura de datos \n") | |
print("===========================================\n") | |
// Lista enlazada simple | |
// Esto es un objeto para lista enlazada | |
class Nodo { | |
// valor numerico del nodo | |
var valor:Int32! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// haciendo la serie de Fibonacci | |
// valor inicial de la serie | |
var valorInit:Int = 1; | |
// valor del segundo elemento de la serie | |
var valorNext:Int = 1; | |
print("Serie de Fibonacci") | |
print("==================") |