Skip to content

Instantly share code, notes, and snippets.

View gamorales's full-sized avatar

Guillermo Alfonso Morales gamorales

  • Santiago de Cali, Valle del Cauca, Colombia
View GitHub Profile
@gamorales
gamorales / settings.py
Created January 12, 2020 13:44
Run test with different database
import sys
import os
# ...
# settings.py extra configurations
# ...
if sys.argv[1] == 'test':
DATABASES = {
'default': {
@gamorales
gamorales / ci.yml
Last active January 1, 2022 04:05
Continous Integration github actions
name: Continous Integration
on:
pull_request:
branches:
- development
jobs:
build:
@gamorales
gamorales / anagram.py
Created February 27, 2020 18:50
Find if a word is an anagram of other.
import re
def anagram(a, b):
regex = f"^(?!.*(.).*\1)[{a}]*$"
if re.search(regex, b, flags=re.IGNORECASE):
return True
return False
@gamorales
gamorales / check_odoo.py
Created March 4, 2020 12:07
Verifying if odoo (or any process) is running.
import subprocess
try:
resultado = subprocess.check_output("sudo systemctl status odoo12 | grep 'Active: failed'", shell=True)
if "Active: failed" in resultado:
subprocess.check_output("sudo systemctl stop odoo12", shell=True)
subprocess.check_output("sudo systemctl start odoo12", shell=True)
print("activado 1")
else:
resultado = subprocess.check_output("sudo systemctl status odoo12 | grep inactive", shell=True)
@gamorales
gamorales / .bashrc
Last active June 13, 2022 12:48
.bashrc or .bash_profile configuration
alias android='/bin/sh /opt/android-studio/bin/studio.sh'
alias postman='cd /opt/postman/app;./Postman'
alias www='cd /var/www/html && clear && ls'
alias cdpython='cd ~/Documentos/desarrollo/python && clear && ls'
alias cddjango='cd ~/Documentos/desarrollo/python/django && clear && ls'
alias cdandroid='cd ~/Documentos/desarrollo/android && clear && ls'
alias cddocker='cd ~/Documentos/desarrollo/docker && clear && ls'
alias buildpython='make -j2 -s'
alias djangorun='python3 manage.py runserver'
alias djangoshell='python3 manage.py shell'
# Add these to /etc/hosts
# 127.0.0.1 localhost
# 127.0.0.1 local.host
server {
server_name localhost local.host;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
index index.html;
@gamorales
gamorales / cipher_text.py
Last active June 5, 2020 16:30
Encrypt a text and concatenating the resultant text with itself by characters sorted
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Encrypt and Decrypt idea extracted from http://rodrigogr.com/blog/cifrado-de-transposicion/
import math
def main():
text_encrypt = 'Guillermo Alfonso Morales, 1983-02-12, Santiago de Cali'
key_length = int(len(text_encrypt) / 4)
@gamorales
gamorales / reverse_vowels.py
Last active June 5, 2020 21:11
Rearrange the vowels from a string
def order_vowels_reverse(string):
list_string = [_ for _ in string]
vowels = 'aeiouAEIOU'
vowels_pos = list(filter(lambda car: car in vowels, string))
reverse = vowels_pos[::-1]
index = 0
for car in range(len(list_string)):
if index < len(vowels_pos):
@gamorales
gamorales / .vimrc
Last active December 26, 2023 16:51
Configure Vim to load the Vundle engine.
"vgit clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" vim-fugitive A status bar for Git with shortcuts for many Git tasks.
" tagbar A pane for making it easier to jump to functions, methods, and classes.
" To install -> :PluginInstall»
" To delete all plugins -> :PluginClean
" List installed plugins -> :PluginList
" To install from shell -> vim +PluginInstall +qall
" sudo apt install exuberant-ctags -y
syntax on
@gamorales
gamorales / apkdecompiler.py
Last active June 13, 2020 02:51
Organize files from apkdecompilers.com in their respective folders
import os
import shutil
source_path = '/<path>/<to>/<folder>/app-debug.apk/'
main_pkg_dir = './<android_project_directory_name>/'
def create_dir(dir_list):
global main_pkg_dir