Judah Wright

A collection of my work

Discord HTTP Wrapper

posted 7 12 2017 in Open Source

This is  ground-up custom built library to act as a wrapper for Discords RESTful API.

You can find more information on the project on its GitHub Page, but the short version is it lets your code talk to Discord.

For example:

$Channel = judahantor\DiscordHttpWrapper\Channel::find(1234567890);
$Channel->id; // 1234567890
$Channel->name; // TestChannel
$Channel->guild; // The guild the channel belongs to
$Channel->messages; // The 50 most recent messages in this channel
$Channel->sendMessage("Foo bar baz"); // Sends message, returns the message object

TeamTNT Laravel Scout Search Driver

posted 25 12 2017 in Open Source

I made a contribution that I thought might be worthy of putting on my portfolio, and heck its my portfolio so why not?

I use Laravel Scout in one of my projects, and use the TeamTNT Scout Driver with it. The driver does a fantastic job, but has one major issue. If a model you are trying to make searchable has an accessor that does does not have a column in the applications database (for example, you could have a 'first_name' and 'last_name' and an accessor for 'full_name'), when you run the import command it will throw an error saying it is trying to select a nonexistant column from the database.

Indeed it is. When the library creates the search indexes it selects the array keys of the models "toSearchableArray()" method as columns in a new query, assuming that all of the array keys there will have a correlating column in the database. In many cases this is not so, so in order to make this library work in my project without going out of my way to overwrite the "toSearchableArray()" method on every model I wanted searchable, I submitted a simple pull request.

The solution to this problem was quite simple. Before performing the select statement I added a quick lookup too get all of the available columns on that table. 

$availableColumns = \Schema::getColumnListing($model->getTable());

I then grabbed all of the keys in the "toSearchableArray()" method.

$desiredColumns = array_keys($model->toSearchableArray());

And intersected those two arrays. This way only columns that actually existed in the database would be selected from.

$fields = implode(', 'array_intersect($desiredColumns$availableColumns));

Its not much, but its my contribution to the open source world!

Laravel Options

posted 11 04 2018 in Open Source

For a brief rundown on exactly why this library came into being, you can check out the blog post I wrote about it.

The short version it is an object oriented approach to storing and retrieving general site options. It is as simple as the following:

\Option::set('setting name', 'setting value');
echo \Option::get('setting name', 'default value'); // prints "setting value"

This library comes pre-packaged with a bunch of different drivers for maximum compatibility. If none of the default drivers work for you, you can use your own by implementing a simple interface also included in the library.

You can check it out on both Packagist and GitLab.

The Sodium Ranch

posted 7 12 2017 in Professional Work

What is The Sodium Ranch? According to a quick excerpt from their website:

The Sodium Ranch is a polyvalent entertainment company based in Brooklyn, NY. Founded in 2009, The Ranch is a home base and incubator for works in cinema, photography and fine art.

They approached me asking if I could do some work for them. They rent out equipment to their customers, but their store needed some work.

The first problem was that the store owners had a hard time telling what items were profitable, what items were frequently out of stock, and when items were rented most often. I built them a simple reporting system to give them this basic information.

I also added the ability to drag-and-drop store categories, as well as reorder both store and portfolio items.

Overall a rather straightforward project, but I definitely enjoyed working with all the people involved.

Event Loop

posted 16 03 2018 in Open Source

I found myself needing to create a simple event loop in a case where the React framework would not have worked, so I built my own library.

The idea was to keep it as simple as possible. It does not have all the bells and whistles as React does, but if you need that sort of functionality you should just use that.
You can think of it as an incredibly overly-complicated foreach loop.

It is free and open source, anyone is welcome to use it as they see fit.