WordPress Development

If you only work on one WP site, using the standard WP install method is fine. If you’re looking at building and maintaining multiple, this becomes tedious. Luckily there are some tools that allow for partial automation of this process.

Read On…

Nice and tidy LNMP VPS

Lately I’ve been setting up a lot of servers. After some reading it’s come to my attention that people are slowly shifting away from Apache and occasionally also MySQL in favour of Nginx and MariaDB respectively. This guide runs through a basic LEMP installation of a VPS loaded with Ubuntu 14.04LTS. I will also install Ajenti and Ajenti-v as a management console.

Read On…

WordPress Child Theme Using LESS CSS

less-css-red

Website’s requirements change rapidly. These days, I find myself using a large number of systems working together for any one site. Some work to display content in the most effective way possible, while others allow me to add and modify content and design elements more easily. Read On…

the Breath Alcohol Game Controller

Capture-red

The Idea

A 2-4 player drinking game where breath alcohol levels influence the performance of game controllers which in turn can turn any video game into an interactive drinking game.

Example:

Breathalyser sensor configured to control maximum acceleration in a racing game such that the most inebriated player is able to accelerate the fastest. The objective is to finish the race as quick as possible by drinking as much as possible without it affecting driving abilities.

Read On…

DSDT Override on Thinkpad X230

This article is rewrite of this post and this post. I found the tools used were not quite up to date, as well as an error which may be specific to the Thinkpad X230.

The problem this process aims to solve is that when attaching an external GPU (eGPU) on the PCI bus, there is insufficient addressing space, and not all devices can be function simultaneously. This is because Windows only has 32-bits of space in which it needs to fit devices. By manually adding a memory range outside of this 32-bit space, we can force Windows to operate in 36-bit space instead. This gives us 4 times as much room for devices. This guide is written for Windows 8.1 x64. Read On…

Finding files using a VBA script

I wouldn’t call myself a Visual Basic expert, but recently got tasked to go through a list of over 8000 entries to determine if SolidWorks drawings and models were available.

In short: ” * “ can be used as a wildcard in “Dir()” such that “C:\some_path* <> “”” returns true if the file exists.

Below is the code. Hope it is of some use to someone.

Sub Findfiles()
drawings_path = "G:\Drawing\Product Master drawings\"
models_path = "G:\Drawing\Parts Solid Models\"
num_rows = Worksheets("Sheet1").UsedRange.Rows.Count

For a_counter = 2 To num_rows

 drawing_path = Dir(drawings_path & Range("A" & a_counter) & "*")
 model_path = Dir(models_path & Range("A" & a_counter) & "*")
 If drawing_path <> "" Then
 Range("H" & a_counter) = drawing_path
 Else
 Range("H" & a_counter) = ""
 End If
 
 If model_path <> "" Then
 Range("I" & a_counter) = model_path
 Else
 Range("I" & a_counter) = ""
 End If
 
 Range("K1") = a_counter & " / " & num_rows 'counter
 
Next a_counter
Range("K1") = "" 'clear counter
End Sub

Thinkpad X230 eGPU 100% CPU load

If you are running an eGPU with a Thinkpad X230, you’re probably aware of the memory limitation present: Anything over 8GB causes the CPU and drive to behave strangely which renders the system inoperable.

This issue (as well as others) appears to start in the BIOS. I speculate that it has something to do with the dynamic TOLUD. The problem can hence be circumvented by plugging the eGPU in after BIOS.

However, now that the BIOS hasn’t had the chance to adjust its hardware addressing to fit the eGPU on the PCIe bus, it is likely that Windows will boot with the infamous “code 12 – insufficient resources available.” error. Fortunately, this can be remedied using PCIe compaction features available in Setup 1.x.

Depending on which graphics card you’re using, Setup 1.x may be able to fit all devices into 32-bit space. With recent cards this seems increasingly unlikely however, and 36-bits may be required. Windows isn’t likely to accept this without a DSDT override. I haven’t been able to make this work, but there is still one trick that can be applied if you are using windows 8 and are using an external display.

Boot past POST with eGPU unplugged. Quickly plug in after POST, go into Setup 1.x and perform 36-bit compaction on both GPUs, while forcing the external GPU into 32-bit space. While the internal GPU is technically still active, Windows can’t make use of it (you may get a “code 12 error” on the internal card). The eGPU should now be fully accessible with any amount of memory.

While this is very much a hack, it works well. I hope to successfully do a DSDT override from Setup1.x, which will hopefully allow all devices to be fully functional at a time without making use of the buggy dynamic TOLUD.

Fixing the Arduino MEGA 2560

The Arduino Mega has been my go-to board for a little while now. It’s much more capable than the Uno, and clones are barely any more expensive. Unfortunately, there are some issues with the bootloader. If a .hex contains three consecutive exclamation marks (!!!), the bootloader halts and the program never runs. Another issue is that the watchdog timer does not work: the chip resets but then gets stuck. To remedy these issues, an updated .hex is provided with the Arduino software. The following folder is the default on a Windows system:

C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\stk500v2

In this folder “Mega2560-prod-firmware-2011-06-29.hex” is the default firmware likely loaded on the board. The new hex is called “stk500boot_v2_mega2560.hex”. Although the bootloader can theoretically be burned through a secondary Arduino board using the Arduino as an ISP, I used a USBasp ISP to program many boards quickly using the ICSP header.

To get the USBasp to run in windows 8 (and above), driver signature enforcement must be disabled. This page describes how to do this. Once the drivers are installed, the chip can be flashed using the USBasp. I used this GUI tool to do this. Make sure you scroll down for the latest version: some links seem to refer to old copies, which don’t support the ATmega2560.

Select the right board, ISP programming mode,  open the .hex file at the top and ‘Write All’. Provided the cable is in the right way, the binary will be flashed onto the chip. – Edit: Extreme Burner caused issues in some cases!

Flashing can be done using AVRdude. I prefer using a GUI and used AVRDUDESS. Write the .hex to the chip as per the screenshot below and you are done!

avrdudess

The Mega should be ready to be used as a regular Arduino, without the bugs! To test this, the following code can be used:

#include <avr/wdt.h>

int count __attribute__((section(".noinit")));

void setup(){
 wdt_enable(WDTO_2S);
 Serial.begin(115200);
 Serial.println("Tick");
}

void loop(){
 Serial.println(count++);
 delay(1000);
 wdt_reset();
 Serial.println("Tock");
 delay(3000);
 Serial.println("Boom!");//WDT not working
}

The “count” variable is loaded into the ‘noinit’ section of the SRAM (more here), which makes the variable persist through resets: count will continue to rise regardless of intermittent WDT resets.