New month, new playlist. Songs which caught my attention in July 2020.

Highlights include:
– a new single from Squarepusher
– a super-sassy song from the Koreatown Oddity
– a re-released Prince track from 1979
– a 15-min long Tool track. Aren’t they all.
– a brand new remix from Tycho, with a distinctly Japanese vibe.

43 songs (wow!), 3 hrs 27 min. I listened to a lot of music last month.

It’s been a while since I updated the site with new music you might like. But I recently found an IFTTT automation which will create monthly playlists for me effortlessly, so I’ll try to be a bit more dilligent about getting them posted here in a timely manner.

So then, without further ado, my May 2020 playlist.

Recently, I’ve been working with CircleCI for doing some automation and testing work, and I’ve been trying to run things locally on my machine, rather than pushing everything up to CircleCI to have it run on their servers.

But I kept running into problems with things like SSH keys, known hosts, and environment variables. These are all things that have easy solutions when you’re running them on the CircleCI servers (e.g., the add-ssh-keys special step.)

However, not so easy when you’re running the jobs locally with the command line interface.

But after quite a bit of googling for an answer, I found that it was much easier than I thought to make it work. Turns out, you can use docker-style volume syntax with the circleci CLI tools!

So, if you are running a local circleCI job called check-repo, for instance, you can mount your local ~/.ssh directory directly into the container, and viola!

circleci local execute --job check-repo --volume /home/{YourUsername}/.ssh:/root/.ssh

Likewise, you can include runtime values for environment variables you may need with the -e flag:

circleci local execute --job check-repo --volume /home/{YourUsername}/.ssh:/root/.ssh -e GITHUB_TOKEN=Y0UrG17hU870k3nG03zH3r3

Remember, when you’re mounting local folders into the container, you’re going to want to use absolute paths, not relative ones.

Was this helpful to you? Drop me a line and let me know.

Here’s the second in my series of monthly Spotify playlists with songs that caught my attention for one reason or another the month before.

Highlights this month:

  • An extended block of dark synthwave (Gost, Perturbator, Daniel Deluxe)
  • A decent Yelawolf track
  • Quite a bit of lo-fi hip hop instrumentals
  • A couple of new songs from Download
  • Several pieces from Cristobal Tapia De Veer, who you might recognize for doing the score for lots of good television, including Black Mirror.
  • A bomb hip hop track from Busdriver, Aesop Rock, and Danny Brown that I must have listened to a dozen times already.
You only get thirty-second samples unless you have a Spotify account.

Here’s a Spotify playlist of songs that caught my attention in February of 2019. Notable features:

  • New track from Download, and a beautiful song by Phil Western, who unfortunately passed away in February.
  • A new song from Amon Tobin
  • An extended jaunt through the soundtrack of the show Letterkenny, which yielded a surprisingly rich vein of interesting stuff.
  • Probably more drum and bass than you want.

Hope you find something new and interesting. I’m going to try to do one of these each month, unless I get bored or forget. In which case, don’t hold it against me.

Hey friends, I’ve been working a plan for a while, and it’s gotten to the point where I can talk about it publicly, so I figured I’d mention:

I intend to leave Chicago around the end of September. I’m headed toward Colorado, and I anticipate landing in the Denver/Boulder sort of area. I don’t know the exact date yet; I don’t have a job there; I don’t really know many people there.

But I’ve been in the Midwest for too long, and it’s time for a change of scenery.

I’m currently in the market for PHP developer kinds of jobs in that area, and I’m open to remote positions from elsewhere. If you know anyone who’s hiring for that sort of thing, I’d like to encourage you to let me know and/or sing my praises.

I’ve also got a line on a sweet 2BR apartment in Rogers Park that’s going to be opening up around the first of October, so if that’s the sort of thing you might be interested in hearing more about, let me know and we’ll talk about it.

So if you’re in Chicago, and you want to hang out with me, or fight me, or yell at me, or make out with me or whatever, you’ll have to do it in the next two months, more or less. Go easy on me.

Excelsior!

The well-known fantasy artist Dave Dorman paints an Alien queen live on Facebook.

Lately, one of my favorite things to do is to check out art demo videos on the internet.

It’s always fascinating to watch someone who’s an expert at something do their thing in real time, particularly in creative pursuits. Often, when a person encounters a work of art, it’s in the context of a final, finished work. Perhaps it hangs in a gallery, or appears on a book cover, or perhaps in a magazine or in an advertisement. And of course, I always enjoy seeing finished works. But it can obscure the fact that reality has a surprising amount of detail, and just having a look at the finished work (particularly if it’s a reproduction, and not the original) doesn’t reveal the process by which the work came to be. Why did they make this decision? How did that detail get made? Where were the mistakes or the false starts?

When I was a kid, the only time you’d ever get to see artists actually producing work was if you took a class, or you watched Bob Ross (or his many imitators) on PBS. Thankfully, in this day and age, we can often get a much richer experience of an artist’s creative process.

A quick YouTube search turns up a zillion tutorial videos on any number of topics, in whatever medium you like.  Like this fellow doing a portrait in oils:

Or maybe you like digital paintings? I know I do. There is a whole genre of videos called “Speed Painting,” which can be amazing; you get a time-lapse of a whole work coming together:

Painting not your thing? Why not check out a sculpture video?

Maybe you’d like to hear the artists talking about the techniques as the work unfolds?

Perhaps there is a particular style or artist you are fond of, and you’d like to learn more about how they made their works.

No matter what kind of art you’re into, there’s someone making videos showing off how they do it. That’s why it’s become one of my favorite ways to spend some time; you can get art lessons from all across the world, in any style or medium you like, at a moment’s notice. The whole world is your art teacher.

Ok, so this particular problem took me a while to solve, but it turns out to be a useful technique, at least in my case, so I’m reproducing it here in the hopes that if you’re searching around on the internet looking for an answer, it’ll save you a little bit of time.

First, let’s describe the problem.

Let’s say you have a basic Laravel class something like:

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\DB;

class Aspect extends Model{
    public function display(){ ... }
}

And you have a bunch of other classes that extend your base class, including, possibly, classes that do not yet exist.

class SpecialAspect extends Aspect{
    public function display() { .... but with something different! }
}

class StupidAspect extends Aspect {
    public function display() {  ... and something else is different! }
}

Now, all of these classes will share the same underlying table, which includes a field which specifies what type of Aspect each record represents.

And what you want to do is to continue using Eloquent ORM to work with collections of aspects, such that belongsToMany() and the like will give you back a Collection object containing a bunch of Aspects, all cast into the correct sub-classes (e.g., [Aspect, Aspect, SpecialAspect, Aspect, StupidAspect]).

So you try it out, and you find everything is getting returned as the base class [Aspect, Aspect, Aspect, Aspect, Aspect].

Laravel thinks that you only want instances of the base class, but you don’t; you want the object with overridden methods to load correctly so you can work with them normally.

This is the classic use-case for the Factory pattern.

So how do you do it?

What you do is create a Custom Collection object to override the normal Collection method that your object uses.  In the Custom Collection, you iterate through the objects available, figure out what type the are supposed to be, and then create new objects of those types.  Then you essentially load the data into them manually, build them into an array, and replace the $items in the Custom Collection with your new array of objects.

So first, modify your base class to implement a custom collection method.  While you’re at it, make a manual_load() method as well; remember, the newCollection method is going to override the normal Collection method all the time, so if you don’t load your objects up manually, you’re going to get yourself into a situation with an infinite loop, until you run out of memory:

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\DB;

class Aspect extends Model{

    public function display(){ ... }
    
    public function newCollection(array $models = []){
        return new AspectCollection($models);
    }
    
    public function manual_load(){
        // use the DB::select method to pull your data out of the underlying table
        // and add it to the respective properties on $this
    }

}

So far, so good.

Now, you’re going to want to build your custom Collection object:

class AspectCollection extends \Illuminate\Database\Eloquent\Collection {
    public function __construct($items){
        parent::__construct($items);
        $this->recastAll();
    }      
    
    private function recastAll(){
        $new_collection_array = array();
        foreach ($this->items as $k => $m){
            $new_object = AspectFactory::make($m->id);
            $new_collection_array[$k] = $new_object;
        }
        $this->items = $new_collection_array;
    }
}

You’ll notice from that class, there is yet a third class that we’re going to need, an AspectFactory class that decides what kind of object you’re going to create for each individual element, so we’ll create that too:

class AspectFactory{
    public static function make($aspect_id){

        $new_classname = 'App\DefaultAspect'; // <--- if we don't have a custom type, we'll use this as our default.

        $new_type_name = DB::select('SELECT aspect_name FROM { ... whatever query will give you the name you need} ); 
        $mutated_aspect_type = $new_type_name[0]->aspect_name;
        $custom_classname = 'App\\' . $mutated_aspect_type . 'Aspect'; // This string is the name of the class we're going to test for.

        if ( class_exists( $custom_classname ) ){
            // The custom class exists, so override our default.
            $new_classname = $custom_classname;
        }

        $finder = new $new_classname();  // Here, we create the new class.
        $finder->id = $aspect_id;        // Assign the ID to the new object
        $finder->manual_load();          // Call that manual_load() method we wrote for our base class.
        return $finder;                  // Send our custom class back to our Custom Collection.    
    }
}

So now, if you have a relationship that looks like:

App\Subject->belongsToMany(‘App\Aspect’);

Then you can do Eloquent operations such as:

$s = new Subject::find(1);
foreach ($s->aspects as $a ){
     $a->display();
}

And the correctly overridden display() method will spit out whatever it is you’ve got it doing, because your Collection will look like:

[
   0 => Aspect, 
   1 => Aspect, 
   2  => SpecialAspect, 
   3  => Aspect, 
   4  => StupidAspect
]

Or whatever.

And there you have it.  Implementing the Factory pattern with Laravel (5.4).

 

UPDATE (1/3/2018) : Giulio Troccoli-Allard very helpfully got in touch (thanks!) with me to point out the recastAll() function in the collection class wasn’t preserving the keys of the items.  He included some code to provide the enhancement, and so I updated the relevant portion above.

 

 

Hey, so if you’re working with Drupal 7, particularly doing module development, you might find yourself find-and-replacing on the same kind of boilerplate code to set up a new module every time.

Well, I got sick of it, so I made a quick little generator for boilerplate code for Drupal 7 module development.  You can run it from the command line, and it’ll get you down to the interesting stuff in no time.

As an added bonus, I’ve included another command line script you can use to generate form arrays that are compatible with the Drupal 7 Form API.

Give it a looksee over at Github.

If you make anything interesting with it, let me know!