CK knows Wayne

MS SQL Server: German date/time values

Published at by Christian Kruse, updated at 16/12/2011, 01:52pm
Filed under: mssql, german, date, time

When working with the MS SQL Server Enterprise Manager and german date/time values, I often geht the error message „Ihr Eintrag kann nicht in keinen gültigen Datum-Zeit-Wert konvertiert werden” (can't convert value to a valid date-time-value), even when using the display format if the database (dd.mm.yyyy), the ANSI date format (yyyy-mm-dd) or the american date format (mm/dd/yyyy).

The Solution is very simple: use the german date format, but without the periods. Instead use the slash: dd/mm/yyyy. Yet another fucked-up thing I don't like with the MS SQL Server.

No comments, yet

MSSQL with PHP: smalldatetime

Published at by Christian Kruse, updated at 10/11/2011, 10:17am
Filed under: mssql, php, smalldatetime, bug, crash

A few days ago I got a SIGSEGV when querying the MSSQL server with PHP. There was nothing special with the query, just a normal SELECT statement, even without WHERE limitations. After examining it a little bit I found out, that it depended on the columns I selected. When I left out some specific columns in the SELECT, everything was ok.

First I thought that it depends on the values of the columns, but I couldn't really figure out a systematic. So only one conclusion is left: it is the column type. PHP crashes when querying a column with the smalldatetime type. After some research I found, that it depends on the configuration parameter mssql.datetimeconvert. If it is turned on, PHP crashes. If it is turned off, everything works fine. So for now, all my PHP scripts working with MSSQL Server begin like this:

if(ini_get('mssql.datetimeconvert')) {
	echo "---------- WARNING! TURN OFF mssql.datetimeconvert! It causes PHP to crash on smalldatetime fields!\n";
	echo "We're turning it off now for this script, but you should do it globally!\n";
	ini_set('mssql.datetimeconvert',"off");
}

Hope that helps.

No comments, yet

28C3

Published at by Christian Kruse, updated at 06/11/2011, 10:27pm
Filed under: ccc, 28c3

We've got 28C3 tickets. See ya there! :-)

No comments, yet

Easy machine readable date formats with MS SQL Server

Published at by Christian Kruse, updated at 20/09/2011, 10:41am
Filed under: ms, sql, server, date, datetime, machine, readable

The last few hours I was looking for a method to make the date and datetime data types easier machine readable and more predictable in string representation. There are two things you have to do:

  1. The first thing is to select the correct language environment, just to be sure. I my case this is english: SET LANGUAGE english. This ensures, that the „natueral representation“ is always the same.
  2. The second thing is: you have to type cast the date/datetime field via CONVERT(): CONVERT(char(19),DateTimeField,120) AS DateTimeField for datetime fields and CONVERT(char(10),DateField,103) AS DateField for date-only fields.

Kind of fucked up, but if you have to use MS SQL Server you are used to fucked-up solutions.

Hey, two comments!

Remove password from SSL certificate key

Published at by Christian Kruse, updated at 02/09/2011, 01:44pm
Filed under: computer, work, ssl, certificate, key

Because I never remember: here is how to remove the password from a key to a SSL certificate:

openssl rsa -in they_key_file.key -out they_key_file_no_password.key
No comments, yet

Vacation Summer 2011

Published at by Christian Kruse, updated at 11/08/2011, 03:24pm
Filed under: vacation, 2011, summer

Starting from tomorrow afternoon I'm on vacation, for three weeks - without internet, without phone. Yeah! So I won't be able to answer mails.

No comments, yet

Linux: my desperate search for the right distro

Published at by Christian Kruse, updated at 08/08/2011, 02:37pm
Filed under: linux, distro, gentoo

As I recently switched back to Linux, for me a Holy Quest for the One Right Distro began. I used to use Gentoo, but maintaining a Gentoo system is a whole bunch of work. You have to fiddle and twiddle again and again to keep it running. So I began to look for something new:

This all leads to one conclusion: back to Gentoo. It may be more work to maintain a Gentoo system, but with this work you gain the freedom to explicitely choose what software and which version should be installed. Gentoo is still simply the system which fullfills most of my needs.

No comments, yet

Erlang: if or case of

Published at by Christian Kruse, updated at 19/07/2011, 11:02pm
Filed under: erlang, functional, programming

The last few weeks I started to learn Erlang, a functional programming language designed to be very solid. This is my first functional programming language I am really learning. At the university I had a small look at Haskell, but I was never really interested in it.

After writing my first few lines of code, the following question came to my mind: when do we use case of and when do we use if? In traditional non-functional programming languages the difference was clear. But the differences blur in functional languages. So what would you write, and why? Given the following example:

case is_pid(Pid) of
    true ->
        Pid ! {send, ["QUIT :", ?QUITMSG]},
        Pid ! quit;

    false ->
        ok
end

Or

if
    is_pid(Pid) ->
        Pid ! {send, ["QUIT :", ?QUITMSG]},
        Pid ! quit;

    _ -> ok
end

Personally I would prefer the second variant, since one can see on the first look what which branch does. What do you think, and why?

Oh my god! Six comments!

Duplicate entries

Published at by Christian Kruse, updated at 12/07/2011, 09:08am
Filed under: burp, blog, bug

It may happen that duplicate entries occur in your feed reader when you are following our feeds. I'm sorry about that, I had to do a major software update and for this update I had to remove the dots from my URI tags. This leads to the above described bug. I'm sorry for the inconvenience.

No comments, yet

Emacs: restore last frame size on startup

Published at by Christian Kruse, updated at 09/07/2011, 10:26pm
Filed under: emacs, frame, size

Emacs is my favourite editor. I use it for about 10 years now, and there is no editor fullfilling my needs as good as Emacs does. But one thing bothered me always (but not enough to repair it - until now): everytime I start Emacs, I have to resize it to the right size. The .Xressources is not a real option for me, because I use to change my desktop environment from time to time. And this changes the geometry of the desktop, too. Also I have two workstations (one at work, one at home), and the settings differ there, too.

To solve this problem ones and for all, I wrote a small Lisp plugin to save the last frame size in a file and restore it on next startup:

(defun save-framegeometry ()
  "Gets the current frame's geometry and saves to ~/.emacs.d/framegeometry."
  (let (
        (framegeometry-left (frame-parameter (selected-frame) 'left))
        (framegeometry-top (frame-parameter (selected-frame) 'top))
        (framegeometry-width (frame-parameter (selected-frame) 'width))
        (framegeometry-height (frame-parameter (selected-frame) 'height))
        (framegeometry-file (expand-file-name "~/.emacs.d/framegeometry"))
        )

    (with-temp-buffer
      (insert
       ";;; This is the previous emacs frame's geometry.\n"
       ";;; Last generated " (current-time-string) ".\n"
       "(setq initial-frame-alist\n"
       "      '(\n"
       (format "        (top . %d)\n" (max framegeometry-top 0))
       (format "        (left . %d)\n" (max framegeometry-left 0))
       (format "        (width . %d)\n" (max framegeometry-width 0))
       (format "        (height . %d)))\n" (max framegeometry-height 0)))
      (when (file-writable-p framegeometry-file)
        (write-file framegeometry-file))))
  )

(defun load-framegeometry ()
  "Loads ~/.emacs.d/framegeometry which should load the previous frame's geometry."
  (let ((framegeometry-file (expand-file-name "~/.emacs.d/framegeometry")))
    (when (file-readable-p framegeometry-file)
      (load-file framegeometry-file)))
  )

;; Special work to do ONLY when there is a window system being used
(if window-system
    (progn
      (add-hook 'after-init-hook 'load-framegeometry)
      (add-hook 'kill-emacs-hook 'save-framegeometry))
  )

;; eof

Emacs rocks :-)

Woho! Three comments!

You can find older postings in the archive.