Skip to content

Instantly share code, notes, and snippets.

View menjaraz's full-sized avatar

Menjanahary menjaraz

View GitHub Profile
@menjaraz
menjaraz / Singleton.Example.pas
Created January 5, 2018 09:21 — forked from drgarcia1986/Singleton.Example.pas
Esqueleto para criação de uma classe Singleton em Delphi
unit Singleton.Example;
interface
type
TMyClass = class
strict private
class var FInstance : TMyClass;
private
class procedure ReleaseInstance();
@menjaraz
menjaraz / EnterAsTab.pas
Created January 5, 2018 09:19 — forked from martinusso/EnterAsTab.pas
Make the Enter key work like Tab in Delphi applications
{
In the Main Form of application
}
procedure TMainUI.DoEnterAsTab(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.Message = WM_KEYDOWN then
begin
if (not (Screen.ActiveControl is TCustomMemo)) and (not (Screen.ActiveControl is TButtonControl)) then
begin
@menjaraz
menjaraz / Project1.dpr
Created January 5, 2018 09:11 — forked from drgarcia1986/Project1.dpr
Generic Singleton Pattern in Delphi
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
uSingletonGeneric in 'uSingletonGeneric.pas',
uMyClass in 'uMyClass.pas';
@menjaraz
menjaraz / delphi-directives.md
Last active January 5, 2018 09:03 — forked from quasoft/delphi-directives.md
Delphi product/compiler versions

List of Delphi product/compiler versions and conditional directives:

Product Product Version CompilerVersion Directive
Delphi 10.2 Tokyo 25 32 VER320
Delphi 10.1 Berlin 24 31 VER310
Delphi 10 Seattle 23 30 VER300
Delphi XE8 22 29 VER290
Delphi XE7 21 28 VER280
Delphi XE6 20 27 VER270
@menjaraz
menjaraz / emailAdressValidator.pas
Created January 5, 2018 08:56 — forked from martinusso/emailAdressValidator.pas
Delphi Email Address Validator
// uses RegularExpressions;
function ValidateEmail(const emailAddress: string): Boolean;
var
RegEx: TRegEx;
begin
RegEx := TRegex.Create('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]*[a-zA-Z0-9]+$');
Result := RegEx.Match(emailAddress).Success;
end;
@menjaraz
menjaraz / Delphi-version-info.txt
Created January 5, 2018 08:54 — forked from jpluimers/Delphi-version-info.txt
Delphi version info
BDS # HKCU/HKLM registry path Name CompilerVersion RTLVersion Define Characterset Frameworks DllSuffix ProjectVersion Architectures HKCU HKLM
----- ----------------------- ---- --------------- ---------- ------ ------------ ---------- --------- -------------- ------------- ---- ----
1 \Software\Borland\BDS\1.0 Borland C# Builder 1 C# C# C# Unicode .NET ???? ???? C# .NET 1 hkcu:\Software\Borland\BDS\1.0 hklm:\Software\Borland\BDS\1.0
2 \Software\Borland\BDS\2.0 Borland Delphi 8 none/16.0 none/16.0 VER160/VER160 Ansi/Unicode VCL/.
{$IFDEF VER80} ShowMessage('Delphi 1');{$ENDIF}
{$IFDEF VER90} ShowMessage('Delphi 2');{$ENDIF}
{$IFDEF VER100} ShowMessage('Delphi 3');{$ENDIF}
{$IFDEF VER120} ShowMessage('Delphi 4');{$ENDIF}
{$IFDEF VER130} ShowMessage('Delphi 5');{$ENDIF}
{$IFDEF VER140} ShowMessage('Delphi 6');{$ENDIF}
{$IFDEF VER150} ShowMessage('Delphi 7');{$ENDIF}
{$IFDEF VER160} ShowMessage('Delphi 8');{$ENDIF}
{$IFDEF VER170} ShowMessage('Delphi 2005');{$ENDIF}
{$IFDEF VER180} ShowMessage('Delphi 2006');{$ENDIF}
  1. Place server.js and sse.html in the same directory
  2. npm install hapi nipple
  3. node server.js
  4. In browser that supports Server Sent Events, navigate to http://localhost:3000/sse.html
  • Navigating to this page triggers a connection to /stream.
  • /stream connects to /events and proxies the data back to the client.
  • /events provides the actual Server Sent Events stream.
@menjaraz
menjaraz / hapi.js
Created February 16, 2016 06:49 — forked from lwe/hapi.js
Server-sent-events with trial for hapi and one with a plain node.js http server.
var Hapi = require('hapi');
var stream = require('stream');
// Create a server
var server = Hapi.createServer('localhost', 8000);
// Add a route
server.route({
method: 'GET',
path: '/hello',
@menjaraz
menjaraz / gist:9e71d2bea2dfbcdd59ce
Created February 16, 2016 06:45 — forked from iampeter/gist:5af9c9e113e41c954364
Simple proxy with hapi.js to fix your CORS problems

Problem

While building a JavaScript single page app that acts as a front-end to multiple backend servers, even if they are on the same host as the web app - but on different ports, you come across CORS issues.

Solution

Use a simple node.js + hapi.js server to:

  1. Serve your static single page app
  2. Act as proxy to the backend servers