Judah Wright

A collection of my work

Simple Twitch.TV Widget

posted 6 12 2017 in Open Source

The Simple Twitch.TV Widget is exactly what the name implies. It is a very

straight-forward, easy to use, and configurable front-end widget generator.

The entirety of what the widget does, is show if a user is online or not. If the

user in question is online, it will give a preview of their stream and a link

to their stream. If they are offline, it will simply place a placeholder image

there.

Hold This

posted 7 12 2017 in Open Source

I made this site with a friend in mind. He needed to make frequent off-site backups of one of his servers, but had an incredibly slow Internet connection and aggressive bandwidth caps. He had a bash script to upload files to DropBox, but it was slow and cumbersome.

We were talking about the problem one day and he mentioned that he wished there was a site out there that he could just tell to “Hold This” file for a little bit. And thus the site was born.


The site is not meant to be too complicated. It has a simple web interface, an easy to use API, and that’s it.


The site can be viewed at https://holdthis.net/, the project is open source and is viewable on GitLab

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!

BytesCounter

posted 7 12 2017 in Open Source

This was a SUPER simple library I wrote that does some simple math and conversions between machine-readable file sizes and human-readable file sizes.


This plugin is used on the Hold This site, as well as a few other smaller projects.


You can do some nifty stuff with it, for example:

<?php
echo Bytes::make(512)->add('512B')->pretty; // 1.00kB

You can find more information on it on its GitHub page, as well as on Packagist.

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

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.