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 1,860 other subscribers

Archive for November, 2017

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 »

Kaart met onontplofte bommen in Amsterdam nu openbaar

Posted by jpluimers on 2017/11/27

De interactieve bommenkaart van de gemeente die laat zien waar onontplofte bommen uit de Tweede Wereldoorlog liggen, is openbaar gemaakt.

Source: [Archive.is] Kaart met onontplofte bommen in Amsterdam nu openbaar

Kaart: [Archive.is] Grote kaart – Dataportaal

Eerder artikel: [Archive.isKaart met verdachte bommen onder Amsterdam bijgewerkt

Dichtbij: [Archive.isVerdachte gebieden: Monte Viso / Gran Paradiso / Pasubio

 

Posted in LifeHacker, Power User | Leave a Comment »

OS X dmg files – Disk Utility usually creates them read-only

Posted by jpluimers on 2017/11/27

While recovering the backups of a Retina MacBook Pro, I needed to know if I could mount a Disk Utility backup image on read-only mode.

Finding that info was a tad difficult as most results were about making dmg files read-write. This already hinted me in that most dmg files were readonly.

The main tool for handling dmg files is hdiutil. for which you can get more info here:

The hdiutil command imageinfo will output a Format: line having the kind of dmg image:

  • UDRW – UDIF read/write image
  • UDRO – UDIF read-only image
  • UDCO – UDIF ADC-compressed image
  • UDZO – UDIF zlib-compressed image
  • UDBZ – UDIF bzip2-compressed image (OS X 10.4+ only)
  • UFBI – UDIF entire image with MD5 checksum
  • UDRo – UDIF read-only (obsolete format)
  • UDCo – UDIF compressed (obsolete format)
  • UDTO – DVD/CD-R master for export
  • UDxx – UDIF stub image
  • UDSP – SPARSE (grows with content)
  • UDSB – SPARSEBUNDLE (grows with content; bundle-backed)
  • RdWr – NDIF read/write image (deprecated)
  • Rdxx – NDIF read-only image (Disk Copy 6.3.3 format)
  • ROCo – NDIF compressed image (deprecated)
  • Rken – NDIF compressed (obsolete format)
  • DC42 – Disk Copy 4.2 image

All compressed formats seem to be read-only and of course all read-only formats. Which then basically leaves only these as (potentialy) read-write image types:

  • UDRW
  • UFBI
  • UDSP
  • UDSB
  • RdWr
  • DC42

References and further reading:

–jeroen

Posted in Uncategorized | Leave a Comment »

Chrome Store Foxified: Enables the Google Chrome Store and Opera Addons Website for Firefox.

Posted by jpluimers on 2017/11/27

Most of my browser life is in Chrome, but the memory consumption and CPU usage has increased so much over time so it, err, become less than optimal.

Given the new FireFox is supposed to use far less memory and CPU than previous FireFox versions, I want to try it, but since so much of my Chrome life is about Chrome Extensions, I was glad to discover [WayBackChrome Store Foxified

by Nicolas AragoneNoitidart
Enables the Google Chrome Store and Opera Addons Website for Firefox. Point and click to install Opera/Chrome extensions straight into Firefox.

via:

–jeroen

Read the rest of this entry »

Posted in Chrome, Chrome, Firefox, Google, Power User, Web Browsers | Leave a Comment »

DNS Knowledge DNS Tutorial, News and Tools: How to setup Quad9 DNS on a Linux

Posted by jpluimers on 2017/11/24

Reminder to self so I try this out: [Archive.isDNS Knowledge DNS Tutorial, News and Tools: How to setup Quad9 DNS on a Linux

Quad9 is a free security solution that uses DNS to protect your systems against the most common cyber threats and you can setup it on Linux.

Related: [Archive.is] Quad9 | Internet Security & Privacy In a Few Easy Steps:

Quad9 is a free security solution that uses DNS to protect your system against the most common cyber threats. It improves your system’s performance, plus, it preserves and protects your privacy. It’s like an immunization for your computer.

Via: [WayBack] Remember 8.8.8.8 (Google DNS)? Now we have 9.9.9.9 from IBM/Quad9 that brings together cyber threat intelligence about malicious domains…. – nixCraft – Google+

Remember 8.8.8.8 (Google DNS)? Now we have 9.9.9.9 from IBM/Quad9 that brings together cyber threat intelligence about malicious domains. It can block malware and other bad domains. https://www.dnsknowledge.com/tutorials/how-to-setup-quad9-dns-on-a-linux/ and https://quad9.net/#/ What do you think? Do you use Google DNS or OpenDNS or ISP DNS or newer Quad9 DNS?

–jeroen

Posted in *nix, DNS, Internet, Power User, Security | Leave a Comment »

macbook – OS X 10.9.5 hangs with grey spinner; safe mode last message is “payload 2: device was reinitialized” – Ask Different

Posted by jpluimers on 2017/11/24

[WayBackmacbook – OS X 10.9.5 hangs with grey spinner; safe mode last message is “payload 2: device was reinitialized” – Ask Different

[WayBackRecovery partition: “Restore From Time Machine Backup” stuck at 43.6% for more than 60 minutes – Ask Different

Steps since then:

  1. Restoring an image backup failed: same situation
    • (it took an hour to verify the media, then an OK button appeared before continuing to restore in the middle of the night; actual restore took 4+ hours)
  2. Reinstalling OS X 10.9.5 failed: error -4403F
  3. Restoring a prior Time Machine backup hung at less than 50% (taking like 6 hours)
  4. Reinstalling OS X 10.9.5 over a different fiber connection worked
  5. Mounting the image backup succeeded, but took 3 hours to complete “verifying…”
  6. Migration Assistent on the image backup worked fine

In total it took 2.5 days to get the machine back in working condition.

Related links:

There was no transparent proxy inbetween the MacBook and Apple so these didn’t help:

What did help was ensuring there was only ONE NAT in between the MacBook and Apple.

–jeroen

 

Posted in Apple, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, OS X 10.9 Mavericks, Power User | Leave a Comment »

MCL65 – a cycle exact 6502 in an FGPA

Posted by jpluimers on 2017/11/24

Cool stuff: [WayBackMCL65

MicroCore Labs MCL65 6502 core

The MC65 is an ultra-small footprint, microsequencer-based, 100% instruction-set compatible, cycle-exact NMOS 6502 core that can be implemented in any FPGA or ASIC technology which can utilize as little as 252 LUTs  (0.77%) of a Xilinx Spartan-7 FPGA. It has also been ported to a Xilinx Spartan-3 device where it uses about 10% of the part.

The MCL65 is instruction set compatible with the original NMOS version of the 6502 which was the processor used in computers and game machines such as the Commodore VIC20, Apple II, Atari-2600, and the Commodore-64 as well as  many others.

It runs inside an Apple ][ fine: see the below videos by MicroCore Labs

  • [WayBack] Download
  • [WayBack] MCL65 Working!: The MCL65 is currently running inside of a Commodore VIC-20 computer!  I have no game cartridges at the moment, so I am just running the classic a=a+1 BASIC counting program…
  • [WayBack] MCL65 running on VIC-20: Here are a few pictures of the MCL65 running on a VIC20. Video is available at MicroCore Labs YouTube Channel
  • [WayBack] MCL65 in a Spartan-3: Just ported the MCL65 to a Xilinx Spartan-3 board which contains an XC3S250E. 490 LUTs are used, which is 10% of the device.
  • [WayBack] MCL65 running on Atari 2600: The Atari 2600 just arrived in the mail, so replaced the MOS6507 CPU with the MCL65 core which is fitted the Xilinx Spartan-7 board and then to a 28-pin header for the 6507 package…
  • [WayBack] MCL65 works in Apple II+: Received the Apple II+ in the mail today but it did not come with any diskettes. I used a terrific tool, ADTPro, to transfer disk images from my PC over to the Apple using the cassette port…
  • [WayBack] MCL65 running Apple II+ Programs:I uploaded some videos of the system running a few applications and games. My hope was to test the MCL65 on a variety of programs that could demonstrate the instruction as well as cycle accuracy…

Via:

–jeroen

Read the rest of this entry »

Posted in 6502, History | Leave a Comment »

Use operator overloading for classes with non-ARC compiler · GitHub

Posted by jpluimers on 2017/11/23

[WayBackUse operator overloading for classes with non-ARC compiler · GitHub

The trick: do not use class operator but use class function &&op_ with the special operator name in the table referenced below. Just follow the bulleted example links to get an idea.

Bonus: it works on class helper constructs as well.

Officially this unsupported and with the non-ARC compiler you will have a risk of memory leaks.

But it’s so much fun as these links prove:

The usual operator gotchas apply here as well: Delphi operator overloading: table of operators, names, and some notes on usage and ‘glitches’.

The operators you could try: [WayBackOperator Overloading (Delphi) – RAD Studio

Oh, this thread needs some change now: [WayBackList of Delphi language features and version in which they were introduced/deprecated – Stack Overflow

–jeroen

Posted in Delphi, Development, Software Development | 1 Comment »

Capitalization Conventions – more than Canceled not Cancelled

Posted by jpluimers on 2017/11/23

[WayBackCapitalization Conventions

Posted in .NET, Delphi, Development, Software Development | 1 Comment »