Skip to content

Instantly share code, notes, and snippets.

View SrChach's full-sized avatar
:octocat:
Building better humans

Ignacio Martínez Ávila SrChach

:octocat:
Building better humans
  • Mediaagility
  • Mexico City, Mexico
View GitHub Profile
@SrChach
SrChach / Format.php
Last active April 11, 2019 17:58
Format of Query dates in PHP, compatibility with MySQL && SQLite
<?php
class Format {
function __construct(){
}
function query_if_varios_manejadores($nombreCampo, $valorCampo, $if_verdadero = 'NULL', $if_falso = 'NULL' , $manejador = 'sqlite'){
if($manejador == "mysql")
@SrChach
SrChach / paginador.php
Last active April 15, 2019 17:49
Función de paginador para PHP
function botoneador($total_registros, $registros_por_pagina, $primer_registro){
$registros_por_pagina = is_numeric($registros_por_pagina) && $registros_por_pagina != 0 ? $registros_por_pagina : 10;
$total_paginas = ceil($total_registros / $registros_por_pagina);
$primer_registro = is_numeric($primer_registro) ? number_format($primer_registro) : 0;
if($primer_registro < 0 || $primer_registro > $total_registros)
$primer_registro = 0;
$pagina_actual = floor($primer_registro / $registros_por_pagina) + 1;
@SrChach
SrChach / vue.config.js
Last active May 24, 2019 16:08
Configuration to proxy calls to dev server
/* Create a file into the root directory of the project, and name it as "vue.config.js". Paste this code there.
*/
module.exports = {
devServer: {
proxy: {
'/auth': {
target: 'http://127.0.0.1/api', // Sitio al que va a apuntar (redirigir)
pathRewrite: {'^/auth/': '/'} // Para que, por ejemplo, no busque "/auth" en el server de datos, si no la ruta que le pasemos acá
},
@SrChach
SrChach / linux_permissions.txt
Last active July 31, 2019 18:17
Linux Permissions
Note: need to improve gist and move it to MarkDown.
need to add how to add permissions to httpd.conf (in another gist)
Structure of the permissions in Linux:
For example, analyzing "-rwxr-xr--"
- rwx r-x r--
[ Type of file ][Owner's permissions ][Group's permissions ][Other's permissions ]
| | 'r' = 'read' |
|'-' indicates file | 'w' = 'write' |
|'d' indicates directory | 'x' = 'execute' |
@SrChach
SrChach / manageProccesses.txt
Last active February 11, 2019 19:43
Http start/stop services
/* Inicializar servidor */
sudo systemctl start httpd.service
/* Parar servidor */
sudo systemctl stop httpd.service
/* Inicializar servicio mariadb */
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
@SrChach
SrChach / testingFunctions.txt
Last active February 11, 2019 19:43
Testing functions
/* @Lang: PHP
* @Description: Función para imprimir el valor y metadatos de una variable
*/
function predump($var, $imprime=false, $salir=false){
echo "<pre>";
var_dump($var);
echo "</pre>";
echo $imprime? $var : "";
$salir? exit(): true;
}