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.
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");
}
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:
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.
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.
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:
First of all, I tried Debian. Debian is the favoured distro of many of my friends, so I decided to give it a chance. And of course I hit the common problem of Debian: old software. My NIC was not supported, because of the old kernel version Debian Squeeze uses.
Second choice was Ubuntu. Ubuntu recently switched to Unity, which made me kind of curious. But I couldn't change anything at all, I could not even move the fucking bar on the left to the bottom. So… mkfs.ext4 /dev/sda3
Next I gave Fedora a try. Fedora uses GNOME3, which in fact has the same problem as Unity: you cannot change anything. They basically removed nearly all configuration options in GNOME3.
Next I tried Arch Linux. Basically, archlinux is binary rolling release distribution, so exactly what I was looking for. In fact, I like archlinux. It brings a ports-like system (the AUR) for non-supported software. It misses just one thing: packet versioning. You are not able to install an older version of a software. You are only able to say „no, I don't want to update this software now.“ But this function is a feature I really need, e.g. because I don't want to upgrade to GNOME3 or KDE4.7.
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.
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?
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.
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