Sunday, November 3, 2013

Prop Hunt v3.0 Beta Available

A beta version of Prop Hunt which is compatible with Garry's Mod v13+ is available on GitHub here.

I'm working to get the final v3.0 version released in a Garry's Mod update, as Prop Hunt was shipped with Garry's Mod prior to the v13 update. Please report any bugs/issues/feature requests here.

Sunday, December 2, 2012

Simple Admin on GitHub

The latest Simple Admin source code is now available on GitHub:

https://github.com/andrewtheis/simple-admin

Half-Life 2 Campaign on GitHub

Seems garrysmod.org has been discontinued. You can download the latest version of my Half-Life 2 Campaign co-op gamemode off of GitHub:

https://github.com/andrewtheis/half-life-2-campaign

Some community members will be updating it to work with the latest Garry's Mod release (13). Stay tuned!

Prop Hunt on GitHub

It appears Prop Hunt is no longer shipped with Garry's Mod. You can download the latest source from GitHub:

https://github.com/andrewtheis/prophunt

Note: This version has not been updated to work with Garry's Mod 13. If anyone feels up to the task, fork from GitHub and then a send pull request with updated code.

Tuesday, September 20, 2011

Configuring MAMP 2 php.ini File on Mac OS X

If you are scratching your head over where they stuck the php.ini file in MAMP 2 (both Pro and regular), wonder no more! Doing a quick spotlight search reveals the php.ini file is in one of two locations (based on the version of PHP you are running):
/Applications/MAMP/bin/php/php5.2.17/conf/php.ini
- or -
/Applications/MAMP/bin/php/php5.3.6/conf/php.ini
Hope this helps anyone who has been stuck looking for the file (as I was). Configure away!

Thursday, June 9, 2011

Quick Fix for LLVM Compiler Reachability.h Warnings

If you are using Apple's LLVM compiler and their Reachability.h file you may be getting warnings like this:

Reachability.h: warning: Semantic Issue: Declaration of 'struct sockaddr_in' will not be visible outside of this function

Luckily, there is a quick way to fix this. Simply add this import line to the includes section of the Reachability.h file:


Bam! Warnings gone.

Monday, November 8, 2010

Rails 3 and Form Errors

There seems to be a lot of debate over the best way to replace the error_messages_for helper. It was removed in Ruby on Rails 3 because it conflicted with the core convention that Rails should not define the application's appearance. To compensate the Rails team modified the scaffold tool to generate erb that iterated through the errors and displayed them. It looks something like this:


Well that's cool, you might say. But isn't another concept of Rails "Don't Repeat Yourself" (DRY)? Isn't having that code at the beginning of every form redundant? The answer to both those questions is of course "yes", which is why I find it odd the Rails team chose to replace one problem with another. So let's look at some of the alternatives:

Install the plugin that they exported the function to: While this solution is a great for those who want to upgrade their application quickly to Rails 3, it's not exactly addressing the core issue or following the "convention over configuration" idealogy.

Create a helper function that outputs HTML to your template: Getting closer, but this conflicts with the idea that you should never directly output HTML because it defeats the purpose of the MVC system. The code also just doesn't look very good (if that's important to you).

Move the scaffold generated erb to a partial: Ding ding ding! We have a winner! One of the first videos I remember watching about Rails was the infamous "Create a Blog in 15 Minutes" tutorial. In that video one the first DRY concepts introduced is this idea of using partials. So why not do that here? It allows you to create cleaner looking code, follows Rails conventions like DRY, and is easy to use for all your forms! Easy, right? Let's get started:

Step 1: A Place for Everything

Partials are generally kept inside the same folder that houses the view they are used in. Since we are creating a partial that would probably be used across multiple views/controllers, we need to create a new folder inside our apps/views folder. I've named mine "shared" but you can use whatever name you like.

Step 2: The Partial

Inside your app/views/shared folder create a new file named "_form_errors.html.erb". Remember, the underscore at the beginning is a Rails naming convention that indicates that this file is a partial.


As you can see, this code looks very similar to the code generated by the scaffolding tool, but with some important differences:
  1. The @model instance variable has been replaced with the local variable object. This variable will passed through from our form view.

  2. The error message in the <h2> tags has been replaced with something more generic so that it may be used across all of our forms.

Step 3: The Form View

Lastly, we need to add the render partial function to our form view.


And that's it! Simply use the above code in any view you wish to display the form errors partial. I hope this has helped someone. If you have any questions/suggestions/thoughts on this be sure to let me know in the comments!