Skip to content

Instantly share code, notes, and snippets.

Avatar

Hektor hcosta

View GitHub Profile
View f-Strings.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hcosta
hcosta / script.py
Created July 9, 2022 22:03
Pyinstaller resources loading
View script.py
import sys
import os
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
@hcosta
hcosta / command.txt
Created February 15, 2022 11:46
Fix Jupyter Notebook kernel error after update Python
View command.txt
python -m ipykernel install --user
View correccion.py
# La solución provista es incorrecta debido a lo siguiente:
del( l[i] )
# Al borrar el elemento de la posición actual hay que tener en cuenta que
# la siguiente vez que recorremos la lista, el índice habrá corrido una
# posición pero el número de elementos se habrá reducido y por tanto
# no se borrará el elemento que toca.
# Si en lugar de eliminar los elementos de la lista, generamos una nueva
View variante.py
import sys
if len(sys.argv) == 2:
numero = int(sys.argv[1])
if numero < 0:
print("Error - Número es incorrecto")
print("Ejemplo: descomposicion.py [0-999999999999999999999999]")
else:
# Aqui va la lógica
cadena = str(numero)
@hcosta
hcosta / enumerate.ipynb
Created January 27, 2022 02:19
enumerate.ipynb
View enumerate.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hcosta
hcosta / audio.cs
Last active November 18, 2021 18:56
View audio.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioManager : MonoBehaviour
{
public static AudioManager Instance { get; private set; }
public AudioSource musicPlayer, soundPlayer;
public AudioClip[] availableSoundClips;
Dictionary<string, AudioClip> loadedAudioClips = new Dictionary<string, AudioClip>();
@hcosta
hcosta / resumen.md
Last active February 28, 2023 20:11
View resumen.md

Paquetes de linting en VSCode para Django:

pipenv install pylint pylint-django autopep8 pycodestyle --dev

Configuración del linting en el proyecto .vscode/settings.json o en Settings generales:

{
@hcosta
hcosta / read-camera.py
Created March 7, 2021 14:51 — forked from bsdnoobz/read-camera.py
Displaying webcam feed using OpenCV and Python+PySide.
View read-camera.py
#!/usr/bin/env python
from PySide.QtCore import *
from PySide.QtGui import *
import cv2
import sys
class MainApp(QWidget):
def __init__(self):
@hcosta
hcosta / gist:14bc91da7f2122a58a449985d1ddb8b8
Created March 5, 2021 18:14
Fix jupyter nobteook kernel after uninstall anaconda/,iniconda
View gist:14bc91da7f2122a58a449985d1ddb8b8
Edit the file
C:\Users\<User>\AppData\Roaming\jupyter\kernels\python3\kernel.json
Change "C:\\Miniconda3\\python.exe" to your current Python path.