Skip to content

Instantly share code, notes, and snippets.

View edwinyzh's full-sized avatar

Edwin Yip edwinyzh

View GitHub Profile
@edwinyzh
edwinyzh / .block
Created September 27, 2016 09:32 — forked from mbostock/.block
Collapsible Indented Tree
license: gpl-3.0
unit Lyna.Generators;
interface
uses
SysUtils, Rtti, TypInfo;
type
TRange = record
strict private
type
TObjectHelper = class helper for TObject
public
class function &&op_LogicalOr<T: class>(A, B: T): T; static;
end;
class function TObjectHelper.&&op_LogicalOr<T>(A, B: T): T;
begin
if A <> nil then
Result := A
@edwinyzh
edwinyzh / Project1.dpr
Created October 21, 2016 04:07 — forked from superswanman/Project1.dpr
Use operator overloading for classes with non-ARC compiler
program Project1;
{$APPTYPE CONSOLE}
uses
System.SysUtils, System.Classes, System.Types, Vcl.Dialogs;
type
TStringListEx = class(TStringList)
public
@edwinyzh
edwinyzh / gist:1b8693623502940ad594e3aab1387933
Created February 15, 2017 06:48
THtPanel access violation error for the <control> special tag
date/time : 2017-02-15, 14:42:16, 728ms
computer name : EDWIN-T450
user name : edwin <admin>
registered owner : edwin
operating system : Windows 7 x64 Service Pack 1 build 7601
system language : Chinese (Simplified)
system up time : 1 day 22 hours
program up time : 1 minute 35 seconds
processors : 4x Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
physical memory : 2970/7888 MB (free/total)
@edwinyzh
edwinyzh / client PC madExcept log (stacktrace)
Last active February 16, 2017 07:41
mORMot SQLite3 "cannot rollback - no transaction is active" error
date/time : 2017-02-16, 13:37:20, 734ms
operating system : Windows XP Service Pack 3 build 2600
system language : Chinese
system up time : 3 hours
program up time : 3 hours
processors : 4x Intel(R) Atom(TM) CPU D525 @ 1.80GHz
physical memory : 1494/2037 MB (free/total)
free disk space : (C:) 17.47 GB
display mode : 1024x768, 32 bit
allocated memory : 214.53 MB
@edwinyzh
edwinyzh / Unit1.dfm
Created May 24, 2017 06:50
Prove that the each OTL task has a built-in cancellation token and I use it a lot!
object frmMain: TfrmMain
Left = 0
Top = 0
Caption = 'frmMain'
ClientHeight = 571
ClientWidth = 798
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
@edwinyzh
edwinyzh / OtlTaskTeriminationTestUnit.pas
Last active May 27, 2017 14:21
Demonstrate the blocking issue of OTL task termination
(*
1 - the thread proc.
*)
procedure MyThreadProc(task: IOmniTask);
begin
while not task.Terminated do begin
SubProcedureThatWillTakeAtLeast3Second;
if task.Terminated then Exit;
SubProcedureThatWillTakeAtLeas2Second;
unit UDebouncedEvent;
interface
uses
System.Classes, System.SysUtils, System.DateUtils, FMX.Types;
type
TDebouncedEvent = class (TComponent)
private
unit NonBlockingDlgHelperU;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
const
WM_ShowDlgA = WM_APP + 1;