Skip to content

Instantly share code, notes, and snippets.

TThread.CreateAnonymousThread(procedure ()
var
I: Integer;
begin
TThread.Synchronize(nil,
procedure
begin
{ Update UI components at begining }
end
@an01f01
an01f01 / rabbitmq-docker-compose.yaml
Last active February 26, 2025 22:09
Docker compose for a rabbitmq Docker image
version: "3.7"
services:
rabbitmqqtt:
build: rabbitmq/
ports:
- "5672:5672" # AMQP port
- "1883:1883" # MQTT port
- "15672:15672" # Management UI port
volumes:
@an01f01
an01f01 / Dockerfile
Last active February 26, 2025 22:10
RabbitMQ Docker File
# Use the official RabbitMQ image as the base image
FROM rabbitmq:latest
# Set environment variables for configuration
ENV RABBITMQ_DEFAULT_USER=utest
ENV RABBITMQ_DEFAULT_PASS=test1234
# Add labels for better maintainability
LABEL version="1.0"
LABEL description="Dockerfile for running RabbitMQ"
unit AsyncThread;
interface
uses
{Delphi}
System.SysUtils
{Project}
;
unit PlatformColorMode;
interface
uses
FMX.Platform
{$IFDEF MSWINDOWS}
, System.SysUtils, System.Win.Registry, Winapi.Windows
{$ENDIF}
;
procedure TFrmMain.OnPyModuleLoad(Sender: TObject);
begin
with Sender as TPythonModule do
begin
AddDelphiMethod( 'printme',
ConsoleModule_Print,
'printme(handle,val1,val2,val3)');
end;
end;
@an01f01
an01f01 / delphi_python_parsing.pas
Last active March 13, 2025 09:34
Method parses function arguments from Python to Delphi
function TFrmMain.ConsoleModule_Print( pself, args : PPyObject ) : PPyObject; cdecl;
var
pprint: NativeInt;
val1: Integer;
val2: Single;
val3: PAnsiChar;
begin
with GetPythonEngine do
begin
if (PyErr_Occurred() = nil) and
@an01f01
an01f01 / py4delphi_test.py
Last active December 27, 2024 22:36
py4delphi_test.py
from PythonModule1 import printme
def print_data(handle):
print('starting script...')
for i in range(10000):
print(i)
val1 = 2.5 + i
val2 = 'this is the iteration number ' + str(i)
def make_app():
settings = dict(
cookie_secret=str(os.urandom(45)),
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
default_handler_class=ErrorHandler,
default_handler_args=dict(status_code=404)
)
return tornado.web.Application([
(r"/", StatusHandler),
class StatusHandler(BaseHandler):
async def get(self):
self.set_status(200)
self.write({'message': 'File upload REST API working as expected'})
self.finish()
class UploadHandler(BaseHandler):
async def get(self):
return self.render('uploads.html')