This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FileUploadHandler(BaseHandler): | |
""" | |
File upload handler inbehrits the BaseHandler, obtains file data from a POST call | |
""" | |
def post(self): | |
# Retrieve file from the request | |
fileinfo = self.request.files['file'][0] | |
filename = fileinfo['filename'] | |
content_type = fileinfo['content_type'] | |
file_body = fileinfo['body'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ Screen Scaling for Device } | |
function GetScreenScale: Single; | |
var | |
ScreenService: IFMXScreenService; | |
begin | |
Result := 1; | |
if TPlatformServices.Current.SupportsPlatformService (IFMXScreenService, IInterface(ScreenService)) then | |
begin | |
Result := ScreenService.GetScreenScale; | |
end; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ Where AVP is the TViewport3D or self on a TForm3D } | |
var tmpsp: TPoint3D := ScreenHelper.CalculateScreenPosition(AVP.Context, | |
TPoint3D.Zero, Layer3D1.Scale.Point, Layer3D1.RotationAngle.Point, Layer3D1.Position.Point); | |
Circle1.Position.X := tmpsp.X - Circle1.Width / 2; | |
Circle1.Position.Y := tmpsp.Y - Circle1.Width / 2; | |
{ FIX: TPaintBox offset position } | |
tmpsp.X := tmpsp.X - PaintBox1.Position.X; | |
tmpsp.Y := tmpsp.Y - PaintBox1.Position.Y; | |
tmpr := RectF(tmpsp.X -FSize, tmpsp.Y -FSize, tmpsp.X +FSize, tmpsp.Y +FSize); | |
{ ABMP is a TBitmap } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ Obtains device scaling } | |
function GetScreenScale: Single; | |
var | |
ScreenService: IFMXScreenService; | |
begin | |
Result := 1; | |
if TPlatformServices.Current.SupportsPlatformService (IFMXScreenService, IInterface(ScreenService)) then | |
begin | |
Result := ScreenService.GetScreenScale; | |
end; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tmpsp: TPoint3D := TPoint3D.Zero; | |
// Obtain the screen coordinate by using the WorldToScreen method | |
tmpsp := self.Context.WorldToScreen(TProjection.Camera, Layer3D1.Position.Point); | |
writeln('2D Position: ' + tmpsp.X.ToString + ', ' + tmpsp.Y.ToString); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A docker-compose must always start by the version tag. | |
# We use '3' because it's the last version at this time. | |
version: '3' | |
# You should know that docker-composes works with services. | |
# 1 service = 1 container. | |
# For example, a service maybe, a server, a client, a database... | |
# We use the keyword 'services' to start to create services. | |
services: | |
# As we said at the beginning, we want to create: a server and a client. |