Category: Nerd
Posted by: sjf
Use Only Your Nose to Install an Oracle Database (How-to Video)

aka Oracle for the insane

I always ask myself when choosing a DB, can I install it while wearing a straight jacket?

Category: Nerd
Posted by: sjf
I've currently got a contract writing code that is destined for the mainframe. If anybody else is looking for a job at nice, stable financial institution I've found the perfect thing. This site has a list of interview questions and answers for JCL, CICS, COBOL and DB2; all the skills a young person needs to replace all those retiring mainframe programmers.
Category: Nerd
Posted by: sjf
A quine is a program which outputs its source code when run. They are essentially useless, but pretty cute. This is what a quine looks like in English:

"quoted and followed by itself is a quine." quoted and followed by itself is a quine.

This might be easier to read if it is written as Bob quoted and followed by itself is a quine. Letting Bob stand in for quoted and followed by itself is a quine.

Quines are named after Mr Quine, surprise, who was a logician and philosopher. He used the same sort of trick to recreate the liars paradox without using the word this. For completeness here it is:

"yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.

On to the programming, here is quine in haskell:

main = putStrLn $ (\x -> x ++ show x)"main = putStrLn $ (\\x -> x ++ show x)"
And here is one in python:
s="""print 's=""%s"";%s' %('"'+s+'"',s)""";print 's=""%s"";%s' %('"'+s+'"',s)
Worst abuse of quoting ever? Perhaps. I wrote it before I discovered repr (backticks) makes this a lot easier.

Once you get the hang of it quines are pretty easy to write. They basically need a way of quoting or escaping a string so code inside it will not be interpreted, and a way of outputting the quoted and unquoted string. For the record, locating and reading the source code from disk or something similar is usually not acceptable.

There is of course the infamous shortest quine in the world that was entered in the Obfuscated C Contest. It consisted of a completely empty file which when compiled, produces a program which outputs the source, i.e. nothing. This was deemed an abuse of the rules too hideous even for the Obfuscated C Contest, so they changed it so that the source must contain as least one byte. From the author: "While strictly speaking, smr.c is not a valid C program, it is not an invalid C program either!" Hmm, taking a look at the makefile he doesn't even call gcc on it, the empty file is just copied and made executable, so it will be interpreted as an empty shell script.

Category: Nerd
Posted by: sjf
Programmable completion is a bash feature that does context sensitive tab completion, so it will only show files which the current command can accept. For example
unzip [tab]
will only complete zipped files. It also even knows how to tab complete "-" as an argument for most common commands. In case this seems like magic, it isn't, somebody painstakingly maintains a database of the valid arguments. These are all defined in /etc/bash_completion, all 9,000 lines of filename and argument specifications.

If programmable completion isn't already enabled, you can starting using by doing

shopt -s progcomp

But the problem is that sometimes it just isn't quite smart enough. I know what I'm doing, sometimes I really do want to open that random file in mplayer. Just because something ends in .part (thanks, firefox) doesn't mean it's out of bounds. So what to do when bash thinks it knows better than me?

  1. Avoid programmable completion for the current command.

    To get default tab completion press

    M-/
    instead of
    [tab]
    This completes filenames, which is what you want 90% of the time. To complete hostnames and usernames there are other key combinations, listed here

  2. I want out altogether.

    If you want to disable it forever put

    shopt -u progcomp
    in your .bashrc

  3. I am root and never want my users to suffer this inconvience.

    If it's enabled in /etc/profile, or /etc/bash.bashrc, then comment out the lines that look like:

    if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
    If it's not enabled in either of these places, then it could have been turned on in /etc/skel/.bashrc or /etc/skel/.bash_profile. Your users got a copy of each of these files when you made them an account. There isn't any easy way to turn it off.
Category: Nerd
Posted by: sjf
Recently Amazon.ca was selling Lisp in Small Pieces for $4 Canadian. I ordered a copy, along with enough other people to put it at the top of the bestseller list, ahead of Harry Potter.

However, Amazon has cancelled the $4 orders for Lisp in Small Pieces, along with several other books which were also priced at $4. The guy from customer service I spoke to says they will be sending out mails telling people about this later today. They claim there were "pricing mistakes", (LISP is now priced at $94.40). Their pricing policy allows them to cancel any orders which haven't shipped and were incorrectly priced. So, no LISP for you!

I find the pricing mistake story suspect as I've seen how good amazon's monitoring software is at predicting orders. And something as anomalous as an obscure programming book outselling Harry Potter would have raised alarm bells long before they repriced it.

This pricing mistake also applies to a couple of other books that were selling for $4 around the same time:

Probability Theory : The Logic of Science by E. T. Jaynes, cancelled due to pricing mistake
Numerical Methods of Statistics by John F. Monahan, cancelled due to unavailability of stock.

Update Amazon has issused $10 vouchers to everyone who tried to order the $4 books. Apparently, some people who ordered a couple of months ago actually received the books.

Category: Nerd
Posted by: Andrei
I came across a post on reddit earlier today which claimed to show the breakdown of instructions on x86 asm generated by gcc. We found it rather curious that 1/4th of the instruction were adds. This sounded fishy, how often have you looked at code that had 1/4th adds, so we looked at how the disassembly was done. The person read in the binary, ran it through UDis86 and outputted the instruction counts. Looking at the documentation revealed that UDis86 takes a binary stream and decodes it, interesting. This means that it doesn't check which section it's in. The tipoff to this was a very high level of invalid instructions. If that person is just decoding the code parts of the text section, there should be no invalid instructions; unless that disassembler is so terrible it isn't worth a mention. Another reason why add may be so prominent is that '00 00' decodes to add; and the fact that add has a lot of encodings, although a lot of x86 instructions do too. In case you're interested, you can find the blog here.

But let's see, is there actually a problem with this? We went forth and disassembled /bin in a few different machines. We used objdump, restricting it to only count the code in the text section. First let's look at debian x86:


Debian x86

We can see from this that add is not the most used instruction. But how does this differ from something like Gentoo, where everything is compiled from source, with optimizations and the appropriate -mcpu options.
Gentoo x86

Interesting, almost the same for the top few instructions. How close these ratios are to each other surprised us. One last thing that we did was looking at an amd64 box, running debian.
Debian amd64

Given how close the other two graphs were, this is very dissimilar to them. With the reasons given above and the acquired data, we think we can safely say the previous blog was quite off in its counts.
We generated these just with: objdump --prefix-addresses -d /bin/*|grep "<"|cut --delimiter=" " -f 3|sort|uniq -c|sort -n followed by a bit of postprocessing.

Here's the data:
debian x86
gentoo x86
debian amd64


Note:
The shoddy graphs are generated using ploticus. It would be great if someone knew of a nicer way to generate them, the fact that some of the tags overlap is rather unpleasant.

Another note:
It was pointed out that maybe it isn't too clear what the striking differences between the x86 and the amd64 charts are. We guess that if you haven't looked at these at these while making them until you were entirely sick of them you might have some trouble readily noticing the differences.
So here's a list of major differences: a lot less moves (the extra registers surely helped here), a lot more xors, more pops than pushes on amd64, but more pushes than pops on x86 (the difference in calling convention probably accounts for this), more adds. There are others, though the above seemed to be the most interesting.
Category: Nerd
Posted by: sjf
...make an online service that sends a validation code by mail.

Not email, real mail. You know the kind with stamps, and ponies, and Kevin Costner.

ReachServices* allow you to look at your tax record and apply for refunds online. As anyone who has ever been the tax office in Cathedral St can testify, this would be pretty handy. However the catch is they have to confirm your PPS number, and they only way they seem to be able to do this is to send a validation code to your postal address. To avoid making things too inconvenient they will send you a reminder mail around the time the letter should have arrived prompting you to enter your code. The email also warns you that it will expire soon. 'Soon', when is 'soon'? What if I don't get the letter before the code expires? Will they send me another? Will they use exponential backoff or are all of us in the boglands doomed?

* Is that an aging Gary Lineker posing in their business clip art?

09/02: UnDaily WTF

Category: Nerd
Posted by: sjf
This is a highly informative comment from the amsn source:

#TODO:when we write a message to a CW, it should do the same as WLM, 
#try to open an SB, if the CAL answer is 207 
Come on people, is it so hard write 'chat window'?

There is also the most awesome error message I have ever seen. Admittedly, we can't blame this one on the amsn people as it's part of the MSN protocol.

713 {
        status_log "CALReceived: 713 USER TOO ACTIVE\n" white
        return 0
}
Bad user!
Category: Nerd
Posted by: sjf
I've got a job as a notetaker for some first year computer science classes. One of which is officially named Introduction to Computing, but known by all as assembly class. (This was my favourite class, once you get over all the tedious number systems stuff and just spend the rest of the year writing 68k assembly).

It's 10am on a Wednesday morning, an unspeakable hour of the day. I only cover one lecture out of three during the week, so there should have been two lectures since I was here last week. Last week the prof gave a class on pointers, which was all well and good. But this week, 2 lectures later, he's still talking about pointers. He's even using the same lecture slides. I feel like I should just submit the same notes I took last week. Pointers really aren't that hard. Why do lecturers need to belabour them so much?

Category: Nerd
Posted by: sjf
Lately I've been reading about mainframes as I have to write this wonderful essay about whether or not they have a future. Joy. Here are some odd terms I've come across.

Kneecapping

Let's try not to make our sysadmins sound like homicidal maniacs.

"Some mainframes have models or versions that are configured to operate slower than the potential speed of their central processors. This is widely known as kneecapping, although IBM prefers the term capacity setting, or something similar."
From the Red Book

Parallel Sysplex

We have to make this sound insanely cool.

I guess the suggestion to call it a Mainframe Cluster didn't go down too well in the board meeting. However Parallel Sysplex has all the key features of an awesome tech name: it's made of a several other tech words merged together to give something which sounds cool and expensive but is completely meaningless. I mean, what is a Sysplex? Hmm, if Googlers work in a Googleplex, does that mean we keep our sysadmins in a Sysplex? I know I'd sure like to work somewhere with a name as cool as that.

Category: Nerd
Posted by: sjf
Recently Ebay's Google ads have been trying to sell me quite strange things:

knacker

You too can have your own traveller kid or animal slaughterer. Unfortunately if you follow the link there aren't any knackers for auction at the moment. Maybe later.

I was looking for Nithin on flickr, I wasn't aware he was available on ebay.

nithin

Category: Nerd
Posted by: sjf
So I'm sure you're all wondering what I flew half way around the world to do.

Well, I'm working in Purdue University. My supervisor is a big scheme freak, so all my work will be in scheme. At the moment I'm writing benchmark programs for the Debian programming languages shootout using Stalin, which as well as being an agressive soviet dictator is also an agressively optimising scheme compiler. Allegedly it is faster than any other functional programming language implementation, so us interns are given the job of proving it. It's not expected to beat Intel cc, fortran or gcc, but should beat ocaml, mlton, haskell, etc.

When the rest of people from my group arrive I'm going to be working on some of source code repository thing, more will be explained later.
«Prev | | 1 · | Next»