A long time ago, on a computer far away from here, I copied and pasted the pattern highlighter from the excellent zsh-syntax-highlighting project and stuffed in a bunch of crappy code so that it would check whether or not a URL was responding with 200 OK.

It was slow, it was buggy, and I never got around to doing anything with it.

Fast-forward 3 or 4 years, a couple of issues on the tracker, and I get a code review.

“What? Someone is code reviewing that piece of junk?”

Yes, they were. And it turns out that my little highlighter was getting many more clones than I expected and was listed on an ‘awesome list’ for zsh plugins.

Ah.

I felt terrible.

All these people who were probably excited at the prospect of highlighting URLs in their command lines, having their dreams shattered by my inability to write zsh code with anything approaching competence.

I needed to fix it. I jumped onto #zsh and #zsh-syntax-highlighting, nagged everyone, asked too many stupid questions and learnt tons. I decided to stop using oh-my-zsh and ‘hand-craft’ my own zsh configs from scratch. It has taken me the best part of too-many-days, but I have a much better understanding of how zsh works and how to manipulate it than I did when I first pushed this highlighter out of my Incompetence and into the Big Wide Internet World.

So, I’ve rewritten it from scratch. It highlights multiple URLs on the same line. It does some basic caching so that it doesn’t request the URLs you type four hundred and seventy million times per keystroke. It even has some configuration options (wow!).

The zsh git plugin offers a handy little function called ‘current_branch’. This will return the current git branch in the current git repository.

You can call zsh functions within commands by wrapping them with ‘$()’.

This helps me to reduce one of the little frustrations I have with git – specifying the branch name when pushing.

Now, I can just type this:

$ git push origin $(current_branch)

Of course, I’ve shortened this by creating an alias for current_branch called ‘cb’, so I just type:

$ git push origin $(cb)

The alias can be added to your .zshrc with the following code:

alias cb="current_branch"

Simple and helpful.

Advertisements

]]>https://asciisoup.wordpress.com/2013/06/09/oh-my-zsh-git-plugin-tip/feed/0nillianrecent-branches – a quick git commandhttps://asciisoup.wordpress.com/2013/02/12/recent-branches-a-quick-git-command/
https://asciisoup.wordpress.com/2013/02/12/recent-branches-a-quick-git-command/#respondTue, 12 Feb 2013 12:57:29 +0000http://asciisoup.wordpress.com/?p=43I’m often switching between the same few branches in git – whether I’ve been distracted by doing a quick fix in another branch, or am doing a code review on a colleague’s branch – and get frustrated with having to type out the name of said branches all the time.

With that in mind, I created a quick ruby script that will show me my most recently checked-out branches (up to a limit of my choosing) and allow me to check one out quickly by typing a number.

As mentioned, the limit can be set by the user, simply by adding the key ‘recent.limit’ to the git config (either –global or in the current project) with an appropriate number.

]]>https://asciisoup.wordpress.com/2013/02/12/recent-branches-a-quick-git-command/feed/0nillianInstalling PHP 5.4.0alpha1 into Wampserverhttps://asciisoup.wordpress.com/2011/07/03/installing-php-5-4-0alpha1-into-wampserver/
https://asciisoup.wordpress.com/2011/07/03/installing-php-5-4-0alpha1-into-wampserver/#commentsSun, 03 Jul 2011 12:18:06 +0000http://asciisoup.wordpress.com/?p=26So, around a week ago PHP 5.4.0alpha1 was released to the QA guys. What does this mean for us? It means we can get a copy of it and tinker around with some of the new features, like traits.

I wanted to do exactly that, and at work we use WampServer so we can easily switch between PHP versions (and it also makes enabling/disabling extensions and options very easy – if you develop on Windows, check it out).

Assuming you have WampServer installed, it is fairly trivial to manually install new versions of the AMP trifecta. Below are the steps to install both PHP 5.4.0alpha1 and Apache 2.2.19-VC9 (which is necessary to run the pre-compiled Windows PHP binaries)

Copy the resulting folders into your WampServer bin directory:
Apache should go in \wamp\bin\apache\apache2.2.19-VC9 (or similar – the important bit is that you place it under \bin\apache)
PHP should go into \wamp\bin\php\php5.4.0alpha1-VC9

Now if you look inside your existing apache folder (\wamp\bin\apache\Apache2.2.17, for example) you should see a file called wampserver.conf. Copy this file into your new apache installation.

Do the same as step5 for your new PHP installation.

It’s a good idea at this stage to copy your existing http.conf (and associated conf files – like vhosts for example) from your previous Apache installation into the new one – otherwise Apache may not start since it will be looking at the Apache default install location etc.

Close WampServer and then start it again; it will read the folders and wampserver.conf files and you should now have the new Apache version and the PHP 5.4.0alpha1 in your WampServer menu!

Open the Apache submenu, hit version and choose the new Apache version. Do the same for PHP. It may take a f couple of goes to get the new Apache + PHP versions to become “active” as I’ve found WampServer can sometimes silently fail to set a new version.

Next time, I’ll show you how to you can hack customise the WampServer menu to add some helpful shortcuts and change the default text editor used for links to config files.

Advertisements

]]>https://asciisoup.wordpress.com/2011/07/03/installing-php-5-4-0alpha1-into-wampserver/feed/7nillianStatic Rows widget for jQuery Tablesorterhttps://asciisoup.wordpress.com/2011/02/20/static-rows-widget-for-jquery-tablesorter/
https://asciisoup.wordpress.com/2011/02/20/static-rows-widget-for-jquery-tablesorter/#commentsSun, 20 Feb 2011 00:07:31 +0000http://asciisoup.wordpress.com/?p=16I was using the fantastic jQuery Tablesorter plugin at work the other day and needed to keep a single “actions” row at the bottom of the table. I found the “Widget” tutorial and quickly knocked up a new widget that ensured my actions row stayed at the bottom when the columns were sorted, and then added the tidy-up job to my todo list.

So here it is. I tidied up the widget I created and allowed any rows to be marked as “static” by simply adding the “static” class to the <tr> tag.

Hopefully this will be of use to someone out there, as I found nothing while searching for something similar last week.

If you do use this widget, please let me know how you got on and if you find any bugs, please report them!

]]>https://asciisoup.wordpress.com/2011/02/20/static-rows-widget-for-jquery-tablesorter/feed/14nillianNot everything has to be a website!https://asciisoup.wordpress.com/2011/02/03/not-everything-has-to-be-a-website/
https://asciisoup.wordpress.com/2011/02/03/not-everything-has-to-be-a-website/#respondThu, 03 Feb 2011 16:25:27 +0000http://asciisoup.wordpress.com/?p=5Being a web developer, and working for a web development company, I often find myself coming up with ideas for new in-house tools that can improve our day-to-day lives.

Where I work, we have “creative days” once a month where us devs get to spend the whole day doodling around, playing with new technologies, building tools and generally just flexing our grey matter and keeping our skillset sharp.

Being a web developer, and working for a web development company, I often find myself building these tools as websites. It stands to reason; I use the LAMP[hp] stack all day, I live and breathe web and web technologies. Lately, however, I’ve been fiddling with C# and building *gasp* … desktop apps.

I know, I know. I’m a web developer, and I work for a web development company.”Ooh”, I think, “Wouldn’t it make sense to build these tools as universally-accessible websites? That way, you can access them from anywhere and they can all share data easily and blah blah blah..”

Yeah, that’s what I’ll do.

We use an in-house project management/issue tracking/invoicing *website* to do pretty much everything we might need. But you know what? It’s clunky. Even with AJAX and nice fast Javascript it just … it isn’t a native desktop application. It doesn’t have that same feel.

So, sod it. I built an application that consumes a REST webservice from our project-management-does-everything-and-shaves-your-hamster website which allows us to track time with an automatic timer. It hides when we’re not using it. It updates itself on-the-fly. You don’t need to click links and wait for pages to load. You don’t need to worry about pressing backspace when you’re not in a textbox and going back to the previous page. You don’t have to worry about a slow internet connection (or heavy office internet usage) slowing you down.

Nope. It all just works. Offline. And with the speed and fluidity that only really comes from subtly-threaded desktop applications.

There, I’ve said it.

Being a web developer, and working for a web development company, I sometimes build desktop applications.