Skip to content

Instantly share code, notes, and snippets.

View obeduri's full-sized avatar

Obed David Pérez Uri obeduri

View GitHub Profile
@obeduri
obeduri / Sommernote.js
Created November 12, 2021 15:54
Sommernote
define('summernote/settings', function () {
var settings = {
// version
version: '@VERSION',
/**
* options
*/
options: {
width: null, // set editor width
@obeduri
obeduri / SnippetsJavascript.js
Last active March 14, 2024 19:59
Snippets Javascript
//SLEECIONA TODOS LOS ELEMENTOS MENOS EL ULTIMOS
$("div.elem:not(:last)").hide();
function formatTable(cnf) {
/*
{
debug: true, //debugging options switch
element: '.table_rols_modules', //object en DOM el cual será datatable
empty_table: 'NO HAY DATOS',
@obeduri
obeduri / CSSSnippets.css
Created November 12, 2021 15:51
CSS Snippets
/*VUELVE CUALQUIER IMAGEN CUADRADA*/
.NO_wrapped_picture {
object-fit: cover;
width: 128PX;
height: 128px;
}
//Imprimir imagenes a color y backgrounds
@media print {
@obeduri
obeduri / RegularExpressions.js
Last active November 18, 2022 15:56
Regular Expressions
Password Strength
[A-Z].*[A-Z])(?=.*[!@#$&*])(?=.*[0-9].*[0-9])(?=.*[a-z].*[a-z].*[a-z]).{8}$
Hexadecimal Color
\#([a-fA-F]|[0-9]){3, 6}
Validate E-mail Address
/[A-Z0-9._%+-]+@[A-Z0-9-]+.+.[A-Z]{2,4}/igm
@obeduri
obeduri / SQLSnippets.sql
Created November 12, 2021 15:48
SQL Snippets
-- GET THE MAX ID ASSIGNABLE POSSIBLE IN A TABLE
SELECT max(id) AS id FROM :TABLE;
-- DYNAMIC QUERIES
SELECT * FROM (
SELECT * FROM students S
JOIN cursos ON s.cursoId = c.cursoId
@obeduri
obeduri / PHPSnippets.php
Last active October 26, 2023 03:38
PHP Snippets
// Split the string into individual words
$words = explode(' ', $string);
// Initialize a counter
$tokens = 0;
// Iterate over the words
foreach ($words as $word) {
// Increment the counter by the ceil of the word's length divided by 4
// GPT-3's tokenizer uses a byte pair encoding that won't split a word into more than one token if it's 4 bytes or less
@obeduri
obeduri / SessionTimeout.js
Created November 12, 2021 15:47
Session Time out with controls for multiple Tabs
//SETS THE TIME FOR THE COOKIE TO EXPIRE
function setTimeUp() {
//DELETE COOKIE EXIST
deleteCookie('TimeIsUp');
deleteCookie('TimeRedirect');
deleteCookie('TimeWarn');
//SETTING SESSION TIME'S UP
setCookie('TimeIsUp', moment().add(18, 'minutes').format('YYYY-MM-DD HH:mm:ss'), 1);
setCookie('TimeRedirect', moment(getCookie('TimeIsUp')).add(60, 'seconds').diff(moment()), 1);