Skip to content

Instantly share code, notes, and snippets.

View gchacaltana's full-sized avatar
🎯
Focusing

Gonzalo Chacaltana gchacaltana

🎯
Focusing
  • Perú
View GitHub Profile
@gchacaltana
gchacaltana / generate_uuid_v4.php
Created June 28, 2017 05:56
Función para generar UUID versión 4 con PHP
// Generate UUID v4
function generateUuidv4()
{
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
@gchacaltana
gchacaltana / nginx.conf
Created September 12, 2023 03:40
Add denny access directive email
# Deny all attempts to access hidden files/folders such as .git, .htaccess, .htpasswd, .DS_Store (Mac), etc...
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# Deny yaml, twig, markdown, ini file access
location ~* /.+\.(markdown|md|twig|yaml|yml|ini)$ {
deny all;
@gchacaltana
gchacaltana / swagger-ui.html
Created October 15, 2022 07:12
Template Swagger UI for API documentation [OpenAPI v3.0]
<!DOCTYPE html>
<html>
<head>
<title>API Docs with Swagger UI</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@3/swagger-ui.css">
</head>
<body>
@gchacaltana
gchacaltana / settings.json
Created September 10, 2022 23:23
Visual Code - Settings - Editor Ruler
{
"editor.rulers": [80,120],
"workbench.colorCustomizations": {
"editorRuler.foreground": "#ff4081"
}
}
@gchacaltana
gchacaltana / .env
Created August 17, 2022 04:44
Archivo .env para proyectos wordpress
#--------------------------------------------------------------------------------------------------#
# ENVIRONMENT SETTING #
# It can be anything, but "development", "staging" and "production" are supported out of the box. #
# Do not use "development" on production and viceversa, because it has effect on debug settings. #
#--------------------------------------------------------------------------------------------------#
WORDPRESS_ENV=development
#--------------------------------------------------------------------------------------------------#
# DEBUG #
# If you set WORDPRESS_ENV, default debug values are used based on that. #
@gchacaltana
gchacaltana / hyper.conf.js
Created May 28, 2022 00:16
Hyper Config File - Example Settings
"use strict";
/*
Example Hyper Config
@link https://hyper.is#cfg for all currently supported options.
*/
module.exports = {
config: {
updateChannel: 'stable',
fontSize: 17,
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
@gchacaltana
gchacaltana / date_default_timezone_set.php
Last active December 20, 2021 08:15
Use datetime format, date_default_timezone_set php
#How to convert yyyy-MM-ddTHH:mm:ssZ to yyyy-MM-dd HH:mm:ss
date_default_timezone_set("America/Lima");
echo date('Y-m-d H:i:s', strtotime('2012-09-10T10:30:00Z'));//date format UTC +00.00
#convert date format UTC to timezone America/Lima
date_default_timezone_set("UTC");//server configured UTC
$date = strtotime(date('Y-m-d H:i:s'));
echo(date_default_timezone_get() . "<br />");//output: UTC
@gchacaltana
gchacaltana / ConfusionMatrix.php
Last active June 17, 2021 05:36
Matriz de confusión binaria
<?php
declare(strict_types = 1);
/**
* ConfusionMatrix
*
* @author Gonzalo Chacaltana Buleje <gchacaltanab@outlook.com>
* @version v1.0.0
* @access public
*/
@gchacaltana
gchacaltana / wordcloud_corpus.R
Created May 16, 2021 07:01
Show worcloud from corpus (R)
# Función que devuelve wordcloud de un contenido de texto
# @param Corpus corpus Example: Corpus(VectorSource(publication)) from Corpus Package
wordcloud_corpus <- function(corpus) {
# Matriz de términos (Term-Document-Matrix)
tdm = TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE, removeNumbers = TRUE, tolower = TRUE))
matrix_tdm = as.matrix(tdm)
# Obtenemos las palabras frecuentes de mayor a menor
words_freqs = sort(rowSums(matrix_tdm), decreasing=TRUE)