Inline text replacement with sed

Replacing values in files is incredibly easy with sed. Here’s some examples:

 

sed 's/match/replace/g' file.txt

Find match, replace with replace, globally (all matches), in file.txt

 

sed 's/match/replace/g' file.txt > file2.txt

Same as before, but write results to new file, file2.txt

 

sed -n 's/match/replace/p' file.txt

-n suppresses output of the results, but /p prints out just the matching patterns that are replaced.

 

sed -i.old 's/match/replace/g' file.txt

Replace matches in the input file with inline replace (-i), renaming original file file.txt.old and writing inline replace results to file.txt

 

Node.js and Mongoose: connection hanging on find()

Following this tutorial to build a simple REST api on Node.js with Express, attempting to retrieve all docs from my MongoDB gave these errors:

2016-05-19T20:10:47.311-0700 [initandlisten] connection accepted from 127.0.0.1:52053 #4 (2 connections now open)

2016-05-19T20:10:47.325-0700 [conn4]  authenticate db: nodetest { authenticate: 1, user: "", nonce: "xxx", key: "xxx" }

2016-05-19T20:10:47.336-0700 [conn4] Failed to authenticate @nodetest with mechanism MONGODB-CR: ProtocolError field missing/wrong type in received authenticate command

Some quick Googling turned up the same error in this post that just suggested authentication was failing because no user was passed. So created a new used with:

db.createUser({user : 'nodetest', pwd: 'passwordhere', roles: ['readWrite', 'nodetest']})

… and problem solved.

Update: onscreen keyboard for Raspberry Pi 7″ touchscreen

Quick followup from last week’s post on setting up an onscreen keyboard. I couldn’t find a way of getting an onscreen keyboard, either matchbox-keyboard or florence, to respond on Raspbian’s logon screen. Rather than spend more time on investigating this, I just enabled the logon to desktop in raspi-config, and now logged on, either of the keyboards work as expected, perfectly well.

Florence seems to be the better of the two I tried. Once opened from the menu you can drag it around, or minimize it to a keyboard icon, so you can pop-it open as needed.

If I could get it to work from the logon screen too that would be awesome, but avoiding that issue and once you get to the desktop, it works great.

Common dipole antenna dimensions for Amateur Radio HF bands

When building your own antennas, you can either look up a design or dimensions online or from book, or you can use a common formula. 468/MHz is commonly used to calculate the total length of a wire dipole in feet. I had a few dimensions jotted down for reference, but it’s easy to stick the formula into a spreadsheet and just enter the freqs you’re interested in. For example, here’s a Google Doc with the common HF bands:

I hope I’ve got these right, but if not, drop me a comment below.

Here’s a link direct to the Google Sheet if you’d like to bookmark it: https://docs.google.com/spreadsheets/d/1d3Mmnyzvj8AG1lFPd59RSMJhE9ihbE2M4w5noDzyedo/edit?usp=sharing