Skip to content

Instantly share code, notes, and snippets.

View IsaacAndres's full-sized avatar

Isaac Calavera IsaacAndres

View GitHub Profile
@IsaacAndres
IsaacAndres / ExampleICalendarInMail.php
Last active April 19, 2023 13:30
Este código muestra cómo agregar la opción "Añadir el calendario" a los correos electrónicos enviados mediante Laravel Mailable, utilizando la librería Spatie Icalendar Generator para crear archivos iCalendar.
<?php
/*
* Se requiere la instalación del paquete Spatie/IcalendarGenerator vía composer para utilizar
* funcionalidad de generación de archivos iCalendar.
* El paquete puede ser instalado con el comando "composer require spatie/icalendar-generator"
* Para más información, consulte la documentación en https://github.com/spatie/icalendar-generator
*/
namespace App\Mail;
@IsaacAndres
IsaacAndres / Rut.php
Last active October 7, 2022 17:55
Larevel Rule Validate RUT
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class Rut implements Rule
{
/**
* Create a new rule instance.
@IsaacAndres
IsaacAndres / tildeshtml.php
Created August 24, 2020 20:00
Convierte las tildes de un texto a sus entidades HTML.
<?php
function tildesHtml($cadena) {
return str_replace(array("á","é","í","ó","ú","ñ","Á","É","Í","Ó","Ú","Ñ"), array("&aacute;","&eacute;","&iacute;","&oacute;","&uacute;","&ntilde;","&Aacute;","&Eacute;","&Iacute;","&Oacute;","&Uacute;","&Ntilde;"), $cadena);
}
@IsaacAndres
IsaacAndres / check_in_range.php
Created May 29, 2020 20:52
Comparar si fecha esta dentro del rango
<?php
function check_in_range($fecha_inicio, $fecha_fin, $fecha){
$fecha_inicio = strtotime($fecha_inicio);
$fecha_fin = strtotime($fecha_fin);
$fecha = strtotime($fecha);
if(($fecha >= $fecha_inicio) && ($fecha <= $fecha_fin)) {
return true;
@IsaacAndres
IsaacAndres / disabled-inputs.js
Created March 9, 2020 03:14
Desabilitar todos los input
$(function(){
$(":input").prop("disabled", true);
})
@IsaacAndres
IsaacAndres / validaciondatapicker.js
Created February 4, 2020 20:07
Validacion fecha min/max bootstrap datapicker
<script>
$(document).ready(function(){
$("#fechainicio").datepicker({
todayBtn: 1,
autoclose: true,
}).on('changeDate', function (selected) {
var minDate = new Date(selected.date.valueOf());
$('#fechatermino').datepicker('setStartDate', minDate);
});
@IsaacAndres
IsaacAndres / onedecimal.html
Created January 24, 2020 03:02
Permite solo un punto y un decimal
<input type="text" onkeypress="return filterFloat(event,this);">
<script>
function filterFloat(evt,input){
// Backspace = 8, Enter = 13, ‘0′ = 48, ‘9′ = 57, ‘.’ = 46, ‘-’ = 43
var key = window.Event ? evt.which : evt.keyCode;
var chark = String.fromCharCode(key);
var tempValue = input.value+chark;
if(key >= 48 && key <= 57){
if(filter(tempValue)=== false){
@IsaacAndres
IsaacAndres / validacion.js
Last active April 5, 2022 16:03
Validación caracteres permitidos
// Rut
oninput="this.value = this.value.replace(/[^0-9Kk.]/g, '').replace(/(\..*)\./g, '$1');"
// Numeros
onkeypress="return /[0-9]/i.test(event.key)"
// Letras
onkeypress="return /[aA-zZ ]/i.test(event.key)"
// maxLength
oninput="if(this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
@IsaacAndres
IsaacAndres / fechas_mes.php
Created December 11, 2019 14:54
Obtener el primer y último día del mes
<?php
$fecha = new DateTime(); # Para obtener desde una fecha determinada sería de la siguente forma: $fecha = new DateTime('2019-12-11');
// obtener primer día del mes
$primer = $fecha;
$primer->modify('first day of this month');
$primer = $primer->format('Y-m-d');
echo $primer;
// obtener último día del mes
@IsaacAndres
IsaacAndres / fecha_esp.php
Last active August 29, 2019 20:24
Convertir fecha a español
<?php
setlocale(LC_ALL, 'es_ES');
foreach ($listado as $key => $venta) {
$fecha = $venta->fecha;
$date = new Datetime("$fecha");
$fecha = strftime("%d %B %Y", $date->getTimestamp());
$listado[$key]->fecha = $fecha;
}