Skip to content

Instantly share code, notes, and snippets.

View macagua's full-sized avatar
🏠
Working from home

Leonardo J. Caballero G. macagua

🏠
Working from home
View GitHub Profile
@macagua
macagua / ndis-fix.sh
Created September 12, 2016 05:20 — forked from Avinash-Raj/ndis-fix.sh
Shell script to fix "Install NDIS driver failed" error while trying to install Huawei modem drivers on linux
#!/bin/bash
# Run the below script only after "Install NDIS driver failed" error while trying to install Huawei modem drivers on linux.
# I checked this script on Ubuntu.
# Detailed explanation of this script was given here(http://askubuntu.com/a/414401/202806).
path="/usr/local/Mobile_Partner/driver"
if [ "$(ls -A $path)" ]; then
tput setaf 6; echo "Huawei modem drivers for linux are already installed on your pc.Please wait for NDIS driver installation."; tput sgr0
perl -i -pe 's#^(\s*dbg \("can.t kmalloc dev"\);)#//$1#' /usr/local/Mobile_Partner/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c
cd $path
@macagua
macagua / upgrades.py
Created June 30, 2017 12:09 — forked from thet/upgrades.py
Plone / Zope Component Architecture: Unregister all broken persistent utilities
# -*- coding: utf-8 -*-
from zope.component.hooks import getSite
import logging
log = logging.getLogger(__name__)
def unregister_broken_persistent_components(context):
portal = getSite()
sm = portal.getSiteManager()
@macagua
macagua / intro.md
Created December 21, 2017 12:36 — forked from derhuerst/intro.md
Installing Git on Linux, Mac OS X and Windows
@macagua
macagua / gist:235f875138221f2a9032c0adc4144fde
Created February 9, 2018 16:40
[TIP] When there is Internet latency and requires installing python packages by a buildout proyect, for later shared these packages with others buildout proyect, then you can prevent buildout from re-downloading previously downloaded packages, running this command:
mkdir -p $HOME/.buildout/{downloads,eggs,extends,zope} && echo $HOME $HOME $HOME $HOME | awk '{ printf( "[buildout]\neggs-directory = %s/.buildout/eggs\ndownload-cache = %s/.buildout/downloads\nextends-cache = %s/.buildout/extends\nzope-directory = %s/.buildout/zope\nabi-tag-eggs = true\n", $1, $2, $3, $4 ) }' >> ~/.buildout/default.cfg
@macagua
macagua / clases.py
Last active September 27, 2018 01:40
Uso de Clases en Python 2.7.x
# -*- coding: utf8 -*-
class Persona(object):
""" Clase que representa una persona. """
def __init__(self, cedula, nombre, apellido, sexo):
""" Constructor de clase Persona """
self.cedula = cedula
self.nombre = nombre
self.apellido = apellido
@macagua
macagua / python35_tipado_dinamico.py
Created September 27, 2018 02:46
Uso tipado dinámico en Python 3.5.x
""" El tipado dinámico significa que los objetos en tiempo de
ejecución (valores) tienen un tipo, a diferencia del tipado
estático donde las variables tienen un tipo.
>>> variable = 11
>>> print ((variable), type(variable))
<class 'int'>
>>> variable = "activo"
>>> print ((variable), type(variable))
<class 'str'>
@macagua
macagua / python27_tipado_dinamico.py
Last active September 27, 2018 02:48
Uso tipado dinámico en Python 2.7.x
# -*- coding: utf8 -*-
""" El tipado dinámico significa que los objetos en tiempo de
ejecución (valores) tienen un tipo, a diferencia del tipado
estático donde las variables tienen un tipo.
>>> variable = 11
>>> print variable, type(variable)
11 <type 'int'>
>>> variable = "activo"
@macagua
macagua / python35_fuertemente_tipados.py
Created September 27, 2018 03:12
Uso del fuertemente tipado en Python 3.5.x
""" El fuertemente tipado significa que el tipo de valor no
cambia repentinamente. Una cadena que contiene solo dígitos
no se convierte mágicamente en un número. Cada cambio de tipo
requiere una conversión explícita.
>>> valor1 = 2
>>> valor2 = "5"
>>> total = valor1 + valor2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
@macagua
macagua / python27_fuertemente_tipados.py
Last active September 27, 2018 03:13
Uso del fuertemente tipado en Python 2.7.x
# -*- coding: utf8 -*-
""" El fuertemente tipado significa que el tipo de valor no
cambia repentinamente. Una cadena que contiene solo dígitos
no se convierte mágicamente en un número. Cada cambio de tipo
requiere una conversión explícita.
>>> valor1 = 2
>>> valor2 = "5"
>>> total = valor1 + valor2
@macagua
macagua / README.rst
Last active October 4, 2018 16:42
HTTP Server request and response for GET and POST verbs demostration with Python 2

README

To use this:

  1. Install httpie via pip inside a virtualenv, executing the following command: pip install httpie
  2. Execute HTTP Server script on your machine, executing the following command: python3 my-httpserver.py
  3. Test a HEAD request using http script from httpie package,