Adding & Removing Tags On GitHub

If you ever accidentally tag the wrong branch with a release, you can move the release back to the draft stage on GitHub with the following commands.

  1. Delete the tag locally
    git tag -d v1.0

  2. Delete the v1.0 tag on GitHub
    git push origin :v1.0

You can then select the correct branch on GitHub and publish the release once more.

Symlink SublimeText 3

Here you go...

$ ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
$ ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Now you can...

$ cd ~/code/project
$ sublime .
$ subl .

Free Space

When you're looking to free space on a server...

$ df -h
$ du -xhd1 /

Laravel 5.4 JSON Contains Macro

Update 2017-02-10:

A new assertJsonFragment() function has been added to laravel/framework to replace the old seeJsonContains() function.


If you want to get your tests updated for Laravel 5.4, and need a quick patch for the missing assertJsonContains(), here's a macro that you can place in the createApplication() function, either in your tests/CreatesApplication.php trait or your tests/TestCase.php file, depending on how your test folder is setup.

TestResponse::macro('assertJsonContains',  
    function (array $data) {
        $actual = json_encode(Arr::sortRecursive(
            (array) $this->decodeResponseJson()
        ));

        foreach (Arr::sortRecursive($data) as $key => $value) {
            $expected = substr(json_encode([$key => $value]), 1, -1);

            PHPUnit::assertTrue(
                Str::contains($actual, $expected),
                'Unable to find JSON fragment'.PHP_EOL.
                "[{$expected}]".PHP_EOL.
                'within'.PHP_EOL.
                "[{$actual}]."
            );
        }

        return $this;
    });

You'll also want the following use statements

use Illuminate\Support\Arr;  
use Illuminate\Support\Str;  
use PHPUnit\Framework\Assert as PHPUnit;  
use Illuminate\Foundation\Testing\TestResponse;  

Unattended Dependencies

I often run into quality issues in Javascript packages that I want to adopt. Most of these issues consist of simple bugs that are worth eradicating with a pull request. However, the sole reason these packages are not updated is often due to the owners simply not maintaining them. The unfortunate side effect is a lot of forks getting created.

I am currently reading:

Ansible For DevOps by Jeff Geerling

Ansible is a simple, but powerful, server and configuration management tool (with a few other tricks up its sleeve). This book helps those familiar with the command line and basic shell scripting start using Ansible to provision and manage anywhere from one to thousands of servers.

The book begins with fundamentals, like installing Ansible, setting up a basic inventory file, and basic concepts, then guides you through Ansible's many uses, including ad-hoc commands, basic and advanced playbooks, application deployments, multiple-provider server provisioning, and even Docker orchestration! Everything is explained with pertinent real-world examples, often using Vagrant-managed virtual machines.

Cryptonomicon by Neal Stephenson

Cryptonomicon zooms all over the world, careening conspiratorially back and forth between two time periods - World War II and the present. Our 1940s heroes are the brilliant mathematician Lawrence Waterhouse, crypt analyst extraordinaire, and gung-ho, morphine-addicted marine Bobby Shaftoe. They're part of Detachment 2702, an Allied group trying to break Axis communication codes while simultaneously preventing the enemy from figuring out that their codes have been broken. Their job boils down to layer upon layer of deception. Dr. Alan Turing is also a member of 2702, and he explains the unit's strange workings to Waterhouse. "When we want to sink a convoy, we send out an observation plane first... Of course, to observe is not its real duty--we already know exactly where the convoy is. Its real duty is to be observed... Then, when we come round and sink them, the Germans will not find it suspicious."

All of this secrecy resonates in the present-day story line, in which the grandchildren of the WWII heroes - inimitable programming geek Randy Waterhouse and the lovely and powerful Amy Shaftoe - team up to help create an offshore data haven in Southeast Asia and maybe uncover some gold once destined for Nazi coffers. To top off the paranoiac tone of the book, the mysterious Enoch Root, key member of Detachment 2702 and the Societas Eruditorum, pops up with an unbreakable encryption scheme left over from WWII to befuddle the 1990s protagonists with conspiratorial ties.

Start Supervisor At Boot

If you want to have supervisor running at boot on an Ubuntu 16.04 server, you need to enable the service after installing it.

$ apt install supervisor
$ systemctl enable supervisor