Validation in Laravel Artisan commands

One of the things I like most about using Laravel is that most everything I’ve needed to do so far is pretty intuitive.  If I try to code up something the way I think it’s supposed to work, usually it does.

I’ve been working on adding some new Artisan commands to my equipment database to handle some of the back-end administrative tasks that I’d normally have to fire up a browser for.

Naturally I want to validate the input.  Laravel’s got some really nice validation rules that would be nice to use in my new artisan commands.  The documentation covers doing validation on incoming HTTP requests, but isn’t clear on whether the Validator can be used more generically.

Looking at the documentation for manually creating validators, a Validator instance takes two arrays: an array with the data to be validated, and an array containing the validation rules.

It seemed like I could use the Validator facade pretty much anywhere as long as I had arrays of data and validation rules.  In my artisan commands, I added a use statement for the Validator facade,

use Illuminate\Support\Facades\Validator;

and the rest mostly followed the manual validator creation docs.

$validator = Validator::make($model->toArray(), [
  // validation rules

if ($validator->fails()) {
  // show validation errors and exit
else {
  // do stuff with validated data

Much happiness ensued when I tested things out and saw that the validations were working just like I thought they should.

Dipping my toes into org-mode

I’ve taken one of the older but still very capable laptops in my collection and put it to use as my “school” computer.  The goal is to have something I can lug around and use for research, number crunching, and my research notebook.  Then I don’t have to worry about trying to keep all that stuff in sync if I were to use my work and home desktop computers.

My handwriting can get pretty messy, and even I have a hard time reading my own handwriting sometimes.  I decided I wanted to do some kind of electronic lab notebook to keep my research notes, data, bibliography, and whatnot. 

I’ve been making an effort to spend more time in Emacs, and I have a few developer friends who rave about org-mode, so it seemed like a promising choice.

A quick Google search returned a few blog posts by people who are already using org-mode for research lab notes and writing papers and other research related tasks.  Plenty of prior work out there to learn from as I develop my own workflow.

Resurrected power supply

A couple years ago, the power supply in my computer went belly up because the power switch had corroded and stopped being a switch.

No idea what caused it to become so badly corroded, but I finally got around to finding a new switch for it. The new switch fit perfectly into the opening, and getting it reconnected was a pretty simple job.

Now I’ve got a couple of power supplies to work with. Plenty of projects out on the web describing how to turn computer power supplies into useful bench power supplies, and I could definitely use a couple of those on the workbench.

Cooked wifi card

The wifi on one of the older laptops in my collection failed quite a while ago. At the time, I figured the wifi card in the laptop had died, and got a USB wifi dongle to get it back online. Didn’t think much else about the problem after that.

This morning while I was looking inside to see what could be upgraded, I decided to pop the wifi card out to have a look. The top didn’t look too unusual, but when I flipped it over, there was a big toasted area on the label. Looks like the wifi chip got a bit hot and burned itself out.

Scorched wifi card
Scorched wifi card

The wifi card bay also showed some evidence of the heat. The area was a bit tacky, so I think it might be adhesive residue from the sticker on the back of the wifi card.

Wifi card area
Wifi card area

I popped the RF shield off the card and saw a bit of browning on the board from the overheating chip.

Scorched wifi card under the shield
Scorched wifi card under the shield


Retro gaming: Ultima IV

Ultima IV! On Linux!

One of my favourite games to play on my Apple IIe back in the day was Ultima IV: Quest of the Avatar. It’s been a long time since I played it, but thanks to xu4 (on Sourceforge), I can play it again. I’ve known about xu4 for a long time, but never bothered much with it until recently.

Getting it running on Fedora is as simple as installing the package with sudo dnf install xu4.

UltimaIV intro screen
UltimaIV intro screen
Out in the world
Out in the world
Shopping for supplies
Shopping for supplies

Plays just like it did on my Apple IIe. Ahh, memories.