Eric L. Barnes

David Walsh has a great post on “Being a Good Member of the Community” in which he outlines 7 steps. My personal favorite is the following:

Include, Don’t Exclude

This simple rule takes on a number of different meanings:

  • Don’t exclude known members of other communities; don’t be adversarial
  • Don’t exclude members of your own community that are known for different roles; let others dip their hands in all pots
  • Don’t exclude new people: every potential new member of the community has value

CodeIgniter url_title

The CodeIgniter url helper contains a very useful function named url_title(). This function is designed to take a string such as “my test string” and convert it to “my-test-string”. This works great for english characters but will/can fail when you throw in accented characters.

To get around this issue you will need to run the convert_accented_characters() on the string before passing it to the url_title. Here is a full example:

url_title(convert_accented_characters('My Café'));

I have seen several bug reports about this and to be honest I feel this is much more expressive than an alternative of:

url_title('My Café', 'dash', FALSE, TRUE); 

If you see the above code in a project can you tell what the FALSE and TRUE does? I even had to look up the function to find out what the current third param was. I had no idea it had a lowercase option. Which in my opinion is not even needed inside the function. Instead you should write it as:

strtolower(url_title('My Café', 'dash')); 

At the end of the day is writing two function calls that bad? It’s expressive, it does the job, and above all you get the same results.

Statamic Sitemap

This is just a few simple template files to generate a sitemap of your site for submitting to Google webmaster tools. It follows the sitemap protocol.

Installation

Copy the contents of all the directories and move them into your Statamic site.

Download

You can clone the repo by running the code below:

$ git clone git://github.com/ericbarnes/statamic-sitemap.git

Or visit the GitHub Repo.

Statamic

If you have followed this blog over the years you know I am always changing something. So this may not surprise you that I have switched blog platforms, again. I had been using Tumblr which is perfect for my normal posting routine. Sharing quick links, photos, quotes, and occasional articles. As much as I liked Tumblr some things just irked me.

  • They control your data
  • No easy way of setting up redirects in bulk
  • No importing

Mainly the control of my data is what I didn’t like. I want all my content stored where I can do what I want with it. Of course they do offer an api but what if one day they stop providing it?

I did have a short stint of using kudos which is a flat file laravel app created by Ian Landsman and it worked great for me. Except for one major drawback. You still have to open your editor and write the post and then push. Just to much work for me and my number of posts went down considerably. I guess I am just lazy :)

A few weeks ago I came across a new cms named statamic and quickly applied for the beta. I ended up getting just before it was officially released but had enough time to play with it and enjoy how they set up the system. Everything is stored as flat files just like the jekyl flavor. But with one huge difference and that is the ability to post from an admin section. Which still just creates flat files.

So now I can post quickly from the admin and later on when I feel like it sync with git so I have a full off site backup of all my posts. Even though the cms is pretty basic the possibilities are pretty much limitless with what you can do with it. For instance I have duplicated my whole Tumblr setup with it. Now I have all four post types and it really wasn’t much work. Just a few hours over two evenings.

Statamic is commercial but the pricing is very fair and I don’t mind paying for something top quality with support. All my little questions have been answered quickly and with a good answer. So yes I fully endorse what they are doing and excited to see them grow.

I will miss the Tumblr followers, but I always have an rss feed you can use to keep up to date ;)

Hosting

Another negative is hosting. With Tumblr it is free and well you can’t beat free. I tried aws but it was to expensive for me. I am outside of my year free micro and it seemed like a micro was running around $30 a month. I started researching other hosting options and was going to go with a shared system but meh. I would rather have full access to do whatever I want. After browsing what felt like weeks I settled on Linode and was lucky enough to get in when they offered a $100 credit. Woot. :)

So now this site is running on Linode with Ubuntu, Nginx, PHP5-fpm, and apc. All data is stored in a private git repo at BitBucket.

CodeIgniter Security Basics

By default CodeIgniter is a very secure framework and it also does a lot behind the scenes to help you out. I was recently contracted to look over a CodeIgniter application that was constantly getting hacked. So in light of what I seen I want to share some common pitfalls you need to avoid.

  1. Use Active Record! You should “almost” never write your queries manually.
  2. If you must write a query without active record be sure everything is escaped properly. $this->db->escape()
  3. Validate user input! CI has $this->input->post(), $this->input->get_post() and you should use those.
  4. Validate file uploads and use the upload library.
  5. Use the framework tools. It comes with tons of libraries and helpers that are designed to help you with common tasks. There is no reason to write your own if already accomplishes what you need.

Yes I know every php developer should know about these but some people still just haven’t gotten the memo. So spread the word, write secure apps, and make the world a better place.