Skip to content

Instantly share code, notes, and snippets.

@drgarcia1986
drgarcia1986 / Project1.dpr
Created April 2, 2014 14:37
Generic Singleton Pattern in Delphi
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
uSingletonGeneric in 'uSingletonGeneric.pas',
uMyClass in 'uMyClass.pas';
@drgarcia1986
drgarcia1986 / __main__.py
Last active August 9, 2023 21:20
Example of OAuth2 autentication server with Client Credentials grant (using python-oauth2 and tornado)
# !/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 / __main__.py
Created July 28, 2014 18:00
Image server with Python (Tornado) and MongoDB
# !/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Diego Garcia'
import tornado.ioloop
import tornado.web
from bson.json_util import dumps
from pymongo import Connection
from bson.objectid import ObjectId
from gridfs import GridFS
@drgarcia1986
drgarcia1986 / bottle_hello.py
Last active September 30, 2022 16:19
Python HelloWorld (WebFrameworks) Collection
# -*- coding: utf-8 -*-
from bottle import route, run
@route('/')
def index():
return '<h1>Hello World/h1>'
run(host='localhost', port=8000)
@drgarcia1986
drgarcia1986 / TestUntORM.pas
Last active January 5, 2022 07:43
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)
unit TestUntORM;
interface
uses
TestFramework,
untORM,
untDB,
untLog,
Delphi.Mocks;
@drgarcia1986
drgarcia1986 / tornado_asyncio.py
Last active August 7, 2021 15:57
Tornado and Asyncio Mixed example
# -*- 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 / pytesser.py
Created April 25, 2014 21:55
Wrapper for Google-Tesseract
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 February 13, 2014 23:09
Classe feita em Python para recuperar a cotação de algumas moedas estrangeiras baseada nas versões brasileiras do site CashCash.cc
__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 / CurrencyConvertor.pas
Created March 17, 2014 23:12
Aplicativo de exemplo referente a post de titulo "Recuperando o XML de uma requisição SOAP em Delphi" no blog http://drgarcia1986.wordpress.com/
// ************************************************************************ //
// 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 June 22, 2019 13:25
Hello World with Ansible and Vagrant
# 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|