I decided recently to pick up the C# programming language. Actually, I’m quite enjoying it. After spending an aeon in non-strict languages, it’s lovely to be learning a new fully object-oriented and strongly typed language. And, for a bonus, a lot of what I learned in VB.NET applies as far as the Microsoft way of handling thread safety and other similar concepts carries over into the C# realm.
Microsoft offers a reasonably decent C# programming course over at edX. The course material is pretty good, but I have some issues with the “peer review” aspect of it. You have a wildly varying community of people with wildly varying skillsets critiquing your work, so it can at times be unfair. Otherwise, this has been a good experience, and I’ll have a new skill to enjoy when I’m done. Next up: Xamarin.
I’ve finally taken the time to learn Symfony. It really is a remarkable platform, and I’ve been meaning to pick it up for quite some time. My first project is non-pretty, at least visually, but it works well.
I implemented Rock Paper Scissors Lizard Spock as my first exploration into Symfony. It lives at http://roshambo-tng.tk, and you can get the code on bitbucket.
Go get it! In this release, I’ve deprecated the dependency on the Twig templating system. Don’t get me wrong – Twig is fantastic! However, I was only using the tiniest bit of its functionality, and it was really a heavy-handed approach to a simple problem. I refactored the code into a pure PHP alternative in maybe 10 minutes.
Having Twig exposed an issue with both WordPress and PHP (One I should have foreseen, actually). In WordPress, it can be a real challenge to have multiple copies of the same third-party library in the same install. To wit, if two plugin authors both include the standard Twig package, the second authors plugin won’t activate because Twig is already instantiated. Sure you can check to see if Twig already is declared and simply use that instance, but there’s no guarantee that they’re using the same version. If they’re using an older version and you try to use a feature included in the newer version, you’re out of luck.
Namespacing or class nesting could solve the problem. However, PHP doesn’t implement those features well enough (or at all, in the case of class nesting) to solve the basic issue. It would be fantastic to be able to open a new PHP file, declare a namespace, and require Twig, then Twig would be sitting all pretty and ready to go under my own umbrella namespace. Class collisions would be near-impossible.
My opinion of PHP, in general, has changed since I wrote my little post about PHP being web legos. If wielded correctly, PHP can be a fantastic language to work with. But occasionally you still get the feeling that OOP was sort of bolted on (and it was), and miss some of the things you get when a language is object oriented from day one.
I’ve been threatening long enough – I finally wrapped my jQuery.autoTarget jQuery plugin into a WordPress plugin, making it super simple to make all your external links automagically open in a new tab/window. Go grab jQuery.autoTarget for WordPress!
Oh, and in the spirit of Dogfooding, I also use this plugin on this site.
In preparing to roll out a WordPress plugin version of jQuery.autoTarget (currently under review for inclusion in the WordPress Codex), I discovered that I had a slight error in the regular expression I use to extract the domain from all the links on a page. It’s not hard to have an error in a regular expression, they are dark magic after all. It also occurred to me that I was overwriting any extant targets that may be set deliberately by the site owner/developer, so I added in code to prevent that clobbering from happening.
Go download jQuery.autoTarget v1.1.0!
(Update: the WordPress plugin version of this is now up and ready for the masses!)
I finally reached the point where I was tired of finding and copying over the same snippet of jQuery code to make external links automagically open in a new tab/window. So I wrote my first jQuery plugin called jQuery.autoTarget. Super simple to use. Next up will be a WordPress plugin to so the same thing for any given WordPress installation.