Ben Lobaugh Online

I think, therefore I am. I am, therefore I sail

New fish tank, saltwater- I have never had this before!

For over three decades I have kept aquariums. I tried to calculate of all the individual tanks over the years and came up with a rough 400 gallon number. In all of that time I have never had a saltwater fish tank! My friends Joshua and Jordan were the salt pros and I was the freshwater guy. 

A  buddy with a nano reef tank asked me a couple weeks ago if I could take care of his tank for a while. An established tank, with a built in sump. It is the perfect salt water aquarium starter package. I gladly agreed and the tank is now sitting next to my desk where I get to look at during the work day. 

Tank: Fluval Evo 13.5 

Current stocking:

  • Rose bubble tip anemone
  • Frosted Clown
  • Black and White Clown
  • Watchman Goby
  • Pistol Shrimp
  • Yellow Coral Banded Shrimp 
  • Peppermint Shrimp
  • Emerald Crab (I added)
  • Trochus snails

Photo of the tank after moving it to my house

Algae and Aiptasia got a foothold during my buddy’s vacation. We are currently battling it out, but I am confident that we will be the victors and the tank will be pristine again soon!

Some photos of the stock:

Video of the Emerald Crab

Lock attached to door

How to Force SSL (HTTPS) in Laravel

Out of the box, Laravel will allow both HTTPS and HTTP requests to your website or application. Ideally all requests are served via SSL. There are several ways to accomplish this, some of which require access to server configs. I am going to show you how you can easily force SSL in your Laravel application to ensure HTTPS will be on no matter where you application is deployed. Of course the server still requires a valid SSL certificate to run- that is outside the scope of this tutorial.

Assumptions

  • Working server with the SSL certificate already installed
  • Laravel app running
  • Requests being fulfilled on both HTTP and HTTPS
  • Basic Laravel knowledge

Time to complete in your app

30 minutes or less!

How it works

Laravel provides a mechanism for filtering HTTP requests called Middleware. Middleware has many use cases, a few of which include: user verification, CORS headers, logging requests, etc. Only after all Middleware conditions have been met is the app able to fulfill the visitor’s request. This is the perfect place for us to enforce SSL.

Read more about Middleware in the on the official Laravel docs https://laravel.com/docs/master/middleware

Step One: Create the Middleware Base

Middleware can be generated automatically with artisan with the following command:

php artisan make:middleware ForceSSL

The new file will be created in app/Http/Middleware/ForceSSL.php

namespace App\Http\Middleware;

use Closure;

class ForceSSL
{

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        return $next($request);
    }
}

Step Two: Update the handler

All we have to do now is look at the request and if it is not secure redirect to the secure version of the url!

Update the handle method like so

    public function handle($request, Closure $next)
    {

        // If the request is not secure, redirect to the HTTPS url.
        if( !$request->secure() ) {
            return redirect()->secure( $request->getRequestUri() );
        }

        // Otherwise carry on.
        return $next($request);
    }

Step Three: Test

That is it. 

Really.

Go test it.

Step Four: Enjoy a nice scotch

‘nuff said

Photo by Anita Jankovic on Unsplash

Man reading newspaper

Add a Mailchimp email subscription form in Laravel – double opt in!

With several fantastic extension out there, integrating a Mailchimp email subscription form in Laravel has never been easier!

I am going to show you an example integration that collects an email address in a simple form. We will be using the laravel-newsletter package by spatie.

Assumptions

  • You have a Laravel application already running
  • You have a Mailchimp account
  • You have a basic understanding of Laravel

Step One: Include the spatie/laravel-newsletter package

Include the spatie/laravel-newsletter package in your project with

composer require spatie/laravel-newsletter

This package contains a very easy to use set of methods to control all aspects of your subscribers and user management. In this tutorial we will only be using the subscribe functionality.

Step Two: Configuration

The default configuration file will be generated with

php artisan vendor:publish --provider="Spatie\Newsletter\NewsletterServiceProvider"

A file will be created at config/newsletter.php. In this file are a set of variables that will be needed in the .env file.

Step Three: Create the Controller

A Controller will be used to send off the subscriber’s email to the Mailchimp service. Other tutorials on form submission will also include a Model and Migration here. I am choosing to skip that since we are not putting data into a database, but rather are acting as a passthrough.

php artisan make:controller Subscriber 

The controller file will be created at app/Http/Controllers/Subscriber.php

Add a method called addSubscriber

    public function addSubscriber( Request $request ) {

        $validatedData = $request->validate([
            'email' => 'required|email',
        ]);

        // Do additional validation and security checks here....

        // Sign up the user!
        Newsletter::subscribePending( $validatedData['email'] );

        if( Newsletter::lastActionSucceeded() ) {
            $status = json_encode( [ 'success' => true, 'message' => 'You have been added to the list! Please check your email to confirm.' ] );
        } else {
            $status = json_encode( [ 'success' => false, 'message' => 'There was an issue adding you to the list! Please try again or contact the admin.', 'error' => Newsletter::getLastError() ] );
        }

        return $status;
    }

Step Four: Update routes

Next you will need to update your routes file to add the new endpoint. Do this in routes/web.php

Route::get('subscriber/add’, 'Subscriber@addSubscriber');

If you are building this into an API you can use the routes/api.php file.

Step Five: Wire up your form

This is the final step to world domination!…. or at least having your subscription form ready for prime time. Simply wire up your form to use this new endpoint. I am going to assume that you know how to handle html forms here 😉

Step Six: Final Testing

Because we set this up as a GET query, testing is as simple as passing the email query parameter. Submit an email and see it populate in your Mailchimp account!

Step Seven: Drink Scotch

The final and most important step!

How I made my first, CHEAP, aquarium sump

Sump filtration systems are popular amongst fish hobbyist, but in 33 years of fish keeping I have never had one on my tanks. My filter of choice is the good ‘ole under gravel. It can be a hotly debated method, but it has always served me well. Of course I have lived in places with good water straight out of the tap! Currently I am living in a real estate rehab house, and the water quality here is awful for fish. There are wild fluctuations in chemical composition, sometimes the chlorine is overwhelming. I do not trust it, and it has made keeping my tank level a chore.

As much as I like under gravel filters, I recognize their strengths and weaknesses- one weakness being the (slow) speed at which they can process the water. Larger established tanks can absorb spikes ok, but my little 30 gallon struggles under the load…. enter the sump filter.

Sumps can process the entirety of the tank’s water several times per hour, but they tend to be expensive if purchased from a fish store. When you break down their components, it turns out sumps are relatively inexpensive to build yourself.

Here are the major components:

  • Method of getting water out of the tank automatically
  • Filtration method to run the removed water through
  • Method of getting the water back into the tank

That’s it!

“But wait!”, you say, “It cannot be that easy!”

Really, the most difficult part of the project is getting the water out and back into the tank. I promise! The sump itself is simple. It consists of three parts:

  • Mechanical filtration
  • Biological filtration
  • Reservoir of cleaned water

Here is the big picture of my setup:

Getting water out of the tank utilizes a siphon and gravity- no electricity required. Just like the gravel vacuum you use when cleaning your tank. The water return is accomplished via an electric pump in the water reservoir, in this case, at the bottom of a 5 gallon bucket.

A cut away view of my sump looks like:

* The circles with an X in them are the biological filtration.

How does this work?

  • Water comes into the bucket
  • Then it is mechanically filtered via a layer of polyester
  • It tickles through the polyester into several layers of plastic pot scrubbies (yes, that you clean pans with!) that act as the biological filtration media. Bacteria loves to grow on this stuff!
  • Then falls into an empty space at the bottom of the buckets, the reservoir
  • Finally, an electric pump pumps it back into the tank

All told, this system cost less than $60 to build, vs hundreds to purchase from a pet store.

Here is a list of the components I used:

I put a ball valve on the water return line to be able to control the flow rate of water. I believe 250 – 300 gallons per hour is the current flow rate through this system. That means the entire tank water gets processed up to 10 times per hour! That is a lot of filtration….maybe a little overkill. Recommendations I saw around the web were around 5 times per hour as a minimum.

Overall a very simple project. The water clarity is outstanding and the fish are moving around happily. The main caveat here is that since this is a brand new sump it means it has to go through the whole cycling process. I am hoping it will be accelerated though since the tank as it was was cycled already. Some of that good bacteria should make its way into the sump to help prime it.

Have you built a sump before? What is your method?

If this post has inspired you to build one please drop a comment below. I would love to hear about your experience.

A couple great resources on the web for all things fish keeping

World’s cheapest standing desk

Standing desks are great to get you up from a sedentary chair, especially when you are at your desk all day. In my case, a standing desk is helpful to alleviate the pain of a back injury that I suffered in my teens.

I would like a sit/stand convertible desk, however those cost hundreds of dollars and I wanted to be a bit thrifty. This desk cost less than $20 to build. The top is reclaimed from an old shelf, and and I counted it as free.

I also wanted to be able to integrate my musical keyboard into the setup. It came out pretty well for $20!

Page 3 of 163

Powered by WordPress & Beards