Skip to content

Instantly share code, notes, and snippets.

Avatar

Diego Garcia drgarcia1986

View GitHub Profile
@drgarcia1986
drgarcia1986 / tornado_asyncio.py
Last active Aug 7, 2021
Tornado and Asyncio Mixed example
View tornado_asyncio.py
# -*- coding: utf-8 -*-
import asyncio
import re
import asyncio_redis
import tornado.concurrent
import tornado.httpclient
import tornado.web
import tornado.platform.asyncio
@drgarcia1986
drgarcia1986 / bottle_hello.py
Last active Jul 19, 2021
Python HelloWorld (WebFrameworks) Collection
View bottle_hello.py
# -*- coding: utf-8 -*-
from bottle import route, run
@route('/')
def index():
return '<h1>Hello World/h1>'
run(host='localhost', port=8000)
@drgarcia1986
drgarcia1986 / __main__.py
Last active Jun 13, 2021
Example of OAuth2 autentication server with Client Credentials grant (using python-oauth2 and tornado)
View __main__.py
# !/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Diego Garcia'
import tornado.web
import tornado.ioloop
import oauth2.tokengenerator
import oauth2.grant
import oauth2.store.redisdb
import oauth2.store.mongodb
@drgarcia1986
drgarcia1986 / pytesser.py
Created Apr 25, 2014
Wrapper for Google-Tesseract
View pytesser.py
from subprocess import Popen, PIPE
import os
import sys
PROG_NAME = 'tesseract'
TEMP_IMAGE = 'tmp.bmp'
TEMP_FILE = 'tmp'
PSM_OSD_ONLY = 0
@drgarcia1986
drgarcia1986 / cotacao.py
Created Feb 13, 2014
Classe feita em Python para recuperar a cotação de algumas moedas estrangeiras baseada nas versões brasileiras do site CashCash.cc
View cotacao.py
__author__ = 'diego.garcia'
import urllib.request as req
import re
class Cotacao:
def __get_cotacao(self, url, regex='^.*nacional" value="([0-9,]+)"'):
pagina = req.urlopen(url)
@drgarcia1986
drgarcia1986 / Project1.dpr
Created Apr 2, 2014
Generic Singleton Pattern in Delphi
View Project1.dpr
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
uSingletonGeneric in 'uSingletonGeneric.pas',
uMyClass in 'uMyClass.pas';
@drgarcia1986
drgarcia1986 / CurrencyConvertor.pas
Created Mar 17, 2014
Aplicativo de exemplo referente a post de titulo "Recuperando o XML de uma requisição SOAP em Delphi" no blog http://drgarcia1986.wordpress.com/
View CurrencyConvertor.pas
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
// >Import : http://www.webservicex.net/CurrencyConvertor.asmx?WSDL>0
// Encoding : utf-8
// Version : 1.0
// (27/06/2013 19:13:01 - - $Rev: 45757 $)
// ************************************************************************ //
@drgarcia1986
drgarcia1986 / Vagrantfile
Last active Jun 22, 2019
Hello World with Ansible and Vagrant
View Vagrantfile
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.provision :ansible do |ansible|
@drgarcia1986
drgarcia1986 / TestUntORM.pas
Last active Mar 21, 2019
This is a example of Dependency Injection and Unit Tests with Delphi-Mocks (https://github.com/VSoftTechnologies/Delphi-Mocks) and Spring4D (https://bitbucket.org/sglienke/spring4d)
View TestUntORM.pas
unit TestUntORM;
interface
uses
TestFramework,
untORM,
untDB,
untLog,
Delphi.Mocks;
@drgarcia1986
drgarcia1986 / udp_client.py
Created Feb 17, 2014
Classe feita em Python que encapsula um cliente UDP enviando e recebendo mensagens de um servidor.
View udp_client.py
__author__ = 'diego.garcia'
import socket
class UDPClient:
__IP = '255.255.255.255'
__PORT = 49152
__udp_cli = ''