How To Detect Browser User Agent And Add Mobile Website Support

There remains one major problem with the application as it stands right now: when viewed on a mobile browser, the animation breaks down and the viewer window causes undesirable effects such as rescaling the page. As such, we’ll need to tweak the operation just slightly for mobile browsers (this wasn’t such a problem in the 1990s and early 2000s, but with most web browsing done via mobile, it would be dumb not to account for the difference.

iteration7.html

<script>
$(document).ready(function(){
       detectUserAgent();
    });
</script>

In the main HTML file, the only change we’re going to make is calling a different function from our JS file. In this case, it’s a function that will detect the user agent, letting the application know whether to run the desktop or mobile version of the app.

iteration7.js

function detectUserAgent() {
    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/Android/i))) {
        location.replace("mobile.html");
    }
    startplayer();
    }

function startplayer() {
    $.getScript("videofiles.js", function() {
        });
    makebox();
    }

In the JavaScript, the new detectUserAgent() function queries the navigator.userAgent object to see if it contains the string “iPhone”, “iPad”, or “Android” which would indicate a mobile device and browser. If one of those strings is found in the object, then the current page is redirected to “mobile.html”. Otherwise, the startplayer() function is called.

In the startplayer() function, we use the jQuery getScript() method to load another JS file within the script as running. In this case, it will load the “videofiles.js” file that now contains the addresses array.

The “mobile.html” file works exactly like the main HTML file, except that it now refers to a slightly different JS file, “mobile.js” that contains the changes we need to make the mobile version work.

mobile.js

function makebox() {
    $(".window").click(function () {
        video = $(this).css("background-image");
        video = video.slice(32, -6);
        window.open("https://www.youtube.com/embed/"+video, '_blank');
    });
    $(".window:not(:animated)").each(function() {
        addy = (Math.floor(Math.random() * addresses.length));
        $(this).css({"top": Math.random() * window.innerHeight - 290+"px","left": "-"+Math.random() * 740 - 740+"px","background-image": "url('https://img.youtube.com/vi/"+addresses[addy]+"/0.jpg')", "border": "10px solid", "color": getRandomColor});
        $(this).animate({left: "2000px"}, Math.random() * 15000 + 15000, makebox);
    });
    }

We only need to make two major changes to the makebox() function to make it work on mobile: First, we need to make sure that we define all animations by pixel distances instead of screen widths. The percentage screen width method of measurement does not work correctly on some mobile browsers and can cause the flying windows to rescale themselves when they reach the right edge of the screen.

window.open("https://www.youtube.com/embed/"+video, '_blank');
Second, instead of a viewer div playing an embedded YouTube video, we’re going to open the video in a new tab. We’re still going to use the embed version of the video, though, to avoid having the full YouTube player page load (which would also be undesirable).

From this point, we just add an appropriate background video to the HTML file body using the background-video CSS property, some appropriate MIDI music using the MIDIjs JavaScript library (midijs.net), and a few navigation buttons, and the application is ready to go!

DIY Phonograph Preamplifier – How Hard Could It Be?

Like many of our hosts, Matthew is an aficionado of vintage technology. In this project, Matthew is completely rebuilding a Califone 1400 series portable phonograph from the early 1980s to improve its playback quality. The first obstacle he has to overcome is rebuilding the preamplifier circuit to bring the raw phono signals from the tonearm up to RIAA line level, but he’s having a little trouble with the op-amp chip. How hard could it be to build a simple preamp from scratch?


I had taken a bit of a hiatus from production (as I discussed in the last Surf Report), due to both a sense of being overwhelmed by my new day job and a general lack of enjoyment in the process. Building things became a job, and it stopped being enjoyable for a time. 2021 gave me an opportunity to reflect on my own goals, and I ended up scratching hundreds of projects from my list that I knew I would either never finish or had no interest in pursuing. I’m still culling that list, but the Califone stands firm. I’m still working on it, but I’m doing it slowly and on my own terms.

In an effort to get me back in the rotation on element14 Presents, the Producers and I agreed on this smaller-format video, showing a chunk of the project in the detail that I like to provide. It’s part of a new Friday series that highlights more conceptual projects, asking How Hard Could It Be? and following the trials that go into a simpler idea. In this case, I needed to build a phono-line preamplifier for the record player from scratch, and I made a fatal error along the way. The idea is to highlight how everyone makes simple mistakes and that it’s okay to ask for help.

The video was a nice transition back into work-for-hire and a way for me to warm myself back up for the next stage of the project. Now that I have a basic design for a power supply and preamp, I can get started on breadboarding a class-D main amplifier so these parts won’t have to spend another year on the shelf!

Single Stage, Single Channel Phono Preamp With Power Supply Schematic

As I explained in the How Hard Could It Be? video, the first objective in getting sound out of a record player is amplifying the phono-level signal from the tonearm (about 5mV) up to line-level (1V). This pre-amplifier stage uses a low-noise operational amplifier to boost the signal to the appropriate level. For Project Califone, I’m building the preamp stage using a Texas Instruments NE5532 OpAmp chip. Of course, I was having a little bit of trouble getting the device to work because I neglected to realize that I needed to apply both a positive and a negative voltage to the chip in order for it to function.

After realizing my mistake, I sourced a 10:1 AC-AC transformer that I could use for prototyping purposes. From the wall, I can get down to a manageable 12VAC and with a simple rectifying circuit, split that into +/-12VDC. I will have to adjust the power supply circuit to account for the 30VAC output from the transformer already installed in the phonograph, but that is a problem for another day!

Single Stage Single Channel Phono Preamp With Power Supply

At this point, I have a minimum-viable amplifier circuit for a single audio channel. Note in this schematic that there is no resistance on the input signal, so there is effectively no gain control at this point. The signal is horrendously over-driven–and when piped through the main amplifier becomes so over-modulated that even Luigi Russolo would shiver–but it works! From here, it’s a matter of adding some resistors to control the gain before feeding the output to a single-knob tone control, the second pre-amp stage, then the main amplifier.

Putting Together An Ubuntu Theme For Windows Terminal

Windows Terminal has proven to be one of my favorite additions to the PC world in a while. Coming from the Linux and Mac paradigm for the last decade-and-a-half, I felt like I needed a capable terminal emulator if I was going to be running a Windows machine as a daily driver again. Of course, the Windows Subsystem for Linux (WSL) just makes me giggle with glee at being able to run Ubuntu at the hypervisor-level instead of using virtualization software like VMware to do the handful of specialized tasks that I would easily perform in a Mac/Linux terminal window.

Of course, if you’re going to have a modern terminal emulator, you need to be able to customize it. Under MacOS, I was rocking a classic green-on-black look that reminded me of playing Zork on an Apple II and was great for getting that “digging around under the hood” vibe. I’ll probably bring that look back for one of my specialized terminal implementations (maybe the dedicated Telnet profile I’ve set up for dialing into the occasional BBS), but for the Ubuntu profile, I wanted something that evoked the orange and purple color scheme that I’ve come to associate with my distro of choice. These colors aren’t exactly the official “on brand” colors that Canonical uses, but they get the idea across.

In Windows Terminal, you can access settings.json from the Settings tab and add the following data to the schemes section:

{
            "background": "#3C0315",
            "black": "#282A2E",
            "blue": "#0170C5",
            "brightBlack": "#676E7A",
            "brightBlue": "#80C8FF",
            "brightCyan": "#8ABEB7",
            "brightGreen": "#B5D680",
            "brightPurple": "#AC79BB",
            "brightRed": "#BD6D85",
            "brightWhite": "#FFFFFD",
            "brightYellow": "#FFFD76",
            "cursorColor": "#FFFFFF",
            "cyan": "#3F8D83",
            "foreground": "#FFFFFD",
            "green": "#76AB23",
            "name": "Ubuntu",
            "purple": "#7D498F",
            "red": "#BD0940",
            "selectionBackground": "#FFFFFF",
            "white": "#FFFFFD",
            "yellow": "#E0DE48"
}

Once you get this inserted, you should be able to select “Ubuntu” from the Color Scheme drop-down under the Appearance tab in your Ubuntu profile, and you’ll get a terminal that looks like this:

Ubuntu color scheme in Windows Terminal

Now that we’ve got the colors all set, we just need to add a custom icon to complete the look. I just grabbed a transparent *.png of the Ubuntu logo and converted it to an *.ico file. I’m weird in that I don’t really use my library folders the way they’re intended. I keep photos on my server, so I don’t have much use for the Pictures library folder. As such, I use the folder for “system” images like custom icons, profile images, and wallpapers. I just dropped the icon into the folder and pointed my Windows Terminal profile to it. Now I’ve got a terminal implementation that reminds me that I’m running a separate operating system on top of Windows and isn’t just another basic grey/white-on-black (that look is reserved for CMD and DOSBox).

How To Remove Library Folders From This PC In Windows 10/11

I’m one of those weird people that doesn’t really use the standard library folders that come in Windows (or MacOS, for that matter), but while I can easily customize Mac’s Finder menu to not list the libraries I don’t use, customizing the Windows Explorer menu is less straightforward. I like opening new instances of Explorer to the Quick Access view where I have all my attached drives, commonly used libraries (Downloads, Desktop, and Documents), and mapped network drives available at a glance. I also have locations for files synced across my devices and the Recycle Bin pinned to the menu, giving me ahem quick access to these commonly-used locations. Because of this setup, the stock “This PC” listing is redundant–listing many of the same locations twice and taking up precious screen real estate. As such, I wanted to customize this menu as much as possible with the hope of getting it similar to my Mac’s Finder sidebar menu.

Editing the Registry

The Windows Registry holds all the power under the hood in the Windows ecosystem. The problem is that it isn’t always clear what registry key values affect what parts of the OS. Fortunately, a little Google Fu is all that is needed to find the appropriate changes to make. First, open the Registry Editor by launching regedit from the Run (WIN+R) dialog. In the Registry Editor, navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions then locate the appropriate folder according to the GUID key list below and expand the folder to show its nested PropertyBag folder.

  • Desktop: {B4BFCC3A-DB2C-424C-B029-7FE99A87C641}
  • Documents: {f42ee2d3-909f-4907-8871-4c22fc0bf756}
  • Downloads: {7d83ee9b-2244-4e70-b1f5-5393042af1e4}
  • Music: {a0c69a99-21c8-4671-8703-7934162fcf1d}
  • Pictures: {0ddd015d-b06c-45d5-8c4c-f59713854639}
  • Videos: {35286a68-3c57-41a1-bbb1-0eae73d76c95}

With the appropriate PropertyBag selected, right-click the ThisPCPolicy value in the main pane and select Modify. Change the value from Show to Hide, then click OK. Conversely, to re-show a particular folder, just change the data back to Show.

In some cases, ThisPCPolicy doesn’t have a defined value in the PropertyBag. In these cases, right-click on the main pane and select New > String Value, naming it ThisPCPolicy. Then set the value appropriately.

Enabling The Libraries Folder

For convenience sake, I do like to have access to the Libraries–just not at the top of the list. You can enable the Libraries folder in the sidebar menu through Folder Options in Windows Explorer. The check box is located under the “Navigation Pane” header below the View tab.

Putting things together like this makes Windows Explorer rather usable at this point!

Cleaning a Focus Electronics FK-2001 Keyboard

New keyboard, who dis?

I’ve been using the Focus FK-2001 for about a week now, and I’m enjoying it. Coming from my Matias Tactile Pro, it’s a pretty easy transition (both using Alps switches and all). I do really enjoy the Tactile Pro, but I wanted something with Windows keys.

I also wanted something with a vintage style, but I didn’t like the prices for a Model M (most Model M keyboards with Windows keys are rubber dome switches anyway, and not the superbly clicky bluckling spring switches that the early Model M units employ). Anyway, I now have me a genuine vintage clicky keyboard that is a treat to type on.

Unfortunately, it’s rather…dirty. Time for a deep clean!

Opening up the case, we find the keyboard driver chip. Unfortunately, I haven’t been able to locate any information on this Intel microcontroller. It’s really just an object of curiosity right now, though.

Ran the keycaps through the ultrasonic cleaner for about 30 minutes and lubricated the switches before putting everything back together. These are all the keys with wire stabilizers reinstalled.

Gave the case a good wash with soap and water, too. Of course, I forgot to put the stabilized keys back together first, so I had to take it apart again 🙄

Now it’s completed, and I only messed up 1 key putting it back together!

All clicky, no sticky!

How To Run Old Windows Games on Windows 11

As much as I love to dig out one of my vintage laptops to get the full nostalgic retro gaming experience, sometimes it just isn’t very practical to fire up Windows 95 for a quick round of JezzBall. Unfortunately, the newer versions of Windows built on 32 and 64-bit architectures won’t run these old software relics. However, unlike Apple, Microsoft actually values backwards-compatibility. (Of course, this is mostly by necessity considering how many enterprises are running legacy software as well as due to the support of independent developers regularly bending the OS to their will, instead of the other way around.)

Windows Entertainment PackVirtue signalling aside, as part of my recent two-foot leap back into the daily-driver Windows world, I wanted to revisit one of my favorite casual diversions of the 16-bit era: Microsoft Entertainment Pack.

The only problem, of course, is that Entertainment Pack is a 16-bit application and Windows 11 won’t run 16-bit applications out of the box. Enter otvdm (forked from winevdm). Based on Wine, otvdm is a compatibility layer that adds the ability to run 16-bit Windows binaries in 64-bit exclusive versions of Windows much like the new Windows subsystems for Linux and Android. (At this point, Windows is almost a Swiss Army knife of computing, taking everything I’ve enjoyed from the Linux world without having to spend a few hours either setting up new hardware or reconfiguring everything after an update.)

How To Run 16-bit Windows Applications In 64-bit Windows

To use otvdm, download the latest release from GitHub, then unzip to the directory of your choice. From here, you can simply use otvdm as a portable installation by dragging and dropping your 16-bit application onto the otvdm.exe binary, and you’re all set!

If, like me, you prefer to have a more seamless integration into Windows, you can install otvdm with one of the included installer shortcuts. If you prefer to not show the console window while your application runs, use the “install (no console)” shortcut. At this point, 16-bit Windows applications (and their installers, for that matter) will run just like any other Windows application! Now, I’ll never get any work done ever again.

JezzBall
JezzBall on Windows 11!

How To Install Windows Applications To Removable Media

Not enough stickersI picked up one of those super-cheap ~$200 Windows 10 netbooks from Best Buy a while back because I wanted something inexpensive to keep at the shop for incidental tasks like programming microcontrollers or burning SD cards for Raspberry Pi. Unfortunately, someone at Microsoft boasted that Windows 10 could be installed on a 32GB storage drive, so manufacturers like Asus put exactly 32GB in their discount netbooks leaving very little space (after updates, usually less than 5GB) to install applications.

Fortunately, Windows 10 comes out of the box with the ability to change the default storage locations for the library folders and installation location for apps installed via the Windows Store. However, I use a lot of applications that aren’t available in the Store and I also require a fair bit of space for screen capture videos when I’m walking through a project, so I’m going to need some extra storage space. At least the little Asus that I selected has a MicroSD card slot so I can just grab a 128GB unit and leave it inserted. Windows treats it like any other removable media, but be warned: the MicroSD read/write speed isn’t anything you’re going to write home about! Applications are going to load more slowly, but in most cases will run just fine from RAM. (Writing that previous sentence gave me weird flashbacks of the 8- and 16-bit eras when we often ran applications directly from a floppy and experienced the associated slowdowns.)

Windows 10 Storage Options
Access Windows storage options by using the search function.

Install Windows Applications To SD Card

In most cases, Windows application installers will offer the option to select the install folder. For these, I just have the folder structure of the C: drive root copied to my MicroSD card, notably the Program Files and Program Files (x86) folders, so I just change the drive letter and everything installs like normal. However, many newer applications take advantage of the Windows User/AppData folder to store local data. One notorious example is Fusion360, which installs to the AppData folder and offers no option to do otherwise! For these exceptions, we’ll need to create a symbolic link from the C: version of the AppData folder to the D: drive location.

Use Symbolic Link To Redirect Folders

First off, using a symbolic link to redirect system folders to another location is generally bad practice because it can expose the machine to symlink attacks, but considering we’ve been backed into a corner by arrogant developers and clueless manufacturers, we’re going to need to pull this trick out of the bag. I wouldn’t use this kind of workaround on any mission critical systems, but it should be just fine for this little auxiliary machine. (Technically, Windows shortcuts are symbolic links, so we’re not doing anything too weird. We’re just forcing Windows to use a different storage location for something it prefers to have on the main storage device). The first step is to create a directory on the D: drive that will hold our AppData (since it’s a hidden folder and I’m the only user, I’ll just put it in D:\AppData). From here, just copy the contents of the AppData directory over to the new location and delete (yes, I said delete) the original.

Create Symbolic Links With Windows Command Line

Windows comes with the mlink command to create symbolic links, but you have to use the Command Line terminal to invoke it. Open an elevated command prompt (one with Admin privileges) by pressing Win + X and selecting the appropriate option from the list. The syntax for the command is as follows:

mlink /switch <link> <target>

So, to make C:\Users\<user>\AppData point to the new location on the D: drive, we’ll invoke the following command:

mlink /D "C:\Users\<user>\AppData" "D:\AppData"

Once the link is created, as far as Windows is concerned, the two locations are the same place. If an application needs to access the folder, it will seamlessly connect to the location on D:. As such, Fusion360 will run without a hitch (although it will load more slowly due to the reduced read/write speed)!

Unfortunately, this trick does not work to upgrade Windows 10 to 11, so this machine will be stuck in the late 2010s forever (or until I decide to install Linux on it…again).

How To Update Plex Plugin TrueNAS

Once upon a time, during the dark ages, we had to run several shell commands–like savages–to get the Plex plugin in TrueNAS (or FreeNAS, if you go back that far) to update. One had to fetch, then unpack the tarball, then move to the right directory, change ownership, and finally run the script! It was quite a pain when Plex was coming out with a new update every week (or so it seemed), and got to be more annoying than productive.

Fortunately, we don’t have to live like animals anymore because [mstinaff] wrote a nice, simple shell script to take care of all the heavy lifting! You can even set it up as a cron task to run on schedule (for when Plex decides to start issuing updates every few days again).

Let’s start by assuming that you know how to access your TrueNAS jails. On the Jails dialog, open Plex, then DO NOT CLICK “Update”. Click “Shell”.Once you’ve got your root prompt in the shell, download the updater by invoking the following command:
fetch https://raw.githubusercontent.com/mstinaff/PMS_Updater/master/PMS_Updater.sh

From here, you can just run the shell script with sh PMS_Updater.sh

Automating Plex updates on TrueNAS with cron jobs

To set up a cron job on your TrueNAS installation, navigate to the Tasks > Cron Jobs dialog. Click the “ADD” button to create a new cron job and give it a descriptive name such as “Plex update”. Then, enter the following in the “Command” field:

/usr/local/bin/iocage exec [plexjail] /bin/sh /usr/local/PMS_Updater/PMS_Updater.sh -r -a -v

Substitute the name of your Plex jail for [plexjail]. Mine is just called “plex“. The -r flag will keep your installation clean by removing the older packages before installing the new one. The -a flag automatically updates to the newest version without user intervention. Finally, the -v flag runs the script in verbose mode, so you’ll have a log available just in case anything goes wrong.

Set the “Run As User” field to root, and set your preferred schedule. I run mine weekly on Sunday nights. From here, make sure your job is enabled, and click “SAVE”. Now, you shouldn’t have to make another manual Plex update again!

How To Activate Descaling Mode On A Keurig K-Supreme Plus

My wife loves her Keurig. I’m the one that has to maintain it, though.

When that “DESCALE” message comes up on the little screen, it’s time to run some citric acid through the machine and get rid of all those fun hard water deposits that inevitably make it through the filter. Don’t buy the overpriced Keurig brand, just grab the cheapest citric acid cleaner you can find.

However, before you dive in, you’ll need to invoke the special “Descale Mode” on the Keurig. Activate this mode by powering off the Keurig, then holding the “8oz” and “12oz” buttons until the “K” button lights up and “DESCALE” appears on the screen. Follow the directions on the bottle from here, and you’ll be in good shape! The Keurig will return to normal function once the program is finished.