Sunday, December 9, 2012

Flexible inline enumerate

I was asked to produce an inline enumerate with more flexibility and i quite like the solution. Just include enumitem
\usepackage[inline]{enumitem}
and then define
 
\newenvironment{my_enum}[1]{\begin{enumerate*}[itemjoin={{; }}, itemjoin*={{; #1 }}]}{\end{enumerate*}}
\begin{my_enum}{as well as}
  \item foo
  \item bar
  \item baz
\end{my_enum}
.

Saturday, December 8, 2012

How Windows development works

Or doesn't at times.
Former Windows Developer
I hope this is somewhat overstated (I am not going to push the disgruntled employee cliche), although I am inclined to believe it simply on the grounds of how the development in large projects works.
Quite sad.

Friday, October 26, 2012

Multiple Mediawikis on one host and/or short URLs

I wrote up a guide to setting up the above mentioned pieces of the puzzle, head here if you are interested.

Friday, October 19, 2012

apache ssl warnings on client localhost

Have you seen these before?

[Fri Oct 19 18:48:22 2012] [info] Seeding PRNG with 1824 bytes of entropy
[Fri Oct 19 18:48:22 2012] [info] [client ::1] Connection to child 0 established (server tehsuck.de:80)


The reason for this is, that spawning a new process for every request is expensive (time and ressourcewise) and thus apache prespawns them and keeps them around. When it now manages this group of proces that all listen to a port and wait for a connection, it just wakes them by talking to them on the port specified last in the config.
Now maybe you have seen these:

[Sun Oct 14 09:55:39 2012] [info] Seeding PRNG with 1824 bytes of entropy
[Sun Oct 14 09:55:39 2012] [info] [client ::1] SSL library error 1 in handshake (server tehsuck.de:443)
[Sun Oct 14 09:55:39 2012] [info] SSL Library Error: 336027900 error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol speaking not SSL to HTTPS port!?


These are caused by the same process because the threadmanager apparently doesn't know SSL, so it tries to speak plain HTTP on port 443 which is wrong of course.
This is the result of
LISTEN *:80
LISTEN *:443
somewhere in your apache config.

So in order to turn the latter into the former swap the order and then to get rid of the messages use

SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
SetEnvIf Remote_Addr "::1" loopback

and apped the follwing to your Customlog directive

env=!loopback

Wednesday, October 17, 2012

changing the title of listings

This question cropped up in the channel yesterday and is quite obvious in the source 
but not so in the documentation. If you want to change the name of the listing (think
localization) then you need to change three things.
 
\renewcommand\lstlistingname{Quellcode}
\renewcommand\lstlistlistingname{Codefragmente} 
\def\lstlistingautorefname{Alg.}
 
The first line is the name at every listing, the second the title for the list of 
listings and the third if you want to autoref a listing.

SemanticBundle for MediaWiki

So i inherited this wiki 1.16 with the insane number of 50 plugins. I am now just upgrading the hell out of it and one plugin that quite tripped me up was SemanticBundle. You need to leave it enabled in the LocalSettings.php but then go to Extension/SemanticBundle/SemanticBundleSettings.php (sometimes the middle part reads semantic-bundle) and disable everything after the  
enableSemantics( parse_url( $wgServer, PHP_URL_HOST ) );
line. Then go to <yourwiki>Special:SWAdmin page and click initialize (no, upgrade did not work for me - it still crashed even though it was installed before)
Afterwards just remove the comments you added earlier.

Monday, October 1, 2012

Google and Bettina Wulff

For anyone not into German politics, let me retell the story, it's not really important since there are cases like this one in many countries. The issue is simple, our former second lady was rumoured to have worked at an escort service years ago. The claim seems to be completely made up but that's what rumours are all about. Be as it may it spread around the internet and Google's autocomplete suggested it to anyone searching for her after some time. She was and is quite peeved about it and sued Google, the result of that lawsuit is yet to be determined.

Now the quintessence of the problem is, whether Google is required to censor it's results (and the suggestions are results in a way). It has done so in the past, ordered by court or law (e.g. Italy/France/Egypt or even DCMA), semivolontarily (e.g. China a few years ago or recently RS/torrents in the suggestions) or completely volontarily (e.g. the recent anti muslim video scandal).

Let's state a few facts that i have a feeling are not obvious to everyone.
  • It is technically possible, but only to a degree. I've heard before, that it is and that it isn't and both extremes are pretty much nonsense. I'm not going to discuss how searching works on the inside but you could always put a filter on the end results, there is no denying that. It wouldn't be costly either, compared to the processing, the data experiences already and the fact that it has happened in the past prove this. Still it would be completely out of the question to do try and filter everything that might be offensive. It would be close to impossible to come up with a list that fits everywhere, human intervention is too costly and last but not least, what's acceptable and what isn't is just not canonical (think different countries, cultures, religion).
  • It's not a new problem. I don't even understand why my favourite newspaper made that claim in the first place, it's just way too far out there. There are so many precedences for every aspect of the story and I'm not just talking about the internet here. For the specific case of Mrs Wulff just think of all the garbage the yellow press rumours every day. It's just a sad fact of being in the spotlight.
  • This is not about free speech. Although i can't argue with active undertakings to hide certain results being "censorship" of some kind, so is not pushing certain others. Every little tweak Google would make to their search algorithm would have similar albeit indirect effects. Also at least from a German point view, it is ok to prevent certain things to be said. The German constitution deliberately weighs off freedom of speech vs demagoguery vs slander preventing you saying things considered incitement of the people or insultations. This is difficult, since there are fine invisible lines, that are not obvious or the same to everyone but in practice it works and is reasonable.
  • This is not a completely naturally occuring phenomenon. Yes, the automatic suggestions are solely generated by the amount of users that search for a specific phrase, but (big but) a lot of them only search for those because they were suggested to try them (i wouldn't come up with half that junk, that i have searched for, just because the suggestions were so outlandish).
Is it then justified to force google to censor its results? I'd say yes, it can be, though the case at hand had to be rather severe. I don't think it was a bad idea of them to remove the anti-islam hate video despite the response in the islamic world being ridiculously over the top. I doubt even half the people rioting has even seen this load of tripe.
Is it Ok to force google to remove autosuggestions? I'd say yes, but the case at hand would have to be even clearer than for mere search results. It is definitely desirable to censor, (child) pornography from there for example. Mrs Wulff on the other hand has no right to demand this. The tabloids would have to be outlawed long before that.
The only compromise i could imagine would be to make a list of the results/suggestions not shown alongside their frequency accessible somewhere. This wouldn't solve the problem of technical feasability though.

Wednesday, September 26, 2012

xelatex, polyglossia - french and verbatim

An interesting problem with the combination of circumstances in the title has cropped up today. A minimal sample like this exhibits the problem:

\documentclass[a4paper]{article}
\usepackage{polyglossia}
\setdefaultlanguage{french}
\begin{document}
\verb|00:11:43:D4:86:A0|
\end{document}


 This code produces:
 whereas it correctly should look like this:
A bug about this has been reported, for now work around it with:
\newenvironment{\mverbatim}{\makeatletter \nofrench@punctuation\begin{verbatim}\makeatother}{\end{verbatim}\makeatletter\french@punctuation\makeatother}
The \verb is a little trickier, i'll think about that for a while. It probably boils down to copying the def from latex.ltx and adding an aftergroup or similar.
For now
\makeatletter\nofrench@punctuation
\verb|00:11:43:D4:86:A0|
\french@punctuation\makeatother

does the trick.

Wednesday, September 19, 2012

Widebar too wide

The following post shows a rather complicated solution to the problem of widebar being a little ugly that has naged for a while. Link
http://freebieber.org/ Please someone let me vote for this bill. Justin Bieber or any other cover singer on Youtube banned from the internet, what's not to like? How could one possibly oppose this. The only thing missing would be modems executing the owner if they were used to dial into aol.

Sunday, September 16, 2012

Umlaute not working in lualatex/making unicode work

This is a problem, that has confused us about a year ago. Lualatex claims to have the inputlanguage set to utf8, still i couldn't enter umlaute äüöß into the document. They were always eaten up or so it seems.
What really confused me was, that it worked as soon as i used \usepackage[utf8]{luainputenc}. It also started working without the inputenc if i set the fontenc to T1. This seemed to make no sense at all.

What usually happens is: if you enter a char into the document that char is converted to unicode (conceptually, i don't think it's literally done that way), and then replaced by the glyph corresponding to that point in the output.
This isn't quite so with  some chars, umlauts being one example. They are often constructed as an accent (the ") on top of the normal char, so both packages activate a mechanism that replaces these by composited chars, ä by \"{a} for example. This magic is all done by fontenc and inputenc loads fontenc! If fontenc isn't loaded in some way, the character is output unchanged and the font doesn't have that symbol, so it omits it!

If the font happens to sport the symbol, → comes to mind, then it may or may not look different, because it isn't made up of several parts. If you want the best of both worlds you could either
  • use the ucs package which requires knowing the code point
  • use DeclareUnicodeCharacter{<unicode>}{<replacement>} which of course requires knowing the code point as well
  • make it active and redefine it.
    \catcode`\→=13
    \let→{\rightarrow}
If you don't know the code point, just google it, or use something like http://www.utf8-chartable.de/

lsof replacement for windows

I must admit, i sorely miss lsof. This is sorely aggravated by the moronic way in which locks prevent you from working under windows. You can't delete or move folders with open file handles under them or files that are opened. This is not a problem most of the time, but when texing this can be a pain. Finding out what to close in order to be able to rename a folder can be challenging.
While i would love a
lsof <file>
under linux, this isn't an option. There are replacements like process hacker but I just found out about
openfiles /query <file>
Since this saves me from installing yet another tool, this is cool. :) You probably will have to enable the list keeping first, it's off by default. So in a root shell enter
/openfiles /local on 
and reboot (yes reboot, no kidding).

For the network aspect
lsof -i 
showing you opened connections and sockets, use
netstat /B
(maybe some other switch as well, there are plenty)

mswin.vim and ctrl-v

I started using vim under windows and the remapping of some keys, most importantly ctrl-v doing pasting instead of vertical selection had me going up the wall.

If you, like me, think the default is moronic, do
:e $MYVIMRC
and comment out the line that reads
source $VIMRUNTIME/mswin.vim

Tuesday, September 11, 2012

Always on Top

Always on Top was always something i missed under windows. There are a couple of dedicated tools for this, some of which sport a weird interface. Turns out you can get the same result with autohotkey (beginning to love this tool, even though the configuration is a little clumsy).
Anyway the snippet to make it work with ctrl-alt-t is
^!t::
WinGet, currentWindow, ID, A
WinSet, AlwaysOnTop, Toggle, ahk_id %currentWindow%

Sunday, September 9, 2012

Diagnosing BSODs

I had to investigate a series of Bluescreens and tried a lot of the usual stuff, i would do with common sense and my unixy background. In the end the best tool i found was the NirSoft Bluescreen Analyzer. It helped me understand the frequency of my problem and gave me rudimentary stack traces. So it seems my Page Fault in Non Paged Area BSOD was caused by some interaction of my AVG Virus scanner and the ntfs driver. Good riddance piece of crap.

Saturday, September 8, 2012

Why a lot of modern languages are doing it wrong.

While I am still uncertain about the role of go - half a year after release 1.0 and a bit longer since its introduction, i have not seen any major app in Go that sounded really interesting, just a load of proposals of what could be cool in Go - Rob Pike said quite a lot of true words about the old school dinosaur languages back in '10 that i just heard again.

Epic new bicycle helmet

This new design  is awsome, although i fear, it will be to expensive to really push the classical one out of the market. Poor, I'd love one of those.

En-/Disabling the Windows+L-Locking shortcut

Upon pressing Windows + L Windows will lock your session. I for one am trained to switch terminal emulator tabs with that key combination and am greatly hindered by this.
So i created
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableLockWorkstation
as a DWord (i had to create the System key as well) and set it to 1 for Disabling (0 would be for Enabling it again). Works instantly.

Changing the Windows keyboard layout *permanently*

I involuntarily spend a lot of time in windows at the moment and one of the things that drives me nuts, is the inability to use different keyboard layouts permanently, globally without uninstalling the alternatives. Having to change it for every window, and redoing it after closing one just doesn't cut it. So i now use autohotkey  as an xmodmap and xbindkeys replacement and combine it with kbswitch. In order to get us altgr-intl (the parts that interest me) and make capslock another escape i switch the language to english and use the following autohotkey script:
CapsLock::Escape
>!y::SendInput ü
>!p::SendInput ö
>!q::SendInput ä
>!s::SendInput ß
+>!y::SendInput Ü
+>!p::SendInput Ö
+>!q::SendInput Ä

This appears to satisify my most basic needs for now. Now if there was something that would make this insanity of a vfs less messy i'd be almost content.

Why something hailing itself an international, multiuser OS doesn't have that is beyond me. I would love to force the responsible people to use amharric, japanese and russian in random succession and see if they volunteer to implement it afterwards.

<edit>I forgot to mention, that you should realy turn off the global hotkeys for switching the ime, or you'll likely hit alt shift sometimes and be confused why your layout changes by itself.</edit>

Removing the searchya pest completely

My mother, despite being competent enough to reinstall her operating system, is quite prone to catch these nasty firefox toolbars. I am unsure if they are malware of some kind, though it's not unlikely given how much they resist being deactivated.

I found several hints on the internet regarding how to get rid of that crap:
  • Uninstall via Control Panel>Software
  • Deactivate the firefox addon
  • Edit the registry (don't you love administering windows?)
This still didn't get rid of the searchya completely because it had registered its useless url with the default for a new tab.
So i ended up solving it
  • Opening about:config and setting browser.newtab.url to something sensible.
Good Riddance Pest.

Sunday, September 2, 2012

Writing advice

I am not a very practiced writer and i found the following information quite helpful again http://web.science.mq.edu.au/~rdale/resources/writingnotes/

Tuesday, August 28, 2012

(Xe-|Lua-)LaTeX, Fontspec and endash, emdash

Historically we have used xelatex to typeset a larger publication. When we tried to convert to lualatex we hit a problem with emdashes and endashes showing in the document as --- and -- respectively.
The problem is not entirely clear to me. It appears to be caused by two different chars representing -  and is apparently related to the fontspecmode node, the renderer full and the fact that the loader is implemented differently in luatex and xetex. Contex had the same problem but has been fixed, luatex not apparently

If you care about the details read this discussion on stackexchange and this thread on comp.text.tex.

The problem as well as the solution unfortunately depends on the font. Try
the option  Ligatures=TeX for the font and if that doesn't work also try Renderer=basic, like
\setmainfont[Ligatures=TeX,Renderer=Basic,SmallCapsFont={* SC}]{LMU CompatilText}
or in
\defaultfontfeatures{Ligatures=TeX,Renderer=Basic}

Hopefully this works for you. It did for us.

Wednesday, August 22, 2012

chris released ignite

Chris2 got annoyed by Arch adopting Poetterings upstart as a default we had to convince him that opening a kickstarter for LP's assassination isn't a wise choice (legally and otherwise) so he just created his own answer. Stacks on!

Personally i would have preferred to see a make based init variant with targets in /proc, just out of curiousity. Maybe i'll try that out if i find the time.

Installation is a little tricky still, make sure you read and understand the part about the getty.

AutoTools History explained by its author

David MacKenzie explains how the autotools came to pass and why some of it looks like it does in the comments to this readworthy post.

Tuesday, August 14, 2012

Quotes

Viele Teile der von mir eigentlich geschätzten Süddeutschen Zeitung sind regelmässig davon bedroht der Feuilletonisierung anheim zu fallen. Das schönste Beispiel jüngster Zeit, die Wochenendbeilage darüber wie förderlich oder schädlich Computer für die kindliche Entwicklung wohl sind. Dies fördert dann Stilblüten wie diese zu Tage:
"Es gibt die Angst, dass das Kind dank des Computer ein sozialer Krüppel wird; welcher Mensch wünscht sich schon, dass sein Kind mal Programmierer wird?"
Da fehlen mir doch die Worte.

Sunday, August 12, 2012

Mutter wollte Website

Mutter bekam Website. Hat mich viel zu viel Zeit gekostet, aber ich bin sehr stolz darauf. Jetzt weiß ich auch wieder, warum ich Webseitengefrickel nicht mag. Design ist echt nicht meine Stärke. Ich wünschte LaTeX könnte auch schöne Homepages erzeugen. Glad to be done with it.

Sunday, July 8, 2012

Skype 4 for Linux and the tab switch (again)

I've been using Version 4 for several weeks. I am more than glad to finally have a tabbed interface, which i sorely missed from the mac. This makes them en par to me finally. Since i switched from cwm to notion i am even keener to avoid using the mouse, so today i got fed up and pressed all buttons till I finally found Ctrl+tab to switch the tabs.

Saturday, July 7, 2012

Multiple \label error

Package amsmath Error: Multiple \label's: label 'important' will be lost

It took me over an hour because there were a couple of valid causes to this problem and i had a few hunches that were all completely off. This error was caused by an incredible amount of tiredness on my part and the fact that I, in my stupidity, added a label to a ...
tada... align* environment. If you ever have this problem, think about if your environment actually has a tag you can reference! 

Rotating a single page in latex output

If you want to rotate a page (not just the content, i.e. you also change the geometry of that page!) the following is one possible solution: 
\documentclass{article} 
\begin{document}
  text

  \pagebreak[4]
  \global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 90}
  text\end{document}

Thursday, June 28, 2012

Getting the total number of pages into a counter

This is the only way i know of, to get the total number of pages for anything other than mere display. Took me two hours to get just right and requires two packages. There is a surprising lot of packages that do similar things but in the end all just print. Weird. Enjoy

\documentclass{article}
\newcounter{c@LastPage}
\usepackage{lipsum}
\usepackage{atveryend}
\begin{document}
a %\lipsum
%\lipsum
\makeatletter
\AfterLastShipout{\immediate\write\@auxout{\string\setcounter{\string c@LastPage} {\thepage}}}
\ifnum\value{c@LastPage}>2 foo \fi
\makeatother
\end{document}

"The save failed due to out of memory or disk space".

I had a friend come over with her new Mac because when writing a thesis Word (2007?) claimed "The save failed due to out of memory or disk space". Given that the disk had more space left over than mine ever had (>200Gb), something else had to be wrong. Different Volumes didn't do the trick, permissions were ok, the folder wasn't dangling.

Turns out she used a feature from the equation editor that was incompatible with the .doc format and would have needed to save as .docx. Way to go Microsoft - I hereby proclaim you most useless and moronic error message producer of this month.

Saturday, June 9, 2012

Wrap list around a figure

I often had a need for a way to wrap a list around a figure in the past and hadn't quite found out. Wrapfig and floatflt aren't compatible with lists and break the layout in very bad ways.

Approaches with 2 minipages or tabulars are just wrong, period. There is a new package called cutwin, that you can combine with parshape (or use it without) to coerce your text to do something similar to what ultimately wrapfig should do. I didn't get it to work properly with my ams doc, which is kind of sad. I get the feeling their way of building lists is incompatible with the rest of the latex world :/.

Then i found a solution in some mean way to use minipage. It was still wrong because the type area is so different with ams but after a bit of fiddling with my stuff this works:

\begin{enumerate} 
\item some text
% Rest of old \item
\par
% New \item starts here!
\noindent\begin{minipage}{.88\textwidth}
 \begin{wrapfigure}{r}{.3\textwidth}
   \centering
     \includegraphics[width=.29\textwidth]{pic}
  \end{wrapfigure}
\item[ad d)]
\end{minipage}
\end{enumerate}

Looks really wrong, but does the right thing. Hope this helps someone. I sure would have liked to find this.

A Proof list enumerated by Arrows

Up until recently i used

\begin{enumerate} 
  \item[``$\RightArrow$"] 
  \item[``$\LeftArrow$"] 
\end{enumerate}

or description instead of enumerate which looks even worse. Both don't exactly look right, are cumbersome to type and threw warnings about missing fonts, because latex tried to set the math in bold, so today i sat down and wrote the solution:  


\def\ProofDirection#1{\expandafter\@ProofDirection\csname c@#1\endcsname}
\def\@ProofDirection#1{\ensuremath{\ifcase#1\or\Leftarrow\or\Rightarrow \else\@ctrerr\fi}}
\def\RevProofDirection#1{\expandafter\@RevProofDirection\csname c@#1\endcsname}
\def\@RevProofDirection#1{\ifcase#1\or {$\Rightarrow$}\or {$\Leftarrow$}\else\@ctrerr\fi}

\newcounter{pcounter} 

\newenvironment{myprooflist}[1][]{% 
  
\ifx\relax#1\relax
        \let\@show@count\ProofDirection
     \else
        \let\@show@count\RevProofDirection
     \fi
  \begin{list}{\hss\llap{\textup{``\@show@count{pcounter}''}}}{\usecounter{pcounter}}
  }{
  \end{list}
}


Not only does it work and is cooler, it looks better and is less work to type. Nice!

Sunday, April 15, 2012

gentoo on the samsung 900x3a - the tricky parts

I installed gentoo about two months ago on my shiny new samsung 900x3a, most things work out of the box but some don't.

Kernel module

To make it work first build a custom kernel module created by Corentin Chary (iksaif) . As of 3.3.1 it hasn't made it to mainline yet, although it is scheduled for inclusion. Make sure you have a recent kernel emerged, symlinked, built and installed.
su - cd /usr/src/ git clone https://github.com/iksaif/samsung-laptop-dkms cd samsung-laptop-dkms make make install modprobe samsung-laptop If this works without errors then depmod -a
If you have an error 2 you likely have /usr/src/linux/ pointing to a kernel that isn't the one you are running.

Udev Rules

Enter the following into /lib/udev/keymaps/samsung-90x3a
0x96 kbdillumup # Fn+F8
0x97 kbdillumdown # Fn+F7
0xD5 wlan
This will make the scancodes known to udev.
The next step is create a rule in /lib/udev/rules.d/95-keymap.rules.
ENV{DMI_VENDOR}=="[sS][aA][mM][sS][uU][nN][gG]*", ATTR{[dmi/id]product_name}=="90X3A", RUN+="keymap $name samsung-90x3a"
This file serves to match the laptop to the keyboard, i.e. in our case it finds a samsung 90x3a and will then load the file we created earlier. This is not triggered right now, to activate them now run:
 grep -A 2 keyboard /proc/bus/input/devices  | grep Sysfs
This will tell you the device name for your keyboard, in my case event5
/lib/udev/keymap input/event5 /lib/udev/keymaps/samsung-90x3a
Now these new rules should be loaded, check that you can see them by running xev in a terminal emulator in X. If you press Fn+F8, then you should see events. If you don't see any, then it isn't working.
More to come...

Tuesday, April 10, 2012

python initializers

I just got bitten by this, so let's share. I wanted to be lazy about initializing an array of 250 by 250 values and wrot e cache = [[-1]*250]*250. This unfortunately gave the wrong results later on, because the inner arrays are just pointers to one object, thus all 250 arrays inside are the same. Try for yourself

>>> a = [[0]*2]*2
>>> a
[[0, 0], [0, 0]]
>>> a[0][1] = 1
>>> a
[[0, 1], [0, 1]]

Conclusion:
Be very careful when using these "new" lazy style initializers!

Sunday, April 1, 2012

MacOS Lion and Dashboard widgets on the desktop

A friend of mine just got a new mac and under macos lion it's apparently more difficult than before to get dashboard widget onto the desktop. To enable them disable launchpad as spaces, do

defaults write com.apple.dashboard devmode YES

and logout and login again. Then goto the dashboard (F12 usually), hold the widget and go back to the desktop (F12 again).

Tuesday, February 28, 2012

NFS Firewall worries

We have a NFS3 share on a file server mounted as homes on our clients and we sometimes (depending on use, between several times an hour and once a week) experience short freezes that we had a really hard time pinpointing.
After some long and painful debugging i think i found the solution in this notice from our cisco firewall that corresponded directly to a freeze:

Feb 28 11:18:34 192.168.98.233 fw56 %FWSM-4-209003: Fragment database limit of 200 exceeded:  src = 10.153.59.2, dest = 10.153.59.1, proto = udp, id = 57950

It turns out this is a known problem that I was unable to google: http://www.cisco.com/en/US/docs/security/pix/pix63/system/message/pixemsgs.html#wp1053420

Hope this helps someone, it took us months to find it because we had so many valid ideas for the possible cause. I now setup some work stations to use nfs4 and some to use nfs3 over tcp. Let's see what works better.

Friday, February 17, 2012

For the gentoo crowd


The Towel Paradox

Did you ever notice, that towels suck when they don't suck? And conversely that towls don't suck if they suck?

Saturday, January 28, 2012

The Naked and Famous

I am a quite compulsive listenener of music: If i find a band or song i really like i am not ashamed to turn on autorepeat and listen to it over and over till I'm sick of it and can again move on with my life.

Recently i found the insanely underrated NZ Synthie Rock band The Naked and Famous and i haven't stopped listening to them for about two weeks. When we had to pull a three day coding spree to meet a deadline this week, i figured this is the end, they won't stay on my play list after this.
To my surprise i listened to them for basically 70 hours straight and they are still keeping me up writing this blog entry just so i have an excuse to stay awake and listen to them.

The single most impressive song is probably Spank. It has a driving rhythm matching driven lyrics. From all i can gather, they are writing about being the victim of abuse, giving me the chills thinking about it. What evil genius possessed them when they wrote it? I don't dare thinking about listening to it while running, this would push me to limits i don't want to go to.

This is the beginning of a long, awesome friendship.

Friday, January 6, 2012

Saving a Windows partition with dd and getting it to work again.

Situation: I had a failing hdd recently and thus tried to create a backup. There were four partitions, mostly sparse and an already existing secondary partition on the new drive that couldn't be resized. So I didn't have enough space to backup the disk as a whole, and I didn't have enough partitions to copy them one by one and resize them all (gparted). Long story short i ended up doing a
dd if=/dev/sda2 of=/dev/sdb2
mount /dev/sdb2 /mnt
dd if=/dev/sda3 of=/mnt/sda3
dd if=/dev/sda1 of=/mnt/sda1
For two partitions, most importantly the system partition. Now i had a really hard time getting it to boot. Fix: After lots (and lots) of trial and error this is what got me to the finish line:
  • I installed a Windows Vista
  • mounted this installation in gparted (/media/sdb1), rm -rf everything except files that looked boot related, most importantly /BOOT  (WINDOWS/Boot doesn't seem to be relevant)
  • mv  /media/sdb1/BOOT /media/sdb1/BOOT.bak
  • mount -o loop /mnt/sda1 /media/sda1 and cp -r /media/sda1/* /media/sdb1/
  • rm -rf /media/sdb1/BOOT/; mv /media/sdb1/BOOT.bak /media/sdb1/BOOT 
  • reboot into the Windows Vista installation cd and used the fix boot option
  • Boot into Windows again and fix drive letters (before you start up the SQLServer!)
  • Voila
Overall i was reminded of what a pain Windows can be. If the Fix boot doesn't help try this thread.
If you have the luxury of enough space just do a dd if=/dev/sda /dev/sdb!

What doesn't work:
  • dd of the disk image to the disk (blank cursor)
  • dd of the disk image to a new partition (blank cursor on boot)
  • Creating a partition and installing into it (wrong disk offset => blank cursor)
  • Installing Vista and overwriting the partition with a dd (blank cursor)
  • Deleting the partition, installing Vista and copying everything into it (Missing winload.exe)
  • Installing Vista and copying everything safe for WINDOWS/BOOT (MIssing winload.exe)
It's save to assume I tried a couple  more combinations and that every one of them took 4h's -> annoying holiday. Fuck you Windows!