Git fu: Bash addons

My .bash_profile, sourcing git-completion.bash to get autocomplete for git itself and git-flow-completion.bash to get autocomplete for git-flow, along with two single character shortcuts for the most common shortcuts (s for `git status`, d for `git diff`). And my .gitconfig, among regular config and customizing colored output also defining a bunch of aliases:


(If you’re reading the feed, check this gist).

The export line configures bash to show the current directory (full path!), and, if in a repository, the repository type and current branch, looking something like this: ~/dev/qunit [git:master] $
For that to work, `vcprompt` needs to be installed. If you’re using homebrew:

`brew install vcprompt`

The last line in the .bash_profile overrides the `git` command to point at hub, which wraps `git` to provide a few additional commands that make it easier to work with GitHub projects. Among others, it infers projects based on the current git repository and its remotes, powering the git-fork alias, which I use whenever I test and merge pull requests. Say someone named `beefheart` sends a pull request for jquery/qunit. All I do to get his remote is this:

`~/dev/qunit [git:master] $ git fork beefheart`

So much easier then trying to put together the correct .git URL for his fork, then wrapping that with the right invocation of `git remote add -f`.

Another GitHub specific command is ghpages: It assumes you’re on master, pulls changes, checks out the gh-pages branch, merges master and pushes those changes, then checks out master again. Useful if you keep a 1:1 copy of your master branch as a gh-pages preview.

Other aliases I use all day:

  • `git cm “Message 123″` to commit all updated files without having to launch an editor
  • `git br` and `git co` to create, switch and delete branches
  • `git lp` to see commits with diffs
  • `git lg` to see a kind-of tree view of commits – will show the commits a merge commit added directly after that merge commit, instead of the usual chronological order of `git log`. Very useful to review a banch of merges.
  • `git undo` to revert bad merges
  • `git co .` to revert all changed files

Some more git related tools are provided by git-extras, where I now use git-changelog to create the release notes for QUnit.

I use iTerm 2 on OSX, if nothing else, for the ability to easily display multiple terminals side by side.

If you use ZSH, apparently you can get a lot of this bundled via oh-my-zsh.

Release: Validation Plugin 1.9.0

An update for the jQuery validation plugin is available. Most notable is heavily improved compability with HTML5 controls: You can apply validation rules to input types like number, email or url, it’ll get picked up by the plugin if the type matches a rule, and a required attribute (with the argument) also works with both jQuery 1.6+ (prop) and previous versions (attr).

Another change should make the setup of forms with hidden elements easier, these are now ignored by default (option “ignore” has “:hidden” now as default). In theory, this could break an existing setup. In the unlikely case that it actually does, you can fix it by setting the ignore-option to “[]” (square brackets without the quotes).

A few improvements and bug fixes for validation methods landed:

  • Creditcard now accepts spaces between the other valid characters
  • Email doesn’t accept a dot character at the end anymore.
  • The time method (in additionalMethods.js) is now more thorough.
  • A time12h method got added (also in additionalMethods.js), to validate 12-hour times, while the existing time method does 24-hour times.

There also two new localizations, resulting in a total number of 38 localizations. Existing localizations saw various improvements – thanks to everyone who contributed those! Its the only feature where I’m relying completely on contributions, as I can’t verify the correctness of any of the localizations (other then English and German).

Backwards compatibility is still going strong: The plugin should work with anything from jQuery 1.3.x to 1.6.x.

Download this release.

The full changelog:

  • Added Basque (EU) localization
  • Added Slovenian (SL) localization
  • Fixed issue #127 – Finnish translations has one : instead of ;
  • Fixed Russian localization, minor syntax issue
  • Added in support for HTML5 input types, fixes #97
  • Improved HTML5 support by setting novalidate attribute on the form, and reading the type attribute.
  • Fixed showLabel() removing all classes from error element. Remove only settings.validClass. Fixes #151.
  • Added ‘pattern’ to additional-methods to validate against arbitraty regular expressions.
  • Improved email method to not allow the dot at the end (valid by RFC, but unwanted here). Fixes #143
  • Fixed swedish and norwedian translations, min/max messages got switched. Fixes #181
  • Fixed #184 – resetForm: should unset lastElement
  • Fixed #71 – improve existing time method and add time12h method for 12h am/pm time format
  • Fixed #177 – Fix validation of a single radio or checkbox input
  • Fixed #189 – :hidden elements are now ignored by default
  • Fixed #194 – Required as attribute fails if jQuery>=1.6 – Use .prop instead of .attr
  • Fixed #47, #39, #32 – Allowed credit card numbers to contain spaces as well as dashes (spaces are commonly input by users).
As usual:
  • Please post questions to the official Using jQuery Plugins Forum, tagging your question with (at least) “validate”. Keep your question short and succinct and provide code when possible; a testpage makes it much more likely that you get an useful answer in no time.
  • Please post bug reports and other contributions (enhancements, features, eg. new validation methods) to the GitHub issue tracker

Enjoy!

Links related to software patents

This post is meant to gather articles or other links on the topic of software patents. If you have something to add, let me know!

  • To start with, Dilbert takes the opportunity to make fun of ‘em today.
  • Next up, Martin Fowler on software patents, but starting of with some background on where patents originally came from and how they likely helped enabling much of the industrial revolution, laying the ground for the world of regular change we live in today. He also outlines how certain core principles got disposed, making especially software patents reverse the effect they were originally intended for.
  • The term “patent troll” refers to a company that holds certain software patent, yet has no product on its own, allowing them to sue other, usually bigger, companies for infringing their patents. Unlike one big company with a patent portfolio sueing another big company, which can then count-sue them, the patent troll has no product, therefore nothing to infringe with. A prime example of such a patent troll is Eolas – their one or two patents are about basic browser technologies. Microsoft spent more then a decade with them until finally giving in, and in 2009 they sued a bunch of other big companies. The Wikipedia article has a full list and more details.
  • The item above claims that big companies don’t sue each other due to both sides holding enough patents. Of course the reality isn’t as simple as that. Just this week Google posted a non-subtle piece on how they are getting sued by Microsoft and Apple, apparently with the goal of killing Android, with Apple (iPhone) and Microsoft (Windows Mobile) having an interest in getting rid of that.
    • As everything, that Google piece should be taken a grain of salt. Which, for example, this Forbes article doesn’t seem to do. It quotes parts of the Google post, then adds how they should go further on lobbying to get rid of patents completly: “So if abolition is the right reform (and I think it is), then companies that say so early are going to look prescient”. There’s no attempt in looking at the other side of the coin.
    • A much more reflecting post is, pure coincidence I guess, by Dennis Forbes, a software architect from Toronto. He starts out calling the Google post what it really is: “Google has started an assault by posting some hypocritical and self-serving missives. I would expect absolutely nothing less in such a situation. When you’re in a position of weaknesses you attack the things that make you weak. It is predictable and consistent with every corporation since the dawn of time”. And then goes into detail on the relationships between Google and IBM (covering each others back right now), Oracle, Apple and Microsoft. In the end he concludes: “Patents by their definition are anti-competition on the premise that they’re pro-innovation. In current practice they are anti-innovation.”
    • Yet another article goes a bit further in in not-fanboying Google, but instead calling them out as pussies. He does so a bit too often, but its still well worth a read. Basically he goes into detail how Google is making billions from the search and ads monopoly, then using that money to buy or destroy other businesses, without any innovation anywhere. There’s obviously a lot of bullshit in this article as well, but when put together with the other pieces, presents a much more interesting picture of the overall situation.
    • Another post, Groklaw on “A Brief Explanation of Microsoft’s Anti-Google Patent FUD”, more on the “Google isn’t whining” side, takes the Google post a apart, and unlike the other articles above, provides a lot of links and references, including tweets from Microsoft employeers and emails related to patent bids. The article also links to another post on the site, about “What to Do If You Receive a Lodsys Letter“. This one goes into detail on another patent troll, Lodsys, targeting small companies developing for iOS.

Finally one more link to a subgroup of a special-interest commission of the german government, the “Projektgruppe Interoperabilität, Standards, Open Source”. If I don’t happen to find someone to help out with that, someone with more experience in this area, I’m planning to post a proposal there covering software patents, with the general idea of making sure that, while software patents are granting in Germany, won’t ever get to a point where they can get enforced in court. Right now I need more information on the actual situation here. The resources I’m gathering here should help providing references for that proposal.

In regards to german legislation, there’s a petition against software patents, sponsored by the absurdly german named “Förderverein für eine Freie Informationelle Infrastruktur e.V.” (FFII). Online petitions are kind of silly, but at least here the petition site seems to be gathering some useful references.

For resources as they come in:

Release: Validation Plugin 1.8.1

An update for the jQuery validation plugin is available. This brings compability with jQuery 1.6.1, while staying backwards compatible with 1.3.2, 1.4.2, 1.4.4 and 1.5.2.

The bug was related to the plugin’s usage of the form.elements property, which jQuery 1.6 doesn’t support anymore. Other then that, there is a bug fix for adding and removing the error and valid classes on radio and checkbox elements (thanks to Phil Haack for the contribution), as well as two new localizations: Thai and Vietnamese. That brings the plugin to a total of 37 supported locales.

If you’ve been testing 1.8.0 release with jQuery 1.6 and couldn’t get it to work, despite the note saying that its working, please update to 1.8.1. The form.elements fix was in place before 1.6 final got released, and I only tested against latest code on GitHub, while 1.8.0 was indeed broken.

Download this release.

The full changelog:

  • Added Thai (TH) localization, fixes #85
  • Added Vietnamese (VI) localization, thanks Ngoc
  • Fixed issue #78. Error/Valid styling applies to all radio buttons of same group for required validation.
  • Don’t use form.elements as that isn’t supported in jQuery 1.6 anymore. Its buggy as hell anyway (IE6-8: form.elements === form).
  • Please post questions to the official Using jQuery Plugins Forum, tagging your question with (at least) “validate”. Keep your question short and succinct and provide code when possible; a testpage makes it much more likely that you get an useful answer in no time.
  • Please post bug reports and other contributions (enhancements, features, eg. new validation methods) to the GitHub issue tracker

Enjoy!