As knowledge workers, there’s a huge benefit to us knowing how to do things are quickly as possible in our environments of choice. It doesn’t mater if that’s an IDE or Excel every second saved can really add up.

I use Sublime Text every day at work and some days when I’m not working (today I’m off work but I’m working on this post using Sublime Text) so I thought it would be a good place to start. The goal is to release short posts every week so instead of having to digest a HUGE article with tips you can learn a few and them apply those to your daily work. Some of my examples will be geared towards PHP developers specifically but I think most will be applicable to anyone using Sublime Text.
If you feel like I’ve forgotten something or want something added please feel free to leave a comment on this page and we’ll add it.
We recently hired in a new Junior Developer and it’s been interesting to see how well they understand the basic PHP functions but get a little lost when they use some of our more advanced OOP classes. If feels like forever ago I went off on a rant about how we teach programming in what feel like a backwards way to the way I work every day:
When I learned to program in an academic setting (over a decade ago), we learned the basics of programming first (if block, for loop, functions, etc.) and then object oriented programming. This makes sense because it allows you to quickly write programs that do something but I think it teaches you the “wrong” way to structure your code. I think because of this some of the programmers I’ve worked with have been really good at writing code that can be used in one place (and can be copied and pasted into others :-)) but haven’t always been good at writing code that can be unit tested and reused without duplication.
It’s caused me to think about learning PHP using TDD and what that would look like.
When I learned how to program using C++ all those years ago I was given an example like the following (my guess is that this won’t compile so don’t even try it):
#include "iostream.h";
void main(){
cout << "Hello World!" << endl;
return;
}If I recall correctly, the author of the book I was learning from then went into detail about what each line did but the amazing thing was that I was able to type this into an editor and it would compile. That’s all it took to get a program up and running.
After this we started learning about variables, control statements, and functions. It was only later that we learned about classes, inheritance, and polymorphism.
Only now I realize we learned about the very basic statements, then functions and how they’re composed of multiple statements, and finally classes which are composed of multiple functions. Small pieces build up to larger pieces. From a learning stand point this makes sense. It’s easier to get going quickly and maximize the “wow” of programming so we didn’t lose interest.
For a long time I really didn’t “get” how classes could make my life easier.
So let’s look at what would be involved in learning PHP if we taught everything TDD first. We would have to invert the learning process of statements > functions > classes to classes > functions > statements. Practically, it would flatten our learning process from learn statements, then functions, then classes to just learn all three in one go.
Programming languages like C# force this concept on us because everything must be a class so I wonder if this is even a problem.
I think the most interesting part of any programming language is the “Hello World!” example. The basic PHP version is simple:
<?php
echo "Hello World!";Hard to get simpler than that.
Now let’s look at a classed version:
<?php
class Application
{
public static function run()
{
echo "Hello World!";
}
}
Application::run();This is the simplist version of this I could create. If we were doing it the best practice way we would move the class into it’s own file, use an autoloader, setup DocBlocks, and the biggest problem with this is that it’s not easily testable.
Let’s think about this some more. We could use the code above as our learning application and build on it. By doing so we can teach best practices:
It makes our hello world example MUCH longer and harder to understand but I almost wonder if it’s worth it.
When I work on my site I start jekyll using the following command line:
jekyll serve --future --draftsI like this because it shows me what I’m working on and regenerates the files as things are updated:
Regenerating: 1 file(s) changed at 2016-05-22 14:24:25 ...done in 5.648222 seconds.
Regenerating: 1 file(s) changed at 2016-05-22 14:24:43 ...done in 5.055759 seconds.The downside to this is that if I’m quickly switching between proof reading a post and editing a post it gets a little slow waiting 5+ seconds for the page to regenerate (you should try it). I started looking into the documentation for jekyll serve and there’s an option that allows you to limit how many posts it uses:
jekyll serve --limit_posts 50 --future --draftsThis cuts down the time required to see my changes:
Regenerating: 1 file(s) changed at 2016-05-22 14:25:29 ...done in 1.168727 seconds.
Regenerating: 1 file(s) changed at 2016-05-22 14:25:49 ...done in 0.96031 seconds.That 4 seconds makes a huge difference.
I’m writing this post for two reasons:
This post is almost completely a copy and paste job of the notes I created while I was building my last project using Symfony 2.7.
Read MoreI do all of my primary development work on a Windows computer that runs several Vagrant VMs. The other day I needed to add an executable to my repo and have it be automatically marked as an executable file on all the servers (this project isn’t running Ansible yet so it’s not an option).
If I was running a fully Linux development environment I could just do the following:
chmod +x /path/to/file
git add /path/to/file
git commit -m "Added file"But this doesn’t work because of the way Virtual Boxes virtual folders work. In order to do this I need to run the following in Windows:
git update-index --chmod=+x /path/to/fileThen I can commit the file and it will be marked as executable when it gets git pulled to the server.
Most of my life I’ve been a Warren. When my wife and I got married we decided to take each others names and my last name became Keck-Warren. My assumption was that it would be hard to get the DMV to change my license but then I would be on my way.
But I was wrong. It turns out that it was easier to get some of my socially conservative family members to understand than it was to get some computer systems.
People have crazy names and if you create a barrier that prevents then from signing up because their last name has a space or a hyphen they’ll go somewhere else. It also causes all kinds of information mismatches between sites and systems.
I had to visit a hospital for a couple tests right after I changed my name and their computer systems didn’t accept hyphenated last names. I was shocked that a hospital’s computer system wouldn’t allow the hyphen. We were able to move on through the process by removing the hyphen but the real problem started when they tried to bill my insurance. My insurance had a hyphen in my last name but the hospital didn’t. Because of this mismatch it caused my insurance to reject the claim.
This was strike on against this hospital and I haven’t been back.
Several times over the last couple years I’ve tried to sign up at various websites only to be told that my last name isn’t valid. My first fix is to remove the hyphen and that usually fixes the problem.
Test your sites signup process with common last name “oddities” things like Keck-warren, O’Connor, “van der Wall”, and McDonald. Test with non-latin names like Авандеев and قذافي. Everything you can do to make sure new users can get in because the rest of us non-alpha character last name people will thank you and you might end up with a few more customers.
As developers it’s super helpful to log information to a file so we can retrieve it later. The problem we run into is that over time those log files can take up a lot of space so it’s important to clean them up. We could do that manually by logging into the server and manually deleting them but that’s time consuming and it would be better if we could just have the server do it automatically.
Read Moresubscribe via RSS