Skip to content

Instantly share code, notes, and snippets.

View knkillname's full-sized avatar

Mario Abarca knkillname

View GitHub Profile
@knkillname
knkillname / setup-devcontainers.sh
Last active November 10, 2023 17:50
Setup Visual Studio Code + Dev Containers Extension in Linux
#!/bin/bash
set -e
# Err if user is root
if [ "$EUID" -eq 0 ]; then
echo "Please do not run as root"
exit
fi
# Install git, docker, and VSCode dependencies
@knkillname
knkillname / get_latest_anaconda.sh
Created April 23, 2020 23:53
Install latest Anaconda3 for Ubuntu
wget -O anaconda_installer.sh $(python3 latest_anaconda.py)
bash anaconda_installer.sh -b -u -f -p $HOME/anaconda3
source $HOME/anaconda3/etc/profile.d/conda.sh
conda init
conda config --set auto_activate_base false
import argparse
import csv
import io
import itertools
import pathlib
import sqlite3
from typing import Any, Dict, Iterable, List, Optional
import zipfile
@knkillname
knkillname / generarcontrasena.py
Last active July 29, 2022 13:59
Generador de contraseñas fáciles de recordar
# Autor: Mario Abarca
"""
Aplicación que genera de contraseñas fáciles de recordar mezclando
palabras en español y símbolos.
"""
import abc
import collections
import itertools
import math
@knkillname
knkillname / thomae.py
Last active December 27, 2018 17:38
Gráfica de la función de Thomae
import matplotlib.pyplot as plt
def mcd(a, b):
'Algoritmo de Euclides para hallar el máximo común divisor.'
while b != 0:
(a, b) = (b, a % b)
return a
def grafica_thomae(a=0, b=1, denominador_max=1000):
'''Aproximación de la gráfica de la función de Thomae en el
@knkillname
knkillname / textobinario.py
Last active October 29, 2023 19:54
Convertir texto a binario y viceversa.
# Autor: Mario Abarca
# Fecha: 29 nov. 2017
# Lenguaje: Python 3.6
from cmd import Cmd
class TextoBinarioApp(Cmd):
def __init__(mi):
super().__init__()
mi.codigo = 'utf8'
@knkillname
knkillname / laberinto.py
Created October 31, 2017 17:58
Laberinto por recorrido en profundidad en Python 3
# Crear un laberinto aleatorio en Python3 usando el algoritmo de
# recorrido en profundidad. El propósito de este programa es mostrar las
# características del lenguaje.
#
# Autor: Mario Abarca
# Fecha: 2017/09/07
from random import shuffle, randint # Números pseudoaleatorios
from itertools import product # Producto cartesiano
## A simple program that showcases tree drawing by fractals
## Copyright (C) 2016 Mario Abarca
##
## This program is free software: you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation, either version 3 of the
## License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
import turtle, colorsys, math
t = turtle.Turtle()
t.pensize(4); t.right(90); t.speed(0)
n, j, i, p = 19, 1, 1, (5 ** 0.5 - 1) / 2
for k in range(n):
r, g, b = colorsys.hls_to_rgb(p * k % 1, p, 1)
t.color('white', (r, g, b))
t.begin_fill()
for k in range(4):
@knkillname
knkillname / algsenredes.py
Last active October 20, 2015 17:20
Algoritmos del curso básico de Algoritmia
## Algoritmos en redes (grafos con pesos en las aristas)
##
## Autor: Mario Abarca (asma@uaem.mx)
## Fecha: 20 de octubre de 2015
from grafos import Grafo
from estructuras import Cola
from estructuras import ColaMin
from estructuras import ConjuntosDisjuntos