Mon, Jun 09, 2014

[Icon][Icon]For the sin of moving & editing in one commit

• Post categories: Omni, Technology, Programming, Helpful

A good rule of thumb for version control is to have each commit reflect a single operation. Nowhere is the failure to adhere to this rule more annoying than when somebody moves a block of code *and* edits it in a single commit: The move makes the whole block show in the diff, so you can't see the small edit as well.

That is:

$ cat <<EOF> oldfile
heredoc> one
heredoc> two
heredoc> three
heredoc> four
heredoc> five
heredoc> six
heredoc> seven
heredoc> eight
heredoc> EOF

git add oldfile; git commit

$ git mv oldfile newfile
$ vi newfile
$ git diff
diff --git newfile newfile
index b00a0f1..9e9d5bf 100644
--- newfile
+++ newfile
@@ -1,7 +1,6 @@

$ git add newfile
$ git commit

We now have this diff for our commit:
new file mode 100644
index 0000000..9e9d5bf
--- /dev/null
+++ newfile
@@ -0,0 +1,7 @@
diff --git oldfile oldfile
deleted file mode 100644
index b00a0f1..0000000
--- oldfile
+++ /dev/null
@@ -1,8 +0,0 @@

and it's not easy to see from this that when moving the file, we also deleted a line.

What we need to be able to do is compare the oldfile and the newfile. We need a function that will take:
$ git-compare [branch/sha/tag/whatever] [oldfile] [newfile]
and DTRT.

So here's the simplest way I could think of to do it, which should work in bash or zsh:
git-compare () {
diff -u <(git show $1^:$2) <(git show $1:$3)

Which gives us:
$ git-compare master oldfile newfile
--- /proc/self/fd/12 2014-06-09 11:58:01.442468718 +0100
+++ /proc/self/fd/14 2014-06-09 11:58:01.442468718 +0100
@@ -1,7 +1,6 @@

which shows us what we want to know: Somebody did indeed move AND edit the file. The monster!


Mon, Apr 28, 2014

[Icon][Icon]America loses the Internet?

• Post categories: Omni, In The News, Technology

So the FCC is looking like it's going to go ahead and destroy Net Neutrality - essentially, meaning that some websites will be faster/cheaper to access than others.

The techie parts of the Web are up in arms about this: They argue it'll destroy competition by favouring rich websites that can pay the ISP's "tax" over new startups that can't - making it that much harder for the next Google/Facebook/Twitter/whatever to happen; that it'll create a two-tier internet; and so on.

They're probably right, but I don't think they're thinking big enough. I think the possible outcome of this could be even bigger: It could remove America from its position as "Hub of the Internet".

To explain:

The vast majority of Internet traffic goes through the USA. If you send an email from Europe, to Europe, you can pretty much gaurantee it'll go via America. That's where most of the big players have their servers, it's how the Net is wired.

That was all well and good, until the recent revelations from Snowden shook things up: European countries started investigating the possibility of keeping their traffic out of the USA. Keep European packets in European pipes, as it were. There was, of course, a lot of outcry about this: The USA objected that it would put American companies at a disadvantage; end users complained that it was unrealistic since most content came from the USA anyway. You'll undoubtedly have seen the debates if you've any interest in the topic.

If the FCC kills Net Neutrality, then non-paying traffic starts to slow down. If, for example, Netflix refuses to pay for the new "high tier" pipes, then Netflix's traffic will slow down. Seems bad not just for US viewers, but for Europeans too: If Netflix gets slowed down, we get screwed too, right?

But if you're Netflix, at this point, why would you stay centralised in the US? Rather than pay US ISP's to speed up your traffic to non-US destinations, wouldn't you just put your content onto European servers to serve European viewers, and thus escape the ISP tax for all your non-US viewers?

In fact, most big players already do just that: Google redirects my "google.com" requests to "google.co.uk" for exactly this reason: To keep my traffic local so responses are faster. What the FCC are doing is making it even more sensible for even more players to do this.

It's also taking away incentive for the ISPs to invest in improving America's already-lagging internet infrastructure: If ISPs can slow down traffic that isn't paying them money, then they don't need to upgrade to high-speed fibre everywhere to keep speeds acceptable: In fact, they have more incentive than ever to avoid it - If traffic that doesn't pay their tax is running over a dog-slow network, then you have more reason to pay for the upgrade. If everything's blazing-fast either way, why would you bother paying for priority?

So the abolishment of Net Neutrality will gaurantee that significant services move out of the US, or at least decentralise more; and it will gaurantee that America's internet will stay slow - unless Google manages to throw so much money out that it finally gets its high-speed fibre everywhere, which is unlikely, let's be honest. And Snowden has already given sound reasons to keep non-US traffic out of the US.

If most content is hosted outside the US, if anything that goes into the US is slow and likely to be spied upon.. then the US becomes a bottleneck. And what does the Internet famously do about obstructions? Yes, it routes around them.

There's no intrinsic reason why the Internet needs to revolve around the USA. They have the main DNS machines, but that's just a matter of convention. The main reason they're the nerve center is historical: They built the internet; so most of the content and services are based there. if the FCC changes that, if the USA becomes a place you have technical as well as privacy-based concerns about sending your traffic to.. then the Internet will simply ditch the USA. The world will route around it.

Snowden gave us the first set of reasons why we should keep our traffic out of the USA. The FCC is about to give us another set.

People don't like change, but inertia only gets you so far. Could the shortsightedness of a few profit-obsessed corporations and the regulators they've bought be about to cost America what is arguably its greatest invention?

We might be about to find out...


Wed, Feb 26, 2014

[Icon][Icon]Walled games

• Post categories: Omni, FOSS, Rant, Technology

This is a rant by somebody who's sick of the "walled garden" approach of many modern technologies. The "iTunes is only for the iPhone"/"Google maps is only for Android"/"Amazon is only for Kindle" nonsense.

There's only one reason that this doesn't annoy me very often. As was famously observed in a film from my youth, "the only winning move is not to play."

My music collection consists of MP3's & OGGs ripped from CDs. I don't subscribe to any movie-suppliers. I've never bough an ebook from Amazon, my Kindle has only DRM-free files from Project Gutenberg & O'Reilly. I have a dropbox account that I don't use: if I want to share files I use Git or SSH. When I want to watch movies on my tablet, I put them into a network-shared folder on my laptop.

The fact that I'm not aware of a single big player that doesn't try to lock you in via these mechanisms; the fact that I prefer to avoid services altogether rather than find one and be chained to it; this is one of the biggest failings of modern technology.

The Web demonstrates what an amazing, powerful thing an open platform is. Anyone can build a web browser, anyone can build a web site.

The fact that Apple, Google, Amazon, Microsoft, and God knows how many others, think that their only chance of keeping customers is to make it impossible for them to leave.. it's a pretty damning statement about their level of confidence in their own products.

And the only reason the average person isn't complaining about it is, the average person hasn't really wanted to switch platforms yet. Apple fanbois don't buy Android, Kindle owners buy their ebooks from Amazon.

Give it a few years. When a few more "latest and greatests" have come along and prompted people to want to make a switch, only to discover they're walled in.


I imagine it won't be pretty.

I'll try to be ready with the violin


Tue, Feb 25, 2014

[Icon][Icon]SSL certificate revoked

• Post categories: Omni, Rant, Technology, Helpful

Because "fuck you", that's why.

I'm testing Zabbix deployment via Puppet. To avoid screwing up our live system with my experimentation, I'm using a few VMs. Which suddenly stopped working: Puppet kept reporting that the puppet server's SSL certificate had been revoked.

Lots of people with similar problems found by Google, nothing that actually helped. I didn't want to get into certificate-generating, I wanted it to JFW.

The most common reason reported for SSL issues is the time being wrong. "date" seemed accurate, but on a hunch I figured it was worth rebooting the VM, which resets the clock. And it was: Suddenly, everything works again.

Only burned an hour fixing that.

So if you're having "certificate revoked" issues with VMs, my advice is to reboot the damn thing and see if the problem goes away. Probably not something you want to play with on a live server, though :)


Fri, Feb 21, 2014

[Icon][Icon]Virtual networking

• Post categories: Omni, Technology, Helpful

I've been using Virtualbox more and more lately. One thing that's bugged me is that if you reinitialise the MAC address of a VM (which you often want to do if you've cloned a VM and want the new machine to have a different IP) it has an annoying tendency to break networking: your ethernet interface just isn't there any more.

On the offchance that other people are bothered by this too, I thought it might be helpful to post the fix for it: Delete /etc/udev/rules.d/70-persistent-net.rules

This file is auto-generated (hey, it's udev!) and contains the MAC address. If you change the MAC address, this file needs to be updated: Networking won't work whilst the wrong MAC address is in here.

I suppose you could manually fix it, but why bother? Delete it, reboot the VM, the file will be re-created with the new MAC. Job done.


:: Next >>

[Links][icon] My links

[Icon][Icon]About Me

[Icon][Icon]About this blog

[Icon][Icon]My /. profile

[Icon][Icon]My Wishlist


[FSF Associate Member]

July 2014
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      


User tools

XML Feeds

eXTReMe Tracker

Valid XHTML 1.0 Transitional

Valid CSS!

[Valid RSS feed]

powered by b2evolution free blog software