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

Archive for the ‘Development’ Category

Some notes on Word automation and showing Bookmarks

Posted by jpluimers on 2014/08/27

Though I’ve done this automation in Delphi, this applies to automation from any development platform. In this particular project, the documents used Bookmarks. Those have changed over time, so has the Word support for it.

From Word 2000 until Word you could disable the showing of Bookmarks by setting the ShowBookmarks property to False like this:

<br />ActiveDocument.ActiveWindow.View.ShowBookmarks := False;<br />

Well, when doing this, Office 2013 can throw an error like this:

EOleException: The ShowBookmarks method or property is not available because this command is not available for reading
ErrorCode: 0x800A11FD
Source: Microsoft Word
HelpFile: wdmain11.chm

The full error message does not give any useful search results. But a partial search finds a Word 2013 issue towards the top of the results:

sometimes Words opens the document in Reading layout. Reading layout does not allow all operations in Word 2013.

If a document is protected, and you try to change something you should not, you get an error message like this:

This method or property is not available because the document is a protected document.

Usually, Cindy Meister is very accurate. However this time here code

...ActiveWindow.View = wdPrintView

should have been like

...ActiveWindow.View.Type = wdPrintView

Of course you also have to save/restore this property while you are enabling the ShowBookmarks property.

Read the rest of this entry »

Posted in Delphi, Delphi XE2, Delphi XE3, Delphi XE4, Development, Office, Office 2000, Office 2003, Office 2007, Office 2010, Office 2013, Office Automation, Power User, Software Development, Word | Leave a Comment »

NTLM authentication: Connect to TFS 2013 Git Repository with LibGit2Sharp (via: Gáspár Nagy on software)

Posted by jpluimers on 2014/08/26

I’m fighting some NTLM issues with a proxy server and this might come in handy one day: Connect to TFS 2013 Git Repository with LibGit2Sharp « Gáspár Nagy on software.

https://github.com/gasparnagy/Sample_NtlmGitTest/

–jeroen

 

Posted in .NET, C#, Development, NTLM, Power User, Software Development, Windows | Leave a Comment »

Some notes on Word automation and protected documents

Posted by jpluimers on 2014/08/26

Though I’ve done this automation in Delphi, this applies to automation from any development platform. In this particular project, I had to update Word documents. That is fine, unless your documents are protected. You can find out if a document is protected by probing the ProtectionType property of a Document object.

If a document is protected, and you try to change something you should not, you get an error message like this:

This method or property is not available because the document is a protected document.

If you have control of the documents or templates involved, then you can take the recommended steps from Document Handling with protected Microsoft Office Word Template:

Microsoft Office Word offers the possibility to enable document protection only to certain sections of a document. So you can place Bookmarks used by Dynamics AX in a section that is kept unprotected and the Form Controls in a section where Document Protection is enabled.

If you don’t, then you have to check for protection, unprotect, do the modifications, then re-protect the document. Read the rest of this entry »

Posted in Delphi, Delphi XE2, Delphi XE3, Delphi XE4, Development, Office, Office 2000, Office 2003, Office 2007, Office 2010, Office 2013, Office Automation, Power User, Software Development, Word | Leave a Comment »

JEDI.INC got updated a few months ago: Delphi XE7 seems to be ahead…

Posted by jpluimers on 2014/08/22

While updating a project to a more recent version of Delphi, I also updated the JEDI.INC reference.

Note that since writing Delphi – finding the VERxxx define for a particular Delphi version: use JEDI.INC, the Delphi JEDI project moved from SoureForge to GitHub.

The fun thing: JEDI.INC got updated a few months ago to support Delphi XE7 provisionally.

Given the Delphi release cycle of twice a year, the Delphi Carpathia aka XE7 rumours this summer, I presume Delphi XE7 is near because of:

By then the list of Delphi Versionen | Delphi-Treff will likely also be updaed.

I’m anxious to see if the (Dutch + English) BIG Delphi Conference organized by Barnsten and Blaise from September 11-12 in the Netherlands will be part of the launch tour.

Anyway: here is the JEDI.INC portion with defines:     Read the rest of this entry »

Posted in Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, Software Development | 6 Comments »

Windows 8.x: Three keyboard/mouse ways to zoom in or out on start screen (via: YouTube)

Posted by jpluimers on 2014/08/22

I love it that in Windows you can do everything both by mouse and keyboard.
Take the start screen: there are 3 ways (mouse only, mouse + keyboard, keyboard only) to zoom in/out in the start screen. Read the rest of this entry »

Posted in Keyboards and Keyboard Shortcuts, Power User, Usability, User Experience (ux), Windows, Windows 8 | Leave a Comment »

The Little Mocker (on Test Doubles; via: 8th Light)

Posted by jpluimers on 2014/08/21

Recently, I bumbped into the The Little Mocker | 8th Light by uncle Bob C. Martin.

It’s a nice conversation of a mocker, that explains about Test Doubles (with examples).

Mocks are a bit to Test Doubles like Stunt Doubles are to Body Doubles: a specific kind of Test Doubles.

The conversation step by step explains these Test Doubles probably based on Martin Fowler‘s list of Test Doubles or Mocks, Fakes, Stubs and Dummies at XUnitPatterns.com:

  • Test Dummy: returns nulls (or equivalents null) to consumers as they should not have used: the dummy is a filler in the parameter list to setup the System under Test.
  • Test Double: the generic term (sometimes informally called mocks, but they are not; see Test Mock below).
  • Test Stub: like a Test Dummy, but returns a specific value for a specific test (or group of tests). For instance return true for a LoginStub.
  • Test Spy: like a Test Dummy (or evenTest Stub) but also makes a note (or log) of each call (so you can spy on the calls). It can lead to coupling, so might make your tests fragile.
  • Test Mock: like a Test Spy, but allows verification of certain existence of absence notes or log entries (called Expectations). Like ensuring a certain call to theTest Mock was made with certain parameters.
  • Test Fake: unlike a Test Stub, as fakes have business-like behaviour (so it simulates business behaviour to a certain extent, for instance by having certain data-sets in memory, or responding with certain business logic for instance returning true for certain Login conditions). It also means thatTest Fakes need unit tests of their own.

The links in the above list all contain a small diagram showing the dataflow between the Test Double, System under Test, stc. Jeff Atwood has some nice graphics to go with them at Test Doubles: A Taxonomy of Pretend Objects.

In practice, Stubs and Spies are probably used most, followed by Mocks (either in code or with a Mocking tool).

Notes:

  1. The above order is how the story explains them, not the list by Martin Fowler or the list on WikiPedia.
  2. Want to know more on how to use Test Doubles? Read Test Double at XUnitPatterns.com and Mocks Aren’t Stubs or buy xUnit Test Patterns: Refactoring Test Code: Gerard Meszaros: 9780131495050: Amazon.com: Books.

–jeroen

Posted in Agile, Development, Software Development, Unit Testing | Leave a Comment »

Linux/bash: using mutt to send a file as an email attachment (via: Stack Overflow)

Posted by jpluimers on 2014/08/21

Just in case I need this again:

None of the mutt ones worked for me. It was thinking the email address was part of the attachemnt. Had to do:

echo “This is the message body” | mutt -a “/path/to/file.to.attach” -s “subject of message” — recipient@domain.com

Thanks Alexander Bird for noticing the double-dash, rynop for the modified answer and Chris N for the original answer.

From mutt(1): Mutt Mail User Agent – Linux man page: Read the rest of this entry »

Posted in *nix, bash, Development, Linux, Power User, Scripting, Software Development, SuSE Linux | Leave a Comment »

For GIT/Mercurial users: SourceTree for Windows 1.6.1 – Now Available! (via: SourceTree Blog)

Posted by jpluimers on 2014/08/20

via the SourceTree for Windows 1.6 – Now Available! | SourceTree Blog.

Make sure you download the 1.6.1 version as that is really the latest:

SourceTree 1.6

Enhancements

  • All new file status view
  • Improved diff view
  • New view configurations
  • Cleaner user interface
  • All new welcome wizard

SourceTree 1.6.1

Bugfixes

  • SRCTREEWIN-1902: Fix crash bug when trying to create a new repo from hosted repos screen
  • SRCTREEWIN-1915: Fix a rare crash bug which could happen when closing/re-opening a repository
  • SRCTREEWIN-1894: Staging/unstaging will get ‘stuck’ and not refresh the file list if you turn on ‘always display full console output’ when performing these operations. The refreshing now happens regardless of whether that option is turned on or not.
  • SRCTREEWIN-1897: Fix a crash bug when listing Stash repos from hosted repos list.
  • Confirming removing files now shows the file names in a list so you know which files you’re removing
  • SRCTREEWIN-1909: Can now commit files if committing individually even if they’re at the root and not using staging (so either Mercurial, or no staging mode in Git)

–jeroen

via: SourceTree Release Notes.

 

Posted in Development, DVCS - Distributed Version Control, git, Mercurial/Hg, Software Development, Source Code Management, SourceTree | Leave a Comment »

When deadlocks become livelocks (via: Do deadlocks cause high CPU utilization? – Stack Overflow)

Posted by jpluimers on 2014/08/20

Depending on how you organize locks (for instance via waiting on semaphores or mutexes or spinlocks), deadlocks can become livelocks:

Inability to make forward progress because of conflicting spinlocks is usually referred to as ‘livelock’.

Thanks to Martin James for reminding me of that and Danny Thorpe for describing different ways of locking.

Be sure to read on deadlock prevention as well.

–jeroen

via: c++ – Do deadlocks cause high CPU utilization? – Stack Overflow.

Posted in .NET, C++, Delphi, Development, Software Development | Leave a Comment »

Some more notes on ASUS RT-N66U, firmwares, temperatures and versions

Posted by jpluimers on 2014/08/20

In the the irregular series of ASUS RT-N66U and TomatoUSB posts:

Execute this script from the Tomato USB interface, or a ssh/telnet shell:

cat /dev/mtd0ro | grep bl_version
nvram get os_version
nvram get clkfreq
wl -i eth1 phy_tempsense | awk '{print $1/2+20;}'
wl -i eth2 phy_tempsense | awk '{print $1/2+20;}'
  • Line 1 gets the CFE bootloader version
    (1.0.2 and lower boot with 32K of NVRAM, 1.0.3 and up with 64K of RAM; some Firmwares work around the 32k limitation)
  • Line 2 gets the Firmware model and version
  • Line 3 gets the CPU speed
  • Line 4 and 5 get the temperature for eth1 (2.4 Ghz) and eth2 (5 Ghz) in Celsius
    It is based on the RMerlinDev (firmware developer) information on temperatures: These are for each radio. Take the returned value, divide by 2, then add 20. Results are in Celcius.
    Next to that knowledge, it uses a few tricks on awk calculation, and first parameter in awk (the second parameter would be the hex value of the temperature code in parenthesis) which is easier than shell calculations.

Based on those, I found a few very useful scripts:

–jeroen

Posted in ASUS RT-N66U, Awk, bash, Development, Internet, Network-and-equipment, Power User, Scripting, Software Development, TomatoUSB | Leave a Comment »