Belt: A Handful Of Tools For PHP Developers

php-belt

Clean and well-documented source

Belt is a really handy, and relatively new tool set for PHP developers. It’s initial commit was only 9 days before the date this post was published.

However, it still looks very usable and rather mature. Code has been added at a pretty quick pace, there’s been 102 commits since Belt’s release on GitHub, a little over a week ago.

It’s release under the MIT license, so it’s compatible with the GPL and can safely used in WordPress themes and functions, if you want them included in the official repositories.

Basically, you just include belt and use it’s built in methods/functions to do certain things that would take a bit more work using straight PHP. For example, to get the maximun of an array of numbers, do this:

A value of 3 will be returned, because it’s the max value there.

And from the readme, a list of what Belt offers.

  • 60+ useful functions
  • ability to use the facade Belt or a dedicated component (e.g. BeltUtilities)
  • fully tested
  • source code is clean and documented

Seems like it offers some pretty useful functions, and it looks really easy to use. I’ve been looking for a solid PHP base to use and this may just be it. Anyone got any other suggestions? I’ve heard a lot about Skeleton for PHP.

Searching for “skeleton” on GitHub, then filtering for PHP, gives a LOT of results, over 1,000 results to be more precise. So, maybe I’ll browse there for a while before making a decision.

Any suggestions can be left in the comments.

Poor Man’s VPN With a Cheap VPS

SONY DSC

sshuttle is what makes me love the Internet

It really is awesome, sshuttle basically allows you to browse the web via your VPS, in my case, a DigitalOcean VPS. It works on Linux and MacOS.

The GitHub repo explains it better than I can.

Transparent proxy server that works as a poor man’s VPN. Forwards over ssh. Doesn’t require admin. Works with Linux and MacOS. Supports DNS tunneling.

It hasn’t been updated in two years, but, no need to fix or change something that doesn’t need fixing or changing.

So, Why? What’s the point?

I run some Tor relays, one out of my house, thanks Mediacom! ;)

Because of this, many websites block my. Kohl’s, Best Buy, no posting on 4Chan (understandable), even healthcare.gov is blocked. I don’t want to pay for one of the many VPN services. Here’s the message I get at healthcare.gov without sshuttle.

Access Denied

You don’t have permission to access “http://www.healthcare.gov/” on this server.
Reference #18.22ea4d17.1397361569.6bb6afe

VPN’s even provide vital Internet access to those facing government censorship, and worse.

Options

Setting up a secure VPN server on a linux box can be a pain, and definitely takes longer than 5 minutes. sshuttle takes about that, maybe, if you type really slow.

So, for me, when I found sshuttle, my heart was set, the other options didn’t matter.

Setting Up sshuttle On Ubuntu Flavors

Doesn’t get any easier than this. Run the following in a terminal:

Now, we’re basically going to SSH to our VPS/server. Again, run this in the terminal:

After running sshuttle -r [email protected] 0/0 -vv you’ll be asked for the root password. And sometimes, for whatever reason, it dies immediately after running the sshuttle command.

If sshuttle doesn’t work after running it the first time, run it again! It should work the second time. It could be something with the system I’m on, so hopefully this is isolated to me. :)

Setting Up sshuttle On MacOS

When someone donates me a new Macbook Pro 15″, I’ll start writing this stuff. :)
Update: April 21, 2014 Have a look at this post for using sshuttle with MacOS. Comes courtesy of Aaron Bull Schaefer in the comments.

And if I need a VPS?

You can find a VPS easily with Google. DigitalOcean has them for $5/month, which will be plenty sufficient to use specifically for sshuttle.

Other Options

Lots of other options have been mentioned in the thread at Hacker News. Check em out. Some really good suggestions that are sometimes even cheaper!

Easily Deploy An Open Source Team Chat App to Heroku

lets-chat

Self-hosted chat app for small teams

Let’s Chat is a pretty cool piece of software (no, it’s actually fucking awesome). The ability to run the app on Heroku just makes it that much nicer.

Setting it up on Heroku is quite easy. You can see it running on Heroku at http://yell.longren.io. There’s no admin user, so anyone can register and create their own rooms.

Files can also be posted to rooms, but an Amazon S3 bucket is required for that feature to work. Although, other file storage options are being looked into. Another neat feature is automatic transcript creation. There’s a transcript screenshot in the gallery below.

Prepare Let’s Chat

Open up a terminal and clone the Let’s Chat Git repository:

That will make a local clone of Let’s Chat in the lets-chat folder. Go into that folder, with cd lets-chat.

1. Copy settings.js.sample to settings.js, like so:

2. Remove settings.js from the .gitignore file. Just open .gitignore in your favorite text editor and remove the line containing settings.js.

3. Make any changes to settings.js that you’d like. This is where you’d specify your Amazon S3 credentials to allow storing files in a bucket.

Deploy To Heroku

We’ll be using heroku-app-name as the name of our Heroku app. So you’ll obviously need to change instances of heroku-app-name in the commands that follow.

1. Add a Heroku remote to your newly cloned repository:

2. Add the MongoLab Heroku addon:

3. Get the Mongo URL. Executing the following will give you the Mongo URL, which you’ll need below.

You’ll see some output similar to this:

The Mongo URL is the part that starts with mongodb://.

4. Now, we need to set the Mongo URL:

You’ll want to change the DATABASE_URL variable to the Mongo URL specific to your app.

6. All that’s left is to commit and push to Heroku. You should still be in the lets-chat folder, so, make a git commit! You’ll have to anyway, before you can push to Heroku.

7. Now we can finally push this to Heroku!

Visit your Heroku app URL in your web browser and you should be greeted with a screen that looks similar to the featured image for this post. Some basic screenshots can be seen below!

If you run into any issues or find something I have incorrect, please let me know. You could also see if your problem has already been addressed on GitHub.

This is the steps I took to get Let’s Chat working on Heroku. It’s possible that the project developers will streamline this process in the future. But for now, this is a very easy solution to hosting on Heroku.