Using minicom with an empeg

13 Jun 2022 13:38

It’s been many years since I last connected my empeg player to a Linux PC, and the muscle memory’s gone. Here’s how to make it work with Ubuntu 20.04.

» read more

Pod DNS Problems

25 Feb 2022 08:42

I’ve got an extra instance of CoreDNS running in my cluster, serving *.k3s.differentpla.net, with LoadBalancer and Ingress names registered in it, and it’s working fine for queries to the cluster. It’s not working fine for queries inside the cluster. What’s up with that?

» read more

arm64 support

3 Feb 2022 08:46

Because I’m running my k3s cluster on Raspberry Pi 4 nodes, and they’re ARM-64 (aarch64), I keep running into problems where applications are compiled for x86_64 (amd64) and don’t run.

» read more

Traefik Ingress

31 Jan 2022 08:46

I’m in the middle of installing ArgoCD (blog post will appear later). Rather than use up another LoadBalancer IP address for it (and mess around with TLS), let’s talk about using an Ingress. It’s entirely possible that I can convert the previously-installed docker registry and Gitea to use one as well.

» read more

Colouring the 'iex' prompt

9 Jan 2022 12:17

If you’ve got separate dev, test and prod environments, it can help to use colour to tell you which one you’re logged into. Here’s how to colour the iex prompt appropriately.

» read more

Erlang/Elixir Cookies and Kubernetes

9 Jan 2022 10:27

Distributed Erlang and Elixir applications use a shared secret called a “cookie”. It’s just a string of alphanumeric characters. All nodes in the cluster must use the same cookie. Let’s take a look at what that means in a Kubernetes context.

» read more

Upgrading k3s

3 Jan 2022 14:38

The basic plan is to drain each node in turn, apply the upgrade and then uncordon the node. I’m upgrading from v1.21.7+k3s1 to v1.22.5+k3s1.

» read more

Installing Helm

20 Dec 2021 20:45

To install other things, we’re going to want to use Helm. So let’s install that first.

» read more

git start

10 Dec 2021 11:16

When I create a new git repository, I prefer for there to be an empty commit at the beginning of history.

» read more

k3s on Raspberry Pi: iSCSI

9 Dec 2021 19:42

The default option for persistent volumes on k3s is local-path, which provisions (on-demand) the storage on the node’s local disk. This has the unfortunate side-effect that the container is now tied to that particular node.

» read more

Multiple Laptops, Multiple Monitors

11 Sep 2021 19:04

At home, I’ve got a rather nice setup with two Dell U2520D monitors on my desk, which I’m currently using from my (work) Linux desktop. However, more recently, I’m trying to strike a better work/life balance, so I’ve decided to start making more use of my (personal) Microsoft Surface Book 3 laptop, but I’d like to continue using the two monitors (which are also mine; I never bothered filing the expense claim).

» read more

failed to start child: :ranch_server_proxy

8 Jun 2021 14:02
** (Mix) Could not start application example_server: ExampleServer.Application.start(:normal, []) returned an error: shutdown: failed to start child: {:ranch_embedded_sup, :example_server}
    ** (EXIT) shutdown: failed to start child: :ranch_server_proxy
        ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
» read more

ErlangLS version?

2 Jun 2021 09:16

I recently had to report a bug against ErlangLS (the Erlang Language Server). Here’s how I discovered the version number:

» read more

Integrating direnv with ghc

2 Feb 2020 15:32

I’m reading “Practical Haskell”, which requires a different version of Haskell than Ubuntu installs so I figured I’d add another entry to my direnv series.

» read more

Elixir's use functionality

2 Jan 2020 15:54

use is a way that you can inject code into your module. Elixir uses this for boilerplate in GenServer, and Phoenix uses it for metaprogramming.

» read more

A UPS post-mortem

21 Feb 2019 10:48

This morning, something electrical went wrong in my “network cabinet” (hall cupboard), which knocked me offline for about an hour. Here’s the post-mortem.

» read more

Rebuilding kerl Installations

30 Jan 2019 16:50

If kerl list installations is displaying Erlang installations that you deleted ages ago, and you’ve got all of your installations in ~/.kerl/erlangs/, you can rebuild the list by running the following command:

» read more

jq reduce

11 Jan 2019 19:38

I found myself having to process a large JSON file using jq --slurp, and it was using up a lot of memory, so I thought it was time to learn about jq’s reduce function.

» read more

gen_server:enter_loop

12 Jun 2018 14:52

When you use gen_server:start/3,4 or gen_server:start_link/3,4, the call blocks until the other process has finished running init/1.

» read more

git rebase tips

27 Oct 2017 13:10

This is an internal email I wrote almost exactly 2 years ago. I had to refer to it today, and I figured that it bears sharing publicly.

» read more

No new blog engine

26 Apr 2015 08:13

Periodically, I become unhappy with my blog implementation and decide that I should do something about it.

» read more

Running Chromium as a Dashboard

28 Jan 2015 08:26

On my desk I have a dashboard (an “information radiator”) that displays various useful things, such as the build status of various Jenkins jobs, clocks showing important timezones (Electric Imp is a distributed company), and so on.

» read more

Reverting Erlang 17

9 Oct 2014 12:22

We’ve found a couple of problems with Erlang R16 that mean that one of our projects requires Erlang 17. Conversely, we’ve found a couple of problems with Erlang 17 that mean that one of our other projects should stick with Erlang R16.

» read more

Using kerl with direnv

30 Sep 2014 00:00

kerl allows you to easily build and install multiple Erlang/OTP releases. It’s kinda like nvm or rvm, but for Erlang. It doesn’t do everything, and that’s what direnv is for. direnv allows you to run commands upon entering or leaving a particular directory.

» read more

Adding lager handlers at runtime

10 May 2014 08:49

You’re using lager for logging in your Erlang program, and you discover that your configuration isn’t logging anything more verbose than info-level messages. How do you bump that up to debug?

» read more

Debugging Erlang with a remote shell

8 May 2014 15:54

If you’re connected to an Erlang node via a remote shell, and you don’t have access to stdout on the original node, you’ll need to redirect the trace output to your current shell.

» read more

epgsql: invalid_password

31 Dec 2013 14:55

I’m writing a simple web application in Erlang that uses epgsql to talk to a PostgreSQL database. I keep getting invalid_password, despite the fact that the user doesn’t have a password (and I’m passing “”). I can also log in by using psql -U foo.

» read more

vim plugins

22 Nov 2013 12:22

This, for no particular reason, is the list of vim plugins that I’m currently using:

» read more

Lego Storage

3 Nov 2013 19:59

My son has quite a lot of Lego, but he stopped playing with it. It turns out that he gets frustrated when he can’t find a particular piece. So we started exploring storage options.

» read more

Dependency Injection in node.js

5 Oct 2013 19:26

node.js modules are singletons. If you require('foo') from one module, and then require('foo') from a different module, you’ll get the same instance.

» read more

Phones I have owned

18 Jun 2013 10:37

Apropos of a discussion on Facebook earlier today:

  • Motorola MR20
  • Motorola Startac
  • Motorola (blue thing)
  • Nokia 8310
  • Nokia 6230
  • HTC Desire
  • Samsung Galaxy S3
» read more

Failed to load data access DLL

3 Jun 2013 10:55

While attempting to debug a crash dump from a .NET 4.0 RTM process on my (.NET 4.5), I got the dreaded Failed to load data access DLL, 0x80004005 error message.

tl;dr? Skip to the end…

In full, the error looks like this:

0:000> .loadby sos clr
0:000> !vmstat
Failed to load data access DLL, 0x80004005
Verify that 1) you have a recent build of the debugger (6.2.14 or newer)
            2) the file mscordacwks.dll that matches your version of clr.dll is
                in the version directory or on the symbol path
            3) or, if you are debugging a dump file, verify that the file
                mscordacwks_<arch>_<arch>_<version>.dll is on your symbol path.
            4) you are debugging on supported cross platform architecture as
                the dump file. For example, an ARM dump file must be debugged
                on an X86 or an ARM machine; an AMD64 dump file must be
                debugged on an AMD64 machine.

You can also run the debugger command .cordll to control the debugger's
load of mscordacwks.dll.  .cordll -ve -u -l will do a verbose reload.
If that succeeds, the SOS command should work on retry.

If you are debugging a minidump, you need to make sure that your executable
path is pointing to clr.dll as well.

There are lots of words here, but they’re not the easiest to understand, particularly when you’re in a hurry (like, say, you’re attempting to debug an issue on a production server).

I’m assuming that you’ve got a recent version of WinDbg. I was running 6.12, which should be OK.

If you’re lucky, however, (and you’ll need to have !sym noisy turned on to see this), you’ll get:

DBGHELP: clr - public symbols
            c:\websymbols\clr.pdb\0A821B8A573E42899202851DF6A539F12\clr.pdb
SYMSRV:  mscordacwks_AMD64_AMD64_4.0.30319.01.dll from http://msdl.microsoft.com/download/symbols: 502605 bytes - copied
DBGHELP: c:\websymbols\mscordacwks_AMD64_AMD64_4.0.30319.01.dll\4BA21EEB965000\mscordacwks_AMD64_AMD64_4.0.30319.01.dll - OK

This means that the Microsoft Symbol Server had the relevant mscordacwks.dll file. If not, you’ll have to copy it from the machine from where the crash dump originates, and put it somewhere useful. Unfortunately, the message doesn’t explain what, exactly, it means by “on your symbol path”.

For me, at least, it seems that putting it in (e.g.) C:\WebSymbols doesn’t work – you need to put it in the correct named location. I can’t verify this right now, since it downloaded it successfully from Microsoft Symbol Server.

More importantly for my problem, however, is the easily-overlooked message at the end:

If you are debugging a minidump, you need to make sure that your executable
path is pointing to clr.dll as well.

Given that WinDbg knows that I’m debugging a minidump, it could have made this more prominent. What it’s telling us is this:

  1. Copy clr.dll from the original machine. Put it somewhere. Next to the dump file would be fine.
  2. Add that path to the executable search path, using .exepath+ C:\wherever

Note, that you must use the version from the original machine. If you attempt to use your clr.dll, you’ll get the message:

The version of SOS does not match the version of CLR you are debugging.  Please
load the matching version of SOS for the version of CLR you are debugging.
CLR Version: 4.0.30319.1
SOS Version: 4.0.30319.17929
CLRDLL: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscordacwks.dll:4.0.30319.17929 f:8
doesn't match desired version 4.0.30319.01 f:8

Just tell me what to do, already!

  1. Copy clr.dll, sos.dll and mscordacwks.dll from the machine where the crash is occurring.
  2. Put them in C:\Temp.
  3. .exepath+ C:\Temp
  4. .load C:\Temp\sos
  5. Done, you can now !vmstat, etc., to your heart’s content.
» read more

Using IIS Express in vs-welcome-page

29 May 2013 17:35

So, why did I use IIS Express to implement my vs-welcome-page extension? I’m using Nancy, so why didn’t I just use the self-hosting support and host it inside Visual Studio instead?

» read more

Killing IIS Express

29 May 2013 17:23

A brief aside: I’ve got to the point where I’m about to fire up IIS Express from Visual Studio. In order to be a good citizen, our extension should probably shut it down again later.

» read more

Creating a Visual Studio Extension

29 May 2013 17:21

The next major piece is the Visual Studio extension, so let’s get on with that. Assuming that you’ve installed the Visual Studio 2012 SDK, it’s as simple as creating a new “Visual Studio Package” (it’s under “Visual C#” / “Extensibility”):

» read more

Rendering Markdown in .NET

29 May 2013 17:19

There are several options for rendering Markdown to HTML in .NET. If you bring up the NuGet Package Manager dialog and search for “markdown”, you get three pages of results, including MarkdownSharp, which is the renderer used by Stack Overflow, so it must be good.

» read more

Spike: Providing parameters to IIS Express-hosted applications

29 May 2013 15:32

An aside: We need to be able to support multiple instances of our small web application (because you might have more than one instance of Visual Studio open). If we host our application in IIS Express (and remember that we’re doing this to avoid messing around with URL ACLs), we either need to duplicate the whole thing for each site, or figure out a way to provide it with parameters.

» read more

Running IIS Express

29 May 2013 15:07

When you create a web application in Visual Studio, you can configure it (on the properties page) to run in IIS Express.

» read more

Finding IIS Worker Processes

13 May 2013 13:37

How do we find out if there’s a worker process for an application pool? Note that there can be more than one worker process for each application pool. Note also that a worker process can host multiple web applications.

» read more

The case of the missing print jobs

27 Apr 2013 08:02

Having recently moved my home server (Windows 2012) from the hall cupboard to the corner of my study, I decided to connect it to my printer. This means that I can print from my laptop over wireless without needing to turn on the desktop PC that the printer was originally connected to.

» read more

PowerShell and enums

17 Apr 2013 11:29

PowerShell has a really cool feature where it’ll coerce a string into an enum value. I’ll demonstrate by exporting a certificate from the Windows certificate store:

» read more

Acer Aspire S7 and Secure Boot

29 Mar 2013 13:59

I just bought myself a shiny new Acer Aspire S7-391, with a view towards nuking Windows 8 and to install Linux Mint on it. Stupidly, I didn’t consider that Windows 8 logo certification now requires a UEFI BIOS and Secure Boot.

» read more

Installing Windows 8 Pro on Acer Aspire S7

27 Mar 2013 16:47
  1. Make sure that the ISO file you’ve downloaded is not corrupt – this caused me a bunch of grief.
  2. Format a bootable USB stick as FAT32.
  3. Mount the ISO.
  4. Copy the files from the ISO to the USB stick.
  5. In the Acer’s BIOS, select UEFI; enable F12 boot menu.
  6. Restart the Acer.
  7. Press Fn-= (F12).
  8. Select the USB stick.
  9. Add the Intel drivers.
  10. Continue with the installation.
» read more

Bouncy Castle - Being a Certificate Authority

24 Mar 2013 16:14

Over the last few posts, we’ve seen how to create a self-signed server certificate in C#, by using the Bouncy Castle library. How do we create a CA certificate, and how do we issue certificates from that authority?

» read more

Bouncy Castle - Subject Alternative Names

24 Mar 2013 14:20

When you connect to a server using HTTPS, the server provides a certificate that identifies it. Your browser will then typically check that the name in the server certificate matches the address that you’ve gone to. In this way, you can be sure that you’re connecting to the correct server.

» read more

Bouncy Castle - Missing Certificate Attributes

20 Mar 2013 14:52

Over the last couple of days, we’ve seen how to use Bouncy Castle to generate certificates from C#. However, if you compare the certificates we’ve been generating with those generated by (e.g.) makecert, you’ll see that we’re missing a few things.

» read more

Logging Learnings

16 Mar 2013 11:16

I’ve just spent the bulk of the morning attempting to understand a bug by reading through some fairly large log files. I’ve come to the realisation that:

Make them text-editor-friendly

Most log files are text. This means that, if you’re tracking down a problem, you’ll probably want to search them, and you may want to edit them.

In particular, you may want to do a search+replace to pull out a bunch of lines to do with a particular event or client. For this reason, don’t spread an event across multiple lines. You might think that it makes the file easier for a human to read (and it does), but it makes it impossible to (for example) delete all of the events that mention client 321 (because you’re interested in client 123), because you’ll end up with hanging lines, as in the following example:

Client #123: Getting orders...
Order #1: Foo
Order #2: Bar
Client #123: Returned 2 orders.
Client #321: Getting orders...
Order #3: Baz
Client #321: Returned 1 order.

If you search-and-replace to delete “Client #321”, you’ll end up with the following:

Client #123: Getting orders...
Order #1: Foo
Order #2: Bar
Client #123: Returned 2 orders.
Order #3: Baz

If you tag-and-copy-to-new-file for “Client #123”, you’ll end up with the following:

Client #123: Getting orders...
Client #123: Returned 2 orders.

Either way, you’ve lost information, and confused yourself. This makes it harder to understand what’s going on.

So, either include the context on every line:

Client #321: Getting orders...
Client #321: Order #3: Baz
Client #321: Returned 1 order.

Or, don’t spread your output over multiple lines.

Consider using CSV (or JSON)

Yeah, your log files are human readable. That’s great, provided you can find a human prepared to read through a couple of million lines of log file.

Why don’t you make them machine-readable? Then you’d allow the file to be parsed and processed by a vast number of tools that already understand CSV (or JSON).

Don’t use XML

Whatever you do, don’t use XML. If you do, you’ve got two choices:

  1. Output a malformed XML document that doesn’t have a root element. If you do this, what’s the point in using XML? I suppose that you could claim that each snippet was an individual XML fragment.
  2. Close the root element after every write, and rewind to remove the </root> before every write. Say goodbye to your performance.

Also, it’s massively verbose. Just use CSV or JSON.

Consider using one file per client

Obviously, this isn’t going to work for your web-scale application, because you’ve got millions of clients visiting every second. However, if you’ve only got a couple of dozen clients, consider using one log file per client.

» read more

Reliable Sessions and HTTPS don't mix

15 Mar 2013 12:33

System.InvalidOperationException: Binding validation failed because the WSHttpBinding does not support reliable sessions over transport security (HTTPS). The channel factory or service host could not be opened. Use message security for secure reliable messaging over HTTP.

…reliable sessions and HTTPS don’t mix.

» read more

Hyper-V Remote Management

20 Feb 2013 18:59

It turns out that you cannot manage a Windows 2008 R2 Hyper-V installation from a Windows 8 desktop (even with the Remote Server Administration Tools for Windows 8 installed) or from Windows 2012 Server.

» read more

What is this?

6 Feb 2013 21:25

I got fed up with my existing blog, so I decided to write a new blog engine, as a way to learn some new tech.

» read more

MSBuild Tasks, Input Parameters and ItemGroups

1 Feb 2013 16:20

While looking through some MSBuild scripts recently at work, I came across some stuff to do with Task output parameters that I thought might be worth blogging about. First, however, I need to talk about Task input parameters.

» read more

PowerShell tip: Deleting certificates

31 Jul 2012 10:20
$certs = Get-ChildItem cert:\LocalMachine\My | where { $_.Subject –like 'CN=Victim*' }
foreach ($cert in $certs) {
    $store = Get-Item $cert.PSParentPath
    $store.Open('ReadWrite')
    $store.Remove($cert)
    $store.Close()
}
» read more

Streaming HTTP responses in .NET

14 Jul 2012 19:11

Sometimes you have a web service or web application, and, for one request, you need to transfer an unknown (and potentially unbounded) amount of data in the response.

» read more

New Theme

5 Jan 2012 16:55

New theme: Acquia Slate. It’s maybe a little dark for my taste, but I’m going to leave it for a couple of weeks and see if it grows on me.

» read more

PowerShell: ImportSystemModules

5 Jan 2012 13:58

I’ve been using PowerShell as a better Command Prompt for a while now. Increasingly, however, it’s one of the first tools I reach for when I come across a problem, rather than being an afterthought.

» read more

FTTC FTW

21 Dec 2011 11:10

I’ve not posted this until today, because my blog’s been poorly, but the BT engineer came round last week and upgraded me to FTTC.

» read more

Repairing image links in drupal

20 Dec 2011 15:52

Somehow – I’m not sure how, and I’m not exactly sure when – my website (powered by drupal) lost all of its images. They were still there in the filesystem, and the rows were still in the node table, but they’d vanished from the actual pages.

» read more

Reactive Extensions: Elapsed Time

30 Jan 2011 15:05

I’m using SqlBulkCopy to insert a large number of rows into a database table. I used Observable.FromEvent to hook the SqlRowsCopied event. Rx provides the .TimeStamp() method, but I wanted to know the elapsed time, so I did the following:

» read more

Release Process: Using Source Server

14 Jul 2010 13:33

One of the cool things you can do with the Microsoft Debugging Tools is set up a source server. This works by embedding source control details in your PDB files. Once you’ve published these to a symbol server, and set that up properly, you should be able to load a minidump file in Visual Studio (or WinDbg) and be taken to the correct line of the correct revision of the source file where the crash happened.

» read more

Release Process: Goals

14 Jul 2010 13:33

One of the many things that my former company, 1E, does well is its build and release process. That got me thinking: what makes a good build process?

» read more

Returning HTML from a WCF service

20 Jun 2010 13:05

I’m messing around with writing yet another a blog engine, as a way to learn ASP.NET MVC. One of the things that I’d like to do is have it support uploading from Windows Live Writer. This means that it needs to support XML-RPC and Really Simple Discovery (RSD). More on the XML-RPC stuff later.

» read more

Setting up Squid on Windows

16 Sep 2009 08:38

At work, we do a lot of our testing and debugging with virtual machines (using Microsoft Virtual Server or Hyper-V, mostly). The virtual guests are generally not allowed any access to our live network, which makes accessing the Internet difficult. To get around this, I usually set up Squid on the host machine. This allows the guests to access (e.g.) Windows Update and Microsoft Symbol Server, which makes things a bit easier.

» read more

Symbol Store: How are EXE files stored?

23 Apr 2009 15:12

If you’re using the Microsoft Symbol Server to pull down symbols for Windows, or if you’re using SYMSTORE.EXE for your own stuff, you’ll see that EXE (and other binary files) are stored in a path similar to C:\WebSymbols\user32.dll\4226015990000\user32.dll.

» read more

Using SQL Server Compact Edition for Unit Testing

29 Mar 2009 09:02

Ayende shows how to use SQLite with an in-memory database for unit testing your NHibernate code (here). This is a great idea: your unit tests will run more quickly, and you don’t have to worry about tearing the database down when you’ve finished. On the other hand, it’s not an exact match for Microsoft SQL Server (which is probably what your production website will run against).

» read more

Unplanned downtime

4 Mar 2009 07:14

At the end of February, differentpla.net suffered filesystem corruption. I had to revert pretty much everything to a previous backup, which meant losing about a week’s worth of stuff.

» read more

Numbering on shop fronts

29 Jan 2009 16:50

When I’m supreme ruler of the universe: shops will be required to place the “house” number somewhere on the front of the shop. It should be easily visible.

» read more

Windows 7 beta on Samsung NC-10 Netbook

29 Jan 2009 16:38

Nothing to report. It all works fine. Installation took an hour. The only hiccup was that I had to download the Marvell Yukon drivers (I used the Vista x86 ones) from Marvell’s website, but the WiFi works, so that was easy. I also slapped an SDHC card in there for some ReadyBoost goodness.

» read more

Things I learnt this week: SetWaitableTimer

25 Oct 2008 12:23

SetWaitableTimer doesn’t accept NULL for the pDueTime parameter. It returns FALSE; GetLastError() returns ERROR_NOACCESS (998). If you specify zero (i.e. a LARGE_INTEGER containing zero) for pDueTime, the timer is signalled immediately.

» read more

Things I learnt this week: SVCHOST

25 Oct 2008 12:23

SVCHOST services are configured by having ImagePath set to “%windir%\system32\svchost.exe -k name-of-service”, and a Parameters key containing ServiceDll (REG_EXPAND_SZ), which names a DLL with a ServiceMain entry point. ServiceMain has argc and argv.

» read more

Things I learnt this week: RegQueryValueEx

25 Oct 2008 12:21

RegQueryValueEx, when passed lpData = NULL, will set *lpcbData to the length required in bytes, even if it’s already set to something. If lpData != NULL, and *lpcbData is too short, RegQueryValueEx will return ERROR_MORE_DATA.

» read more

Tweaking TeamCity

12 Jan 2008 14:11

I just started using TeamCity Professional Edition for some personal projects (and we’re evaluating the Enterprise edition for use at work).

» read more

When I'm supreme ruler: Vacations

2 Jan 2008 09:12

When I’m supreme ruler of the universe: If you’ve taken more than 5 days vacation, employers will be required to let you work only a half-day on your first day back. It could be the morning, or the afternoon, but you’ll be required to work only 4 hours.

» read more

An empeg reports progress of OP_STATFID

16 Dec 2007 18:53

We’ve seen the format of the packet that emplode sends to find out the length of a file on the empeg (OP_STATFID). The empeg seems to always send a progress packet in response. The packet looks like this:

» read more

Packet format

16 Dec 2007 18:18

The format of the packets in the empeg’s TCP/IP protocol owe a lot to the fact that the empeg mk1 communicated over a serial link. This means that there’s a certain amount of cruft still in the protocol.

» read more

Source Code License

6 Aug 2007 11:41

Unless specified otherwise, all source code published on the differentpla.net website is available under the following license terms: Do what you want with it, but don’t claim you wrote it, and it’s not my fault if it doesn’t work.

» read more

FindFirstFile and SE_BACKUP_NAME

25 May 2007 17:04

If you want to read a file and bypass security (e.g., if you’re writing a backup program), it’s not enough to simply enable the SE_BACKUP_NAME privilege, you have to also pass FILE_FLAG_BACKUP_SEMANTICS to CreateFile.

» read more

Calling C# from JScript

27 Apr 2007 09:03

It’s possible, through the magic of COM interop, to call C# code from JScript or VBScript. Here’s an example of how to do it from JScript.

» read more

Implementing For Each in JScript

24 Apr 2007 11:01
function forEach(enumerable, delegate)
{
    for (var enumerator = new Enumerator(enumerable); !enumerator.atEnd(); enumerator.moveNext())
    {
        delegate(enumerator.item());
    }
}
» read more

How do I debug my gadget?

24 Apr 2007 10:34

As far as I can tell, you’ll have to go “old school”, and do the equivalent of adding lots of printf statements to your code. This should help:

» read more

Enabling Concurrent Remote Desktop Sessions in Vista

22 Apr 2007 20:26

At work, I do all of my development on a Windows 2003 box. I generally log in as a normal user, and then use Remote Desktop to concurrently log in as Administrator. This means that I’m relatively safe from malware when doing day-to-day stuff, but that I can still get hold of Administrator privileges when I need them.

» read more

A list of HRESULT codes

16 Feb 2007 10:50

…because every time I search for a given HRESULT, all I get is yet another frigging VB website regurgitating the contents of WinError.h

» read more

Turning off Registry Virtualization

15 Feb 2007 10:51

On Windows Vista, applications running without admin privileges can write to HKEY_LOCAL_MACHINE, and they’ll be transparently redirected to HKEY_CURRENT_USER\Software\Classes\VirtualStore. Similar redirection applies to C:\Program Files.

» read more

Roman Numeral letter H

7 Feb 2007 17:26

Someone appears to have spent some time searching my site for the term “Roman Numeral letter H”. This is pointless, for two reasons:

» read more

Things I found out today while looking at Side-by-Side DLLs

7 Feb 2007 16:37
  • You can add DLL dependencies to your EXE file’s manifest by using the /manifestdependency linker switch. As with several other linker switches, this can be done using #pragma comment(linker, ...).
  • The Visual C++ 2005 compiler automatically inserts a /manifestdependency switch into .OBJ files that it creates. It marks them as dependent on the Microsoft.VC80.CRT DLL, version 8.0.50727.762. It does this in the VC\include\crtdefs.h file.
  • You can tell it to use the RTM version (8.0.50608.0) of the runtime by defining the _USE_RTM_VERSION macro. See VC\include\crtassem.h. The behaviour of this macro can be confirmed by opening (e.g.) stdafx.obj in a hex editor.
  • This also adds the /include:__forceCRTManifestRTM switch to the linker. I’ve not yet found out what this does.
  • MFC and ATL do something similar in the VC\atlmfc\include\atlassem.h and MFCassem.h files.
  • In order to allow you to merge your own manifest files, the linker is asked to create the project.exe.intermediate.manifest file, using the /MANIFESTFILE switch.
  • This is then fed to the MT.EXE utility, which can be controlled in the project property pages, under “Manifest Tool”. The .intermediate.manifest file is added to the list implicitly.
  • If you add your own .manifest files to the project, these are also added to the MT.EXE command line implicitly.
  • MT.EXE is almost as bad as MIDL when it comes to error messages. If you include an empty or malformed manifest file in your project, it simply reports “general error c101008f: Failed to compile manifest(s). The parameter is incorrect.”. It doesn’t tell you which file or line caused the problem.
  • As an aside, the “No files were found to look in” misfeature still exists in Visual Studio 2005. Press Ctrl+Scroll Lock to fix it.
  • I don’t actually have a copy of the RTM VC80.CRT DLLs on my Windows XP box, anyway. I have versions 8.0.50727.42 and 8.0.50727.762. One of these would appear to correspond to the RTM version of Visual Studio, and the other to SP1. I’m not sure about this, though.
  • These live in the C:\Windows\WinSxS folder. They both have extremely long names. For example, the latest one lives in a folder called x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700.
  • In the C:\Windows\WinSxS\Policies\x86_policy.8.0.Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_x-ww_77c24773 directory, there’s a couple of policy files. The first one says that any CRT versions between 8.0.41204.256 and 8.0.50608.0 should be redirected to version 8.0.50727.42. Presumably this covers a range containing all of the CTPs and betas up to the RTM version.
  • The second policy file appears to override this by saying that these same versions, and everything from there to 8.0.50727.762 should use the 8.0.50727.762 version.
  • I found the blog of the man responsible. He’s not updated it since 2005 :-(
  • There’s a tool called FUSLOGVW.EXE which is supposed to help diagnose problems with Side-by-Side DLLs.
» read more

qmail STARTTLS is slow

22 Dec 2006 11:01

I’ve recently been struggling to reliably send email via my qmail server. I’ve got STARTTLS and SMTP AUTH enabled, in order to allow relaying for authenticated users. However, it’s been really slow, and Thunderbird quite often times out and gives up on the connection.

» read more

Unable to open Web Project

16 Nov 2006 12:43
Unable to open Web Project 'foo'.
The file path 'C:\wherever\foo' does not correspond to the URL 'http://localhost/foo'.
The two need to map to the same server location.
» read more

Empeg File Structures

13 Feb 2005 10:17

If you’ve ever gone looking for the music and playlists on your empeg, you’ll find them in the /empeg/fids0 and /empeg/fids1 directories.

» read more

Jam: Linking with System Libraries

4 Jul 2004 07:00

Obviously, your code doesn’t just link with your libraries. It also has to link with some of the system libraries. Jam manages this by using the LINKLIBS variable. The simplest way to make this work is something like the following:

» read more

Getting hold of the current directory in a batch file.

19 May 2004 16:33

A common UNIX shell idiom is to write things like cwd=$(pwd) to save the current directory so that in case be used later when other things might have changed it. For a long time I didn’t think this was possible in Windows batch files. It turns out that it is, but it isn’t pretty and it does generalise to getting the output of any command.

» read more

Handling LVN_GETDISPINFO

19 May 2004 14:24

If you specify LPSTR_TEXTCALLBACK when inserting an item into a ListView control, it no longer supports sorting; you can’t click on the column heading to sort the list control.

» read more

Partitioning an empeg's Hard Disk Manually

25 Mar 2004 09:20

If you’re attempting to upgrade the hard disk in your empeg, and the disk builder is not working for you (this is often the case with disks larger than 60Gb), then you might want to build your new disk manually.

» read more

Sent Items: Thunderbird and Outlook Express on the same account

23 Mar 2004 11:46

Outlook Express likes to store a copy of your outgoing email in a folder called “Sent Items”. Thunderbird likes to store a copy of your outgoing email in a folder called “Sent”. If you use both to access the same email account using IMAP, you’ll end up with both folders being created, and your outgoing email will end up in either, depending on which client you used at the time.

» read more

Colouring alternate rows in a CListCtrl

12 Jan 2004 12:23

Nothing particularly strenuous: Just handle NM_CUSTOMDRAW and play with clrTextBk. The only real surprise is that you have to return CDRF_NEWFONT from your handler to get the new colour used.

» read more

Resource File Dependencies

10 Jan 2004 21:49

Our MFC application has a resource script. This resource script suffers from a minor problem: It’s not dependency-scanned. If we edit any file included by it – for example the .rc2 file, it’s not rebuilt properly.

» read more

Disabling the Cancel button in a Wizard

9 Jan 2004 13:03

CPropertySheet provides the SetWizardButtons function, allowing you to enable or disable the “Back” or “Next” buttons. It doesn’t, however, allow you to disable the “Cancel” button.

» read more

Conflicting 'lib' target

9 Jan 2004 10:39

empeg’s source tree has a directory called lib, in which the core libraries used by all of our products live. Unfortunately, this conflicts with one of the included pseudo-targets that jam uses.

» read more

Linker Command Line Length

9 Jan 2004 10:37

Jam imposes a hard limit of 996 characters on command lines when built on NT. This limit is higher for other operating systems, and can actually be raised to around 10Kb on Windows 2000. However, it’s still not high enough for some link actions.

» read more

Displaying Progress in a Wizard

8 Jan 2004 18:24

I’m adding a wizard to the program that I’m currently working on. The wizard walks the user through importing some information from a file. I’d like to be able to display the import progress as a seamless part of the wizard.

» read more

Welcome

7 Jan 2004 19:16

Welcome to differentpla.net, where Roger occasionally posts snippets of code and other stuff that he feels like sharing with the world.

» read more

Using ON_COMMAND_RANGE and ON_UPDATE_COMMAND_UI_RANGE

7 Jul 2003 17:13

The ON_COMMAND_RANGE and ON_UPDATE_COMMAND_UI_RANGE macros are useful when you want to treat a group of commands similarly. In this case, it’s the commands for changing list view style. The command IDs must be contiguous, and you must specify the lower one first.

» read more

RJ45/UTP Crimps

23 Jun 2003 15:16

(Seen from the bottom of the connector, so that the tab is facing away from you, and the gold pins are facing towards you) Pin 1 is on the left. Pin 8 is on the right.

» read more

Using make-kpkg to build a custom Linux kernel for your VAIO

4 Feb 2003 15:10

Debian provides a powerful utility called make-kpkg for compiling your own custom kernels. It integrates tightly with dpkg by making .deb files and you can even use this to prepare your kernel image on a faster system. Later on it will make complex operations, such as compiling in patches and modules, a snap.

» read more

Installing Debian GNU/Linux on Sony Vaio SRX87

4 Feb 2003 15:10

Because the DVD-ROM drive supplied with the SRX87 is Firewire, and is not supported by the standard Debian boot images, you’ll need to use network booting (using PXE) to get it going. This page has some instructions for installing Debian in this manner.

» read more

Vaio: ACPI patches

13 Jan 2003 16:03

You’ll need to install the ACPI patches, and the ACPI daemon. Grab the patches from here, and apply them to the kernel:

» read more

Streaming to Winamp

18 Dec 2001 22:44

Since the Audio Receiver Manager (the server) uses HTTP to stream the MP3 data to the Rio Receiver, it’s possible (with some work) to stream directly to Winamp. Here’s how.

» read more

Advanced Searches in emplode v2.0

25 Oct 2001 19:29

emplode v2.0 adds the ability to search your music database. It provides two methods of doing this: simple searches (which are hopefully so simple that I won’t explain them here), and advanced searches.

» read more

Moving Message Sign

1 Jun 2001 10:41

A couple of weeks ago, we got an LED message board at work. They had them on offer at Maplin (if I recall correctly). Anyway, the manual with the board is singularly useless. It’s labelled “Moving Message Sign”, and has a picture of the display with “Taiwan Kingpul” on it.

» read more

Asus A7V Windows Box

8 Dec 2000 00:01

As mentioned here, my Pentium II-400 got fried by an ocuk power supply. As they say, however: Every cloud has a silver lining. With a dead computer, I could finally persuade my girlfriend that some long-overdue upgrades were necessary.

» read more

Overclockers.co.uk Power Supplies

8 Dec 2000 00:00

I don’t know if there’s something in particular about Overclockers.co.uk, but we’ve not had any good experiences with their power supplies. We’ve had two power supplies from ocuk, and they’ve both gone horribly wrong, and fried a whole shedload of hardware.

» read more