Skip to content

Instantly share code, notes, and snippets.

@drgarcia1986
drgarcia1986 / my_thread.py
Created May 6, 2014 22:04
Exemplo simples de uso de Threads em python
#!/usr/bin/python
__author__ = 'Diego Garcia'
from threading import Thread
from time import sleep
from random import randint
class MinhaThread(Thread):
def __init__(self, identificador, vezes):
@drgarcia1986
drgarcia1986 / Command.bat
Created April 28, 2014 19:56
Scripts for Start/Stop Windows service remote (bath or powershell)
net use \\%Machine% [PasswordOfRemoteMachine] /USER:[UserOfRemoteMachine]
sc \\%Machine% %Action% %Service%
@drgarcia1986
drgarcia1986 / ptwitter.py
Created April 28, 2014 18:35
Twitter integration with Python
#based on: https://github.com/sixohsix/twitter
__author__ = 'Diego Garcia'
from twitter import *
from my_twitter_tokens import * # TOKENS CONSTS
t = Twitter(
auth=OAuth(ACCESS_TOKEN,
ACCESS_TOKEN_SECRET,
API_KEY,
@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 / Strategy.Concrete.Lower.pas
Created April 15, 2014 02:45
A example of Pattern Strategy (GoF). context is IText, strategy is IFormatter and client is Application.
unit Strategy.Concrete.Lower;
interface
uses
Strategy.Interfaces;
type
TFormatterLower = class(TInterfacedObject, IFormatter)
public
function GetFormattedText(AText: IText): string;
@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 / tracking_with_mongo.py
Last active August 29, 2015 13:58
Simple example of using PyMongo and PyTracking
__author__ = 'Diego Garcia'
from pymongo import MongoClient
import ptracking
def make_tracking(cod, user, package):
t = ptracking.PyTracking(ptracking.BRAZIL)
p = t.tracking(cod)
p['package'] = package
@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 / datas.py
Created March 28, 2014 15:06
Exemplo básico de como trabalhar com os métodos strptime e strftime da biblioteca datetime do python
__author__ = 'diego.garcia'
import datetime
dt = datetime.datetime.strptime('February 28, 2014, 7:05 AM', '%B %d, %Y, %I:%M %p')
print(dt.strftime("%d/%m/%Y %I:%M %p"))
@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 $)
// ************************************************************************ //