How to use Gem CLI commands in Supervisor on Ubuntu

Supervisor is a great unix program that lets you run persistant long-running programs. In general it’s easy to use and DigitalOcean ($5 a month hosting) has a great tutorial on how to set it up here.

I was interested in Supervisor because I wanted to run the mispy/twitter_ebooks repo for building some twitter bots. It gives you a great command line interface for both creating new bots (ebooks new <reponame>) and starting the bots (ebooks start).

For whatever reason you can’t just point Supervisor at a directory and call that command. You’ll need to find where the gem wrapper is located and run the command from there.

First find the path of the executable gem:

which ebooks

For me it was located here: /home/shayden/.rvm/gems/ruby-2.2.2/bin/ebooks

Then we can switch the /bin/ dir to the /wrappers/ dir which is the packaged file you will tell Supervisor to run.

/home/shayden/.rvm/gems/ruby-2.2.2/wrappers/ebooks

In Supervisor the .conf file should now look like this:

[program:ebooks] command=/home/shayden/.rvm/gems/ruby-2.2.2/wrappers/ebooks start directory=/home/shayden/ebooks_bot/ autostart=true autorestart=true stderr_logfile=/var/log/ebooks.err.log stdout_logfile=/var/log/ebooks.out.log

Now Supervisor should have no problems keeping your twitter bots alive and tweeting.

Unity C# – Torque Look Rotation in 2D

Getting one object to look at another object in Unity can be a very math intensive project.  In 3D there is an easy way to do this by use the transform to look at another object with a simple call:

Quaternion.LookRotation(target.position - transform.position)

In 2D Unity doesn’t hold your hand and you have to figure it out yourself. Most look rotation guides for Unity focus on simply modifying the transform even when talking about moving a Ridgedbody with physics.

If you want to use physics on Ridgedbody to add torque to turn toward another object then the unifycommunity wiki has a guide for 3D. With slight modifications we can get this same code working for Ridgedbody2D:

reasonably-sound

Awhile ago I was listening to a podcast about video games. They focus mostly on console games but for whatever reason they were talking about PC games which is where most of my interest lie and they just said obviously wrong thing after obviously wrong thing. And it made me so angry. So angry that I actually just stopped listening to all of the small handful of podcasts I was subscribed to.

Slowly I am bringing them back. First to catch up with Welcome to Nightvale and then Serial which has swept the internet almost as quickly as Nightvale did. But also Reasonably Sound a great podcast about an area I know very little about.

For me the greatest problem is just that podcasts are something I tend to do on my commute and which is also where I do most of my reading and so they tend to take me from reading. I’m already not reading as much as I should as I let Game of Thrones slow me down to a halt.