The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,152 other subscribers

Archive for November 28th, 2017

Kriscode.Hint := ‘Kris”s coding blog’: Lazarus IDE on ARM Ubuntu (Raspberry Pi, Ubuntu Touch, etc)

Posted by jpluimers on 2017/11/28

Interesting writeup as Lazarus and Free Pascal have come a long way: [WayBackKriscode.Hint := ‘Kris”s coding blog’: Lazarus IDE on ARM Ubuntu (Raspberry Pi, Ubuntu Touch, etc)

Via:

–jeroen

Posted in Development, FreePascal, Lazarus, Pascal, Software Development | Leave a Comment »

Implementing Memoize in Delphi 2009 – Community Blogs – Embarcadero Community

Posted by jpluimers on 2017/11/28

I think it was Stefan Glienke who pointed me at the Memoisation pattern: [WayBackImplementing Memoize in Delphi 2009 – Community Blogs – Embarcadero Community

Or in laymans terms: caching with generic functions and dictionaries.

Note the Archive.is link is way better readable than the WayBack link, so below I’ve saved parts only in Archive.is.

It points to two other interesting reads:

Later I found it was indeed Stefan who pointed me to the above links and also came up with this very small Memoisation example which is based on Spring4D:

and guess what? because we have interfaced based dictionary this is super easy, let me just hack an example, 5mins6:52 PM

function BuildCache: Tfunc<string,string>;
var
 cache: IDictionary<string,string>;
begin
 cache := TCollections.CreateDictionary<string,string>;
 Result :=
   function(s: string): string
   begin
     if not cache.TryGetValue(s, Result) then
     begin
       Sleep(1000); // hard work! ;)
       Result := ReverseString(s);
       cache.Add(s, Result);
     end;
   end;
end;

Since the returned anonymous method captures the dictionary its kept inside and once the anonymous method goes out of scope the dictionary is also cleaned, want to reset the cache? Just create a new one and throw the old one away.

Need thread safety? just add

System.TMonitoy.Enter/Leave(cache.AsObject);

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

iptables debugging « \1

Posted by jpluimers on 2017/11/28

Using the TRACE target: [WayBackiptables debugging « \1 via [WayBack] iptables Debugging using the TRACE chain – Kristian Köhntopp – Google+

Docs:

TRACE
This target marks packes so that the kernel will log every rule which match the packets as those traverse the tables, chains,
rules. (The ipt_LOG or ip6t_LOG module is required for the logging.) The packets are logged with the string prefix: “TRACE:
tablename:chainname:type:rulenum ” where type can be “rule” for plain rule, “return” for implicit rule at the end of a user
defined chain and “policy” for the policy of the built in chains.
It can only be used in the raw table.

Way more details in the linked article.

–jeroen

Posted in *nix, *nix-tools, Firewall, Infrastructure, iptables, Power User | Leave a Comment »

 
%d bloggers like this: