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
SELECT id, nombre, apellidos, SUBSTR(CONCAT('0000',codigo),-4) as CDB FROM empleados WHERE codigo REGEXP '^-?[0-9]+$' ORDER BY CAST(codigo AS UNSIGNED) ASC |
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 deleteDirectoryRecursive($dirPath) { | |
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) { | |
$path->isDir() ? rmdir($path->getPathname()) : unlink($path->getPathname()); | |
} | |
rmdir($dirPath); | |
} |
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
// Comprobar si el fichero trae BOM | |
$bom = pack("CCC", 0xef, 0xbb, 0xbf); | |
if (0 == strncmp($json, $bom, 3)) { | |
$json = substr($json, 3); | |
} |
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
// Ultimo día del mes actual | |
$ultimoDia = date('Y/m/t').' 23:59:59'; | |
echo $ultimoDia; | |
// Sumar segundos a una fecha | |
$time = strtotime('2013-09-18 11:00:00+25200 seconds'); | |
echo date('H:i',$time); |
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
// Eliminar caracterse no alfanuméricos de una cadena | |
preg_replace("/[^A-Za-z0-9]/", '', $string); |
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
// Tomar una aguja de 1cm y un papel con líneas paralelas a 2cm | |
// Lanzar la aguja sobre el papel, cada vez que la aguja corta una linea | |
// cuenta como un acierto | |
// pi (aprox) = intentos / aciertos | |
import java.util.Random; | |
import java.util.Scanner; | |
public class BuffonPiEstimation | |
{ |
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
$path = $_FILES['image']['name']; | |
$ext = pathinfo($path, PATHINFO_EXTENSION); |
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
// Obtener registros de la tabla con fecha superior a hace tres meses | |
SELECT * FROM tabla WHERE fecha >= DATE_ADD(NOW(),INTERVAL -3 MONTH) | |
// De otro modo: | |
SELECT * FROM tabla WHERE fecha >= (NOW() + INTERVAL -3 MONTH) |
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
<?php | |
// Obtener el array | |
$myarray = glob("*.*"); | |
// Ordenar por fecha ascendente | |
usort($myarray, create_function('$a,$b', 'return filemtime($a) - filemtime($b);')); |
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
SELECT | |
STUFF( | |
( | |
SELECT | |
',' + RTRIM(LTRIM(TELEFONO)) | |
FROM CLIENTE | |
WHERE CLIENTE = '10655' | |
ORDER BY TELEFONO FOR xml path('') | |
) | |
, 1, 1, '') |