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,862 other subscribers

Archive for July, 2014

Using inotify-wait to check filesystem events

Posted by jpluimers on 2014/07/21

Thanks to Using inotify-wait to check filesystem events I got pointed to How to use inotify-tools to trigger scripts on filesystem events which is now on my research list.

–jeroen

Note that Kristian later on commented this:

The solution shown in the article has race conditions and should not be used.

It is based on

while :
do
inotifywait $options && run-backup
done

and that means that while the backup runs, the directory in question is unmonitored. When the backup finishes, new changes may have been accumulating during backup run, but without being picked up by the backup.

A proper solution would do something like

inotifywait -m $options | while read line
do
do-something-that-logs-multile-changes-and-triggers-backup-once
done

The important thing is that “inotifywait -m” does not terminate and hence no changes will be lost. It is wrong to run the backup once in full for each change, though.

 

Posted in *nix, *nix-tools, Linux, Monitoring, Power User, SuSE Linux | Leave a Comment »

Good starting point for RAID information

Posted by jpluimers on 2014/07/21

Accurate information about RAID is scattered around the internet.

This is a good starting point IBM’s Understanding RAID technology.

–jeroen

Posted in Power User, RAID | Leave a Comment »

Devicons is a full stack iconic font with Development tool Glyphs

Posted by jpluimers on 2014/07/19

Devicons is a full stack iconic font ready to be shipped with your next project. Created, handcrafted and coded by Theodore Vorillas Devicons contains 85 vectorized sharp glyphs . Devicons iconic font is free to use and licensed under MIT. via vorillaz/devicons. Read the rest of this entry »

Posted in Development, Software Development | Leave a Comment »

Drawing fully justified text to a canvas (via: Parnassus OÜ – Delphi Consulting & Plugins – parnassus.co)

Posted by jpluimers on 2014/07/19

Though fully justified text is most often in print, and not much in user interfaces any more, this might come in useful one day (it is based on the GDI functions TextOut and SetTextJustification):

David Millington Posted: Have you ever wanted to draw fully justified text ie, text that adheres to both the left and right sides of the destination rectangle? It’s more complicated than it seems, and there’s definitely no inbuilt support in the VCL. But here’s how to do it, including an open-source unit you can drop into your applications and use.

Drawing fully justified text to a canvas | Parnassus – Delphi Consulting & Plugins.

–jeroen

via:

Posted in Delphi, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Development, Software Development | Leave a Comment »

BitTorrent Labs: BitTorrent Sync – distributed peer-to-peer syncing your files without online cloud storage

Posted by jpluimers on 2014/07/18

Interesting for people that do not trust Cloud Storage providers: BitTorrent Labs’ BitTorrent Sync.

I’ve tried an early version, and it works “OK”. Not yet as well-integrated like for instance DropBox, but stable and fast enough.

Important thing for me: works on *nix, OS X and Windows. Hopefully mobile devices will follow soon.

At the time of writing (May 2013), it is the only cross platform freeware entry in Comparison of file synchronization software – Wikipedia, the free encyclopedia.

In the mean time, Thomas Mueller (dummzeuch)wrote a nice blog post with background information on this: Bittorrent Sync, a secure DropBox alternative » twm’s blog.

–jeroen

Posted in *nix, Apple, DropBox, Linux, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, OS X 10.8 Mountain Lion, Power User, SocialMedia, SuSE Linux | Leave a Comment »

(Old style Pascal objects): Could you please remind me if Objects support polymorphism? For instance, I…

Posted by jpluimers on 2014/07/17

I observe an increase of people not asking questions on Stack Overflow any more…

Today, two interesting questions caught my eye.

The first one was by Martijn Coppoolse about Is it possible to figure out whether a type’s property has a ‘stored’ flag or not, preferably without having to create an instance of that type? (note: emphasis is mine)

Then the most interesting one (note this is about old Turbo Pascal style object syntax that is still available in Delphi, yes polymorphism with the object keyword): Could you please remind me if Objects support polymorphism? by Roman Yankovsky.

–jeroen

PS: Martijn posted the solution he used:

So I tried looking at the StoredProc pointer, and I can differentiate between three states:
  1. nil, which means stored False;
  2. Pointer(1), which means that no stored flag was specified;
  3. an actual pointer, which means that a method was specified; and the pointer seems to point at the relevant method’s CodeAddress. However, we always use private methods for that, and those don’t seem to be enumerated by GetMethods.

Still, those three states are basically what I needed: don’t include an element when StoredProc = nil; when StoredProc = Pointer(1) make it compulsory, and make it optional otherwise when it’s a pointer.
Thanks a lot to all who helped! +Qing-Shan Xiao +Jeroen Wiert Pluimers +Asbjørn Heid

–jeroen

Posted in Delphi, Delphi 7, Development, Software Development | 3 Comments »

Delphi: a few short notes on LoadString and loading shell resource strings for specific LCIDs

Posted by jpluimers on 2014/07/17

I’m not a real expert on LCID (the values like 1033 (aka 0x409 or $409) and 1043 (aka 0x413 or $413), but here are a few notes on stuff that I wrote a while ago to obtain shell32.dll resource strings for various LCIDs.

The most often used way to load resource strings is by calling the LoadString Windows API call which loads the string for the currently defined LCID.

To get them for a different LCID, there are two ways:

  1. Set the LCID for the current thread (don’t forget to notify the Delphi RTL you did this, and update FormatSettings)
  2. Write an alternative for LoadString that gets a string for a specific LCID (so you can keep the current thread in a different LCID)

The first method – altering the LCID of the current thread – is done using SetThreadLocale in Windows XP or earlier, and SetThreadUILanguage in Windows Vista/2008 and up (I’m not sure on the timeline of Windows Server versions, but I guess the split is between 2003 and 2008) as mentioned at SetThreadLocale and SetThreadUILanguage for Localization on Windows XP and Vista | words.

SetThreadLocale is deprecated, as Windows has started switching from LCID to Locale Names. This can cause odd behaviour in at least Delphi versions 2010, XE and XE2. See the answers at delphi – GetThreadLocale returns different value than GetUserDefaultLCID? for more information.

But even on XP it has the potential drawback of selecting language ID 0 (LANG_NEUTRAL) which selects the English language if it is available (as that is in the default search order). Both Writing Win32 Multilingual User Interface Applications and the answers to LoadString works only if I don’t have an English string table and Windows skipping language-specific resources and the Embarcadero Discussion Forums: How to load specific locale settingsd thread that describe this behaviour.

To work around that, you can do two things: store your resource strings in locale dependent DLLs, or (if you don’t write those DLLs yourself), write an alternative for LoadString.

I’ve done the latter for Delphi, so I could load strings for a specific LCID from the Shell32.dll.

For a full overview of all these strings, see http://www.angelfire.com/space/ceedee/shell32stringtables.txt

A few pieces of code.

You can get the full code at the BeSharp – Source Code Changeset 100520 (now at bitbucket too). Read the rest of this entry »

Posted in Delphi, Delphi XE2, Delphi XE3, Delphi XE4, Development, internatiolanization (i18n) and localization (l10), Software Development | 4 Comments »

“Weird Al” Yankovic – Word Crimes – YouTube

Posted by jpluimers on 2014/07/16

Thanks Roderick Gadellaa for sharing:

 Music video by “Weird Al” Yankovic performing Word Crimes.

Yankovic’s new album “Mandatory Fun” out now.

–jeroen

via: “Weird Al” Yankovic – Word Crimes – YouTube.

Posted in Uncategorized | Leave a Comment »

Delphi: Variant versus OleVariant (via: RAD Studio API Documentation)

Posted by jpluimers on 2014/07/16

I used to forget about the difference between Variant and OleVariant, and used them like this:

Use OleVariants for OLE, and Variants for non OLE.

There is no need to manually clear them.

Luckily I was right, as the differences are documented in the Delphi on-line help at OLE-compatible Variant type (the oldest I could find was the Delphi 2010 OleVariant documentation): Read the rest of this entry »

Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Development, Software Development | Leave a Comment »

How to change the WiFi network my Chromecast is connected to (via: Frequently Asked Questions – Chromecast Help)

Posted by jpluimers on 2014/07/15

Duh: don’t start the Chromecast extension in Google Chrome, but run Chromecast.app on your Macbook (:

To change the WiFi network your Chromecast is connected to, simply open up the Chromecast app on your phone, tablet, or computer and select your Chromecast from the list. From the Chromecast settings page, select your current Wi-Fi network name and select a new network from the drop-down list.

–jeroen

via: Frequently Asked Questions – Chromecast Help.

Posted in Apple, Chromecast, Google, Mac, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, Power User | Leave a Comment »