Archive for the ‘Technology’ Category

Finding the lowest non-zero value of multiple columns in Microsoft Access

Programming | Posted by epistasis
Jul 01 2014

Recently (for work) I wanted to find the lowest non-zero value of multiple columns in Microsoft Access. I had to trawl the Internet for the best way to do this and in the end worked with a mixture of several methods from different websites. I hope that this post will serve as a single point of reference for anybody wanting to do the same thing.

In this example I will use the following table:

003

 

1) First you need to open the VB editor:

001

2) Create a new module:

002

3) Paste in this code:

Function MinColumn(ParamArray FieldArray() As Variant)

Dim I As Integer
Dim currentVal As Variant

currentVal = FieldArray(0)

'Loop through each value in the columns
For I = 0 To UBound(FieldArray)
    'If the the column we're checking is lower than the last (and non-zero), take it
    If FieldArray(I) < currentVal And FieldArray(I) <> 0 Then
        currentVal = FieldArray(I)
    End If
    
    'If the current value is zero and we find a higher value, take it
    If currentVal = 0 And FieldArray(I) Then
        currentVal = FieldArray(I)
    End If
Next I

MinColumn = currentVal

End Function

4) Close the VB editor

5) Create this query:

SELECT EmployeeLastName,
MinColumn(EmployeeRate1, EmployeeRate2, EmployeeRate3, EmployeeRate4) AS LowestRate
FROM Employee

You should end up with the following results:

004

 

MySQL Backup & Restore Woes

FreeBSD | Posted by epistasis
Nov 03 2011

First things first… during my frantic search for answers, I read a statement similar to this:

“Anybody who’s come across this post looking for information on how to restore their databases, don’t worry – your data is probably not lost.”

In hindsight, I would likely have been much more effective if remembered this, therefore I’ve put it at the top of this post.

Background

My problem arose when I recently came around to the idea of reinstalling one of my servers. It was running FreeBSD 5.2 x86 and I wanted to upgrade to 8.2 x64. It was with great hesitance that I ended the 521 day uptime record.

Read the rest of this entry »

Chrome OS Cherry

Technology | Posted by epistasis
Dec 07 2009

So I downloaded Chrome OS (yes it’s incomplete – obviously) and played around with it. The idea is to be commended. It’s basically the Chrome browser… as an OS. You can pick up a version that can be written to a USB stick and then ran (live) from:

http://chromeos.hexxeh.net/index.php

All round thumbs up!

FreeBSD + pf problem with window scaling

FreeBSD, Problems, Windows | Posted by epistasis
Sep 13 2009

I’ve been having problems for a while with window scaling on my network. I run a FreeBSD router utilising pf for NAT/firewall. Some computers (those with Vista, Windows 7, or recent Ubuntu releases installed) could not establish connections to Google and some other websites, and applications such as Windows Live (MSN) Messenger could not establish connections.

On Windows Vista and Windows 7, disabling window scaling (also called Receive Window Auto-Tuning) with the following command was a successful patch for the problem:

netsh interface tcp set global autotuninglevel=disabled

In Ubuntu the same patch was to modify /etc/sysctl.conf to disable window scaling. I added the following line:

net.ipv4.tcp_window_scaling: 0

This was only a temporary fix however as I did not want to have to disable the feature all the time.

To properly support TCP window scaling, pf must create a state on the initial SYN packet of connection.

If the state is created on a subsequent packet (like when the SYN is  accidentally passed without creating a state, and the state is created on the returning SYN+ACK), pf has missed the window scaling negotiation
containing the scaling factors, and will eventually stall connections. Each peer’s scaling factor is only seen in its SYN packet, and can’t be deduced later on.

Check your ruleset and verify that

a) there is a default block policy
b) all ‘pass’ rules applying to TCP have both ‘keep state’ and ‘flags S/SA’.

That was it! Vista, 7 and Ubuntu were happy again, with default settings so I was able to re-enable Windows auto-tuning by typing:

netsh interface tcp set global autotuninglevel=normal

and for Ubuntu, I was able to erase the line in /etc/sysctl.conf.

Finally…

Windows | Posted by epistasis
Aug 10 2009

Ok so I’ve just moved house and I’m currently settling into a new place…

This weekend I will be getting my hands on a ‘legit’ RTM version of Windows 7, so I’ll be evaluating that for a while now. Will probably give my opinion during next week.

Likely going to try and find myself a cheap, low-spec 64-bit machine so that I can try out sever 08 R2 on it..

Windows Server 2003 Quick Launch Permission Errors

Problems | Posted by epistasis
May 17 2009

Problem: I’ve been trying to fix this for ages. Basically, when logged on as Administrator to my Windows 2003 Server box, using folder redirection (particularly for the Application Data folder, which is where the user’s quick launch is stored – App Data\Microsoft\Internet Explorer\Quick Launch), and redirecting over a share (even though the share is on the same server), clicking any quick launch items brings up an error saying “You may not have the appropriate permissions” etc.

Solution: After lots of googling I found the answer is to add the file server to the ‘Intranet’ zone under the Security tab of Internet Explorer. (i.e. add server or http://server). This will make the quick launch work again. If you want to reload the quick launch, go into task manager and kill explorer.exe, then start it up again.

Windows 7 </3 IE8

Windows 7 | Posted by epistasis
Mar 06 2009

Hmm, so Microsoft have confirmed that users of Windows 7 will be able to ‘turn on or off’ Internet Explorer. Or have they? Turning off IE8 in Windows 7 seemingly does what was already possible – that is, simply deletes the iexplore.exe file. This is hardly ‘disabling’ the browser, as many DLLs and other parts of the browser still remain, not to mention that Windows will probably ask you a thousand times if you’re sure you want to disable it.

I think it’s fairly safe to say that the only reason Microsoft are doing this is to appease Brussels. They’ve got the anti-trust case over including IE with Windows and this is a quickfix.. or should I say hotfix. Oh it makes sense now.. if it’s a hotfix.. it’s meant to be rubbish.

Anyway, I’m going to toddle off and find a copy of build 7048 now and check out the differences between it and the public beta (build 7000). Wish me luck 🙂

DKVM-4U not recognising keyboard

Problems | Posted by epistasis
Feb 09 2009

I bought a D-Link 4 Port USB KVM switch (DKVM-4U) to switch between my servers in their newly installed Node Zero, but I am experiencing a problem with it. Basically, the mouse and video bits work fine, but as soon as you plug in a usb keyboard the unit stops responding and needs a complete reset.

I emailed D-Link with my problem and was surprised to hear that my KVM is not really a KVM. For a transcript of the emails look at: http://www.epistasis.co.uk/site/dlink.html

Via Storage Server and MSI WindBox

Home Automation, Technology | Posted by epistasis
Jan 28 2009

Two things here really.. I’ve just seen that LinITX have started stocking the VIA NSD7800 Tower Storage Server. This amazing kit would be a great NAS device, perhaps running the open source FreeNAS software. It features an Intel Atom 1.5GHz CPU, and can support up to 1GB of RAM. If you pop on over to the Automated Home website there is a voucher code to get the full 1GB for free!

Second up, the MSI WindBox. The WindBox is an ultra-compact PC from MSI. It features a VESA mount interface allowing it to be wall mounted or simply placed on the back of your monitor. It also has the following I/O options:

  • Realtek 10/100 LAN
  • 3 USB 2.0 ports
  • a 3-in-1 card reader
  • VGA interface.

Pretty neat huh?

FreeBSD chown and chmod

FreeBSD, Problems | Posted by epistasis
Jan 28 2009

Problem: I was recently trying to use chmod and chown in PHP on a FreeBSD system. I found out that these two commands (for obvious) reasons, can only be used by the superuser, therefore I couldn’t change the owner of an uploaded file (via a website) from the www to the user who’s website it was. In Solaris you can just change rstchown to 0 in /etc/system – unfortunately I couldn’t find a similar way to do this in FreeBSD.

Solution: The main solution I have found to this is to just use a cron job as root to chown all the files  (by using an asterisk in the file path) in a certain directory (the upload directory) to the user.. This is also a lot safer than allowing other users to use chmod/chown.

Obviously, if anyone can think of a better way of doing this, please let me know.