Fix for slow Cygwin

June 18th, 2019

On my work PC, Cygwin was taking a significant time (minutes) to start programs. The fix for me was to ensure the cygserver process was running.

Replace strings in SQL

June 18th, 2019

On occasion, I need to replace strings in entire database columns. 

Here is how to do it in MySQL (reference link1 link2):

UPDATE
    table_name
SET
    column_name = REPLACE(column_name, 'text to find', 'text to replace with')
WHERE
    column_name LIKE '%text to find%';

Here is how to do it in SQL Server (reference link):

update my_table
set path = replace(path, 'oldstring', 'newstring')

 

vi paste contents of another file in current file

June 18th, 2019

While editing a file in vi, in order to paste the contents of another file at the current location type:

:r filename_to_paste

 

Perl file open details

June 18th, 2019

There are several ways to open files in Perl and it seems that there are many opinions on the best way to do so. I've looked into it a bit and I believe that I'm going to use the three-argument version of open going forward.

open (my $filename_fh, '<', $filename);

As stated in the linked page, benefits include:

  • Perl will open files even if they contain file operation (< > |) characters
  • The scalar file handle ends in _fh so it should be obvious it is a file handle everywhere
  • The file handle should be meaningful
  • The file handle will be cleaned up automatically if it goes out of scope

Accessing Plex media from Sonos

June 18th, 2019

Since I got my first Sonos device, I wanted to be able to play music from my Plex server. Unfortunately, due to the way Sonos issues the network requests, it didn't work properly. I use pfSense for my router and tried a number of workarounds but the one that finally worked was this one:

In the pfSense Plex NAT firewall rule (pfSense->Firewall->NAT->Port Forward->Edit) change the NAT reflection setting to "Enable (NAT + Proxy).