Git: Reverting files in working copy

If you have want to revert some single file in your working copy to the “official” repository version use $ git checkout filename. git revert does not work like in other versioncontrol systems, instead it reverts already submitted changes.

If you want to revert the whole working copy use git reset.

See also man page of git-revert and Bryan Murdocks blog post.

Correct wrong exif timestamps

Found out that the exif timestamps of my last holiday pictures had the wrong timezone. This can be easily corrected with Phil Harveys exiftool. There is even a description of exactly that problem in the documentation

In my case I did not only correct the timezone shift, but also the error to UTC time. For this purpose I simply took a picture of my GPS receivers clock display to compare the GPS / UTC timestamp to the EXIF data. It was a time shift of plus 59 minutes and 39 seconds so I used the following command line:

$ exiftool -AllDates+=:59:39 pictureDirectory

Note that by default exiftool generates backup copies to *_original files which you may want to delete afterwards.

Debugging Exchange IMAP sessions with openssl s_client

I was just curious about the fact that openssl s_client -connect exchangeserver:993 was not working the way I expected it to work. I saw the greeting of the server but wasn’t able to do send any commands such as A1 CAPABILITY. The same worked for all other servers in the past.

Interestingly enough telnet exchangeserver 143 worked, but for obvious reasons unencrypted connections are not an option.

The reason behind is that in fact IMAP and telnet protocol and uses CRLF as line endings and Exchange servers are a bit picky on this specific point. As openssl is not a native client like telnet it sends whatever the terminal uses.

However there is already an solution builtin openssl s_client. Just pass the additional crlf option:

$ openssl s_client -connect exchangeserver:993 -crlf

Show http header / file information without actually downloading

To show the http meta information such as modification date or file size without downloading actually the data you can use the following commands:

$ HEAD http://www.georglutz.de/blog
200 OK
Cache-Control: no-cache, pre-check=0, post-check=0
Connection: close
Date: Sat, 05 Sep 2009 18:12:30 GMT
Pragma: no-cache
ETag: "Sat, 05 Sep 2009 09:11:22 GMT"
Server: Apache/2.0.52 (CentOS)
Content-Type: text/xml; charset=utf-8
Expires: 0
Last-Modified: Sat, 05 Sep 2009 09:11:22 GMT
Client-Date: Sat, 05 Sep 2009 18:12:31 GMT
Client-Peer: 85.214.18.185:80
Client-Response-Num: 1
Set-Cookie: PHPSESSID=xyz; path=/
Set-Cookie: PHPSESSID=abc; path=/
Status: 200 OK
X-Blog: Serendipity
X-Powered-By: PHP/4.3.9
X-Serendipity-InterfaceLang: de
X-Serendipity-InterfaceLangSource: Content-Negotiation
X-Session-Reinit: true

$ wget -S --spider http://www.georglutz.de/blog/feeds/index.rss
Spider-Modus eingeschaltet.  Prüfe ob die Datei auf dem Server existiert.
--2009-09-05 20:13:38--  http://www.georglutz.de/blog/feeds/index.rss
Auflösen des Hostnamen »www.georglutz.de«.... 85.214.18.185, 2002:55d6:12b9::1
Verbindungsaufbau zu www.georglutz.de|85.214.18.185|:80... verbunden.
HTTP Anforderung gesendet, warte auf Antwort...
  HTTP/1.1 200 OK
  Date: Sat, 05 Sep 2009 18:13:38 GMT
  Server: Apache/2.0.52 (CentOS)
  X-Powered-By: PHP/4.3.9
  Status: 200 OK
  Set-Cookie: PHPSESSID=xyz; path=/
  Expires: 0
  Cache-Control: no-cache, pre-check=0, post-check=0
  Pragma: no-cache
  Set-Cookie: PHPSESSID=abc; path=/
  X-Session-Reinit: true
  X-Serendipity-InterfaceLangSource: Content-Negotiation
  X-Serendipity-InterfaceLang: de
  X-Blog: Serendipity
  Last-Modified: Sat, 05 Sep 2009 09:11:22 GMT
  ETag: "Sat, 05 Sep 2009 09:11:22 GMT"
  Connection: close
  Content-Type: text/xml; charset=utf-8
Länge: nicht spezifiziert [text/xml]
Datei auf dem Server existiert.

In Fedora 10 HEAD is part of the package perl-libwww-perl.

Use terminal scrollback buffer in screen sessions

Its quite annoying that in screens default settings you cannot scroll back in history like you used to with shift-pageup/shift-pagedown,

In order to be able to use the local scroll history of your terminal add this to your ~/.screenrc

termcapinfo xterm|xterms|xs ti=\E7\E[?47l