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 / README.md
Created November 23, 2020 19:08
Electron - disable CORS problem

Disabling CORS check in an Electron / Quasar App

Sometimes we try to do http requests from Electron to any page and it seems to be blocked by the "Browser engine" that comes with the renderer proccess.

There's one solution

The hack

  1. Change the BrowserWindow security config
@SrChach
SrChach / arrays.js
Created December 26, 2019 21:02
JS snippets
// For searching into an array, by object property
let arr = [
{ name:"string 1", value:"this", other: "that" },
{ name:"string 2", value:"this", other: "that" }
];
let obj = arr.find(o => o.name === 'string 1');
@SrChach
SrChach / shell.sh
Created November 8, 2019 19:38
useful shell comands
## Este archivo crecerá
# Para "disk usage". Devuelve el espacio en disco que ocupa un archivo o carpeta
du
# Put in there knowledge for conditionals, if/else, find, pipes
@SrChach
SrChach / retrieve_images.sh
Created October 28, 2019 18:51
G214 shell file for find lost images and move it to main folder
# If you don't set "_usuario" and "_pass" for DB, this script won't work
# constants setted
_usuario=""
_pass=""
_input="images.txt"
_search_in="../Evidencia"
_carpeta_puente="__ejemplo"
_carpeta_salida="../storage/images"
_limit="LIMIT 5"
@SrChach
SrChach / test_time.py
Created August 27, 2019 18:33
See time that processes late in various languages
import datetime
begin = datetime.datetime.now()
# Code we want to measure goes here
end = datetime.datetime.now()
time = end - begin
print("\n" * 5, time.seconds , "\n" * 5)
@SrChach
SrChach / README.md
Created June 17, 2019 16:46
git_pre_push_hook

Git hooks

Git hooks live into .git/hooks folder in every git repo.

The name of each one tells us when the git hook it's gonna be executed, and the .sample extension in each one prevent its execution.

When we are going to execute a script in some part of git's lifecycle, we need to

  1. Find the file of the part of lifecycle that we need to override
@SrChach
SrChach / dynamic_imports.py
Last active August 28, 2019 19:05
Code to dynamic imports in python
from importlib import import_module
my_module_new_name = import_module('variable.module.name')
@SrChach
SrChach / git-log.sh
Created May 23, 2019 20:38
useful ways to list changes on git/Formas útiles de listar los cambios en git
## Remember that the options below could be used together
# List all the changes made in a file
git log <path_to_folder_or_file>
# Track the change history of a file (including rename)
git log --follow <file>
# list commits by author
git log --author="example_user"
@SrChach
SrChach / fun_json.php
Last active May 23, 2019 20:26
Manage errors and success messages in php, check if values exists
<?php
// print_if_not_failed sólo afecta si la operación fué exitosa
function json_check_print($mensaje_posible_error = 'error', $variable = null, $print_if_not_failed = false, $json = false){
$print = [
'error' => null
];
if($json)
header('Content-Type: application/json');
$failed = $variable === null || $variable === false;
if($failed)
@SrChach
SrChach / parameters_from.js
Created April 11, 2019 17:36
Functions for get values from URL's get parameter && edit URL strings
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
}
function changeUrlParameter(url, parametro, value){
let separator = '&'
if(url.indexOf("?") === -1)
separator = '?'
url = window.location.href + '&'