Skip to content

Instantly share code, notes, and snippets.

View cuahutli's full-sized avatar

Cuahutli Miguel Ulloa Robles cuahutli

View GitHub Profile
@cuahutli
cuahutli / get_hdd_info.py
Created April 15, 2020 07:48
Get Information about disk, Total, Free and Used Space
import ctypes
import platform
import os
class HardDriveSpaceException(Exception):
def __init__(self, value):
self.parameter = value
def __str__(self):
return repr(self.parameter)
@cuahutli
cuahutli / rest-api-flask-sample.py
Created February 25, 2019 17:38
Ejemplo de como crear una api con Flask que incluye conexión a Base de Datos
#!/usr/bin/env python
import os
from flask import Flask, abort, request, jsonify, g, url_for
from flask.ext.sqlalchemy import SQLAlchemy
from sqlalchemy.inspection import inspect
from flask.ext.httpauth import HTTPBasicAuth
from passlib.apps import custom_app_context as pwd_context
from itsdangerous import (TimedJSONWebSignatureSerializer
as Serializer, BadSignature, SignatureExpired)
import sys
code = """
def f(x):
x = x + 1
print("Montamos la función on the fly")
return x
#print('This is my output.')
"""
@cuahutli
cuahutli / Main.java
Created May 24, 2018 00:33 — forked from sergiougalde/Impresora.java
Imprimir con Java en una impresora de tickets Epson tmu 220 En muchos lugares se habla de como imprimir con Java en una epson tmu 220 , he encontrado mucho sobre y he encontrado muchas recomendaciones de usar epson java pos (http://www.javapos.com/devices.html) sin embargo si lo que se requiere es algo más simple aunque no tan potente es simplem…
impresora tiquete=new impresora();
tiquete.escribir(“ Esto es una linea “);
tiquete.escribir(“Esto es otra linea”);
tiquete.escribir(“Otra linea mas”);
//Esto es para escribir una linea divisoria
tiquete.dividir();
//esto cambia el formato de acuerdo a las especificaciones de epson
@cuahutli
cuahutli / run.bat
Last active May 3, 2018 19:03
Open url in chrome with fullscreen mode
start /B wscript "run.vbs"
@cuahutli
cuahutli / settings.json
Created April 14, 2018 17:46
My Settings.json from visual studio code that allow activate python virtual enviroment automatically
{
"python.pythonPath": "${workspaceFolder}\\venv\\Scripts\\python.exe",
"terminal.integrated.shellArgs.windows": ["/K", "venv\\Scripts\\activate"],
}
@cuahutli
cuahutli / create-vm.sh
Created August 11, 2017 22:33
Script para crear una VM con VirtualBox desde consola y acceso vía RDP activado
#!/bin/sh
VMNAME="virtserver"
ISO="PATH/TO/ISO"
VBOX_PATH="/PATH/TO/VirtualBox VMs/"
DIR_VM="$VBOX_PATH""$VMNAME"
HDD_VM="$DIR_VM/$VMNAME-disk1.vmdk"
echo "Creando directorio que almacenara la VM"
mkdir -p "$DIR_VM"
VBoxManage createvm -name "$VMNAME" --register --ostype Ubuntu_64
# -*- coding: utf-8 -*-
import requests
import json
import socket
DDNS_HOST = 'myhost.dyndns.org'
CHEKIP_URL = "http://thisisnt.com/api/getRemoteIp.php"
DDNS_UPDATE_URL = "https://members.dyndns.com/nic/update"
user = "myuser"
@cuahutli
cuahutli / weeks_months.py
Last active April 5, 2017 16:06
get week info (number week, first day of week, last day of week) current month and next month
import calendar
from datetime import datetime
def week_of_month(dt):
current_month = (dt.year,dt.month)
next_month = (dt.year +1,1) if dt.month==12 else (dt.year,dt.month + 1)
weeks_month = []
for year,month in [current_month, next_month]:
@cuahutli
cuahutli / gunicorn_start.bash
Created July 12, 2016 15:52 — forked from postrational/gunicorn_start.bash
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name