code logs -> 2010 -> Wed, 24 Mar 2010< code.20100323.log - code.20100325.log >
--- Log opened Wed Mar 24 00:00:44 2010
00:25 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
00:53 * Vornicus returns
01:03 * Orthia gives Vornicus a cheese
01:06 * Vornicus nromlifies
01:06
< Orthia>
How are ye, sir?
01:06
<@Vornicus>
I am good.
01:08
<@Vornicus>
How are ye?
01:08
<@Vornicus>
And have ye looked at decoding yet?
01:10
< Orthia>
I am doing well, but suspecting I should make a doctors appointment either this week or next
01:10
< Orthia>
The weather has turned, and I can already feel my health beginning to suffer. It's slowed me down all day, even with the inhalers.
01:11
< celticminstrel>
Spring is stalking you?
01:12
<@Vornicus>
(Reiver is in New Zealand. Autumn.)
01:12
< celticminstrel>
Oh. The mention of inhalers caused me to assume hay fever...
01:13
<@McMartin>
Leaf mold
01:13 * McMartin also ponders MinGW-hosted cross compilers.
01:13
<@McMartin>
Tempted to rebuild my GBAdev setup
01:14
< Orthia>
Also general 'change in air humidity and temperature', my lungs do not like.
01:14
< Orthia>
So yeah.
01:14
< Orthia>
Anyway, blarg, etc.
01:15
<@Vornicus>
blarg.
01:15
< celticminstrel>
How do I echo the return value of a command?
01:15
<@McMartin>
print?
01:15
< celticminstrel>
Bash.
01:16
< celticminstrel>
The exit status, I guess.
01:16
<@McMartin>
Ah
01:16
<@McMartin>
I think that's $!, but let me check
01:17
< celticminstrel>
Indeed it is.
01:17 * celticminstrel tried it.
01:17
<@McMartin>
Hm
01:17
<@McMartin>
man bash implies it's really $?
01:18
< celticminstrel>
...oh, yeah, I guess you're right.
01:18
<@Vornicus>
Pretty sure it's $?, that's more familiar from when I wrote a horrible script to do CI
01:19
<@McMartin>
$! is the PID of the most recently executed background process
01:19
<@ToxicFrog>
http://tldp.org/LDP/abs/html/refcards.html
01:24
< Orthia>
Vorn: Would we perhaps be able to poke at the decompiler for an hour and get much useful done?
01:31
<@Vornicus>
We could see how far we get.
01:32
< Orthia>
OK!
01:32
< Orthia>
er, sec. DCing router so it starts loading web pages again.
01:32
<@Vornicus>
Okay. In decoding, we take in a list of numbers, and reconstructing the original string.
01:34
<@Vornicus>
well, once you get back
01:35 Orth [orthianz@Nightstar-0562de92.xnet.co.nz] has joined #code
01:36
<@Vornicus>
In decoding, we take in a list of numbers, and reconstructing the original string -- er, sequence of bytes.
01:36 Orthia [orthianz@Nightstar-832e0407.xnet.co.nz] has quit [Ping timeout: 121 seconds]
01:37
< Orth>
Right
01:41
<@Vornicus>
So we're going to build a function called decode, and it will take an arraylist of numbers.
01:41
< Orth>
That would make sense.
01:42
<@Vornicus>
(technically, in the real world, we would make it take a thing that iterates numbers -- probably an iterator from the unpacker; we're not going to bother.)
01:42
< Orth>
(righto)
01:43
<@Vornicus>
(the reason the real world is like that is because in the real world, our llist of numbers may in fact be too big to store in memory.)
01:45
< Orth>
(Hmm. Fair enough; we shall worry whether that is the case here or not later, I think)
01:46
<@Vornicus>
(right.)
01:47
< celticminstrel>
...how on earth does calloc cause a segfault?
01:48
<@Vornicus>
Now, the other thing is, we need something to stuff this in. Our situation mirrors the one in encode - we're filling a string, not consuming one. So we want an OutputStream.
01:49 Serah [Z@26ECB6.A4B64C.298B52.D80DA0] has quit [Ping timeout: 121 seconds]
01:50
< Rhamphoryncus>
celticminstrel: corrupted heap
01:51
< Rhamphoryncus>
underruns, overruns, double frees
01:51
<@Vornicus>
But there's a problem: http://java.sun.com/javase/6/docs/api/ there's rather a few different kinds of output stream, and two of them are sensible for our specific situation.
01:51
< celticminstrel>
Oh, so the problem is probably not the calloc call itself.
01:51
< Orth>
hmm
01:52
<@Vornicus>
Because of this, our decoder should take a second argument: an OutputStream
01:52
< Rhamphoryncus>
celticminstrel: right. It's just a symptom
01:53
< Orth>
Vorn: Oh, aha. So we can set up the file writer, then tell the decoder where the file needs to go?
01:54
<@Vornicus>
What needs to go into the file.
01:55
<@Vornicus>
So that's our parameters.
01:55
< Orth>
Do we want OutputStream or BufferedOutputStream?
01:56
<@Vornicus>
an OutputStream
01:59
<@Vornicus>
This way we can use any subclass of OutputStream - such as, for instance, a FileOutputStream - as our target.
02:01
<@Vornicus>
But now, we need to set some things up.
02:02
< Orth>
OK!
02:03
<@Vornicus>
Remember how we, at the beginning of our encoder, set up our trie to have every possible single byte in there?
02:05
<@Vornicus>
We're going to have to do a similar thing here - except we won't be using a trie.
02:05
<@Vornicus>
http://pastebin.starforge.co.uk/156 <--- by the way, my decoder is also here.
02:07
< celticminstrel>
Hm. So, is it logical to assume that any call to free between the last call to malloc and the crashing call to calloc is the culprit?
02:07
<@Vornicus>
We will instead be using a list. Well, a pair of lists, for Java, because it can't do just one.
02:07
< Orth>
ArrayLists, I am presuming?
02:07
<@Vornicus>
or at least not without defining another class, which is a goddamn pain.
02:07
<@Vornicus>
Yep.
02:08
< Orth>
Hm. Is the pair of lists so we track the number and the new character seperately?
02:09
<@Vornicus>
Something like that, yes.
02:09
<@Vornicus>
(we'll also need a third list but I'll get to that in a bit.)
02:10 AgentIchiro [Smith@Nightstar-b74e42f9.dsl.teksavvy.com] has joined #code
02:11 SK [Smith@Nightstar-28e02da1.resnet.uoguelph.ca] has joined #code
02:11 * Orth ponders. Sees where you're going with that. It relys, of course, on all three lists remaining identical in size, but it's doable. Making a custom object would be pretty tempting, though. INT, Byte, ??String.
02:11
<@Vornicus>
What these will hold is, indexed by the numbers in the encoded stuff, the last byte in this index's sequence, and the /previous/ index that this one builds on.
02:12 SK [Smith@Nightstar-28e02da1.resnet.uoguelph.ca] has quit [[NS] Quit: Leaving]
02:13
< Orth>
aha
02:13 SmithKurosaki [Smith@Nightstar-b74e42f9.dsl.teksavvy.com] has quit [NickServ (GHOST command used by AgentIchiro)]
02:13 AgentIchiro is now known as SmithKurosaki
02:14 Attilla [Attilla@FBC920.DDABA2.4E6AE9.B3BF85] has quit [Connection reset by peer]
02:14
<@Vornicus>
So, we must seed them with the same kind of data we seeded the trie with: 1 to 256 must contain -128 to 127
02:15
< Orth>
hooray for loops
02:15
< Orth>
hm
02:15
< Orth>
It's not possible to call things out of an Arraylist by index number is it?
02:16
< Orth>
Like you would with a normal array?
02:16
< celticminstrel>
Um... yes it is?
02:16
< celticminstrel>
Except you need to use the member function instead of the subscript notation.
02:17
<@Vornicus>
what celmin said.
02:17
< Orth>
So then we can track the index value as position in the array, and the byte as the, y'know, data stored.
02:17
<@Vornicus>
it's "get"
02:17
< Orth>
Oh, wait. I get it, n/m
02:17
<@Vornicus>
And that's the intention.
02:17
< celticminstrel>
(Apparently the next version of Java will allow the use of subscript notation on container classes.)
02:17
<@Vornicus>
the second list tracks index -> previous index
02:17
< Orth>
Yeah. We then need the /other/ array to track the previous index.
02:18
<@Vornicus>
right.
02:18
<@Vornicus>
(in C++ I'd do this with a pair, but I couldn't find a nice way to do that in java.)
02:19 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
02:20
< Orth>
tuples!
02:21
< celticminstrel>
Does Java have tuples?
02:21
< Serah>
Sounds like vegge food made from whole flower buds.
02:21
< Orth>
I think its idea of a tuple is to handcraft a really small object.
02:21
< celticminstrel>
That doesn't count.
02:23
<@Vornicus>
Right, so we don't get that. Oh well. Anyway, we can't use get to apply indexing, and we can't use set to add stuff.
02:23
<@Vornicus>
We can, however, use add.
02:24
< Orth>
right
02:25
<@Vornicus>
So we should probably use that to build our arraylists; the predecessor to our base stuff should probably be -1, which we can guarantee won't ever be a valid index, and the 0th element in the bytes list can be, well, anything you want.
02:26
< Orth>
Wouldn't the Predecessor to our base stuff be 0?
02:27
<@Vornicus>
I say use -1 because that way if you put in a bug where the predecessor is followed even one step, it'll fail immediately on an indexerror.
02:28
< Orth>
So our base stuff, indexes 1 thru 256, are going to be indexed on 0 thru 255?
02:28
<@Vornicus>
no, -1 the number, not an offset of -1
02:29
< Orth>
oh, right
02:29
< Orth>
So index 0 should hold number -1 ?
02:30
<@Vornicus>
yes
02:32
< Orth>
Right.
02:32
< Orth>
We can't do anything equivalent with the byte array, because every single bloody value has something vaugely useful going for it.
02:34
<@Vornicus>
yeah, which is why we'll just put a random thing in it.
02:34
<@Vornicus>
can't do much about that.
02:35
<@Vornicus>
(also predecessors 1-256 should also hold -1, because of the thing outlined above.)
02:35
< Orth>
Hrm, minor complication.
02:35 * Orth pokes McMartin, who may be able to help.
02:35
< Orth>
ArrayList does not like storing bytes
02:36
< Orth>
Is there an elegant solution to this when our data is, in fact, a byte?
02:36
<@Vornicus>
Does not like storing bytes?
02:36
<@Vornicus>
What are you getting when you try to do ArrayList<Byte>?
02:36
< Orth>
ArrayList<int> gives you an error, because ArrayList does not like primitives. ArrayList<Integer> is legal.
02:38
<@Vornicus>
Try what I just offered. Byte is the box class for byte.
02:38
< Orth>
Oh, right. I had not noticed that. >_>
02:39
< Orth>
Legit now. Cheers.
02:40
<@Vornicus>
Anyway get those filled up and throw code at me.
02:50 * Orth asks the computer to upload faster, please.
02:57
< Orth>
GRAH
02:57
< Orth>
Damn thing.
02:57
< Orth>
Here. http://pastebin.starforge.co.uk/191
02:57
< Orth>
Alas, now I need to go to class. >.< Back in ~90mins.
02:58
<@Vornicus>
have fun, I'll look this over and see if there's any bugs to squish, and decide how precisely to proceed.
02:58
<@Vornicus>
Looks good.
02:58
< Orth>
thank you, Vorny :)
02:59
<@Vornicus>
Though as I mentioned - you need an outpuststream argument.
03:11
<@Vornicus>
(you can't merely return one - the decoder needs to know where you're putting the output before it can give you any.)
03:17
< celticminstrel>
Idly, is it possible to get wxWidgets to load a font from an arbitrary file?
03:50 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: *hums* Can't stay now!]
05:12
<@Vornicus>
it's been 135 minutes. :P
05:26
< Orth>
That sucked
05:27
< Orth>
Note to self: When you take the car to university because it is raining... do not forget you drove to university and walk home. >_>
05:28 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
05:34
<@Vornicus>
...
05:34
<@Vornicus>
MORON
05:35
<@Vornicus>
:P
05:37
<@Vornicus>
Anyway
05:37
<@Vornicus>
Decoding!
05:39
< Orth>
Yes!
05:39
<@Vornicus>
Corrections: 1. this code shouldn't return anything; it has nothing useful to return, because it's applying the stuff directly to an OutputStream that we pass in. 2. we should pass in an OutputStream.
05:39
< Orth>
(On the bright side, it was a nice day for a walk~)
05:39
<@Vornicus>
(thought it was raining.)
05:39
< Orth>
(It cleared up to a lovely sunny day!)
05:40
< Orth>
(Hence why when I returned, I'd forgotten I'd driven because it was pissing when I left.)
05:40
< Orth>
Done
05:41
< Orth>
Then?
05:42
<@Vornicus>
Oh, and encoded can just be a List, not necessarily an ArrayList
05:42
< Orth>
hn, okay.
05:42
< Orth>
Though my understanding is ArrayList is the superior one to use.
05:43
< Orth>
"The constant factor is low in comparison to the LinkedList implementation.", etc
05:43
<@Vornicus>
Right, but this is incoming.
05:43
<@Vornicus>
We don't care what it is.
05:44
<@Vornicus>
We choose implementation details for our internals, but we want to be as generous - and as general - as possible on the outside.
05:45
< Orth>
Oh, I gotcha. Okay.
05:45
<@Vornicus>
Once we've got that going.
05:46
< Orth>
Righto, have altered.
05:47
<@Vornicus>
Actually, you know, Iterator might even be better.
05:47
<@Vornicus>
But fuck that noise, let's get to the point
05:49
<@Vornicus>
For each item in encoded, we will 1. wander through our list of things to figure out what characters it encodes, 2. add another thing to our list of things.
05:50
< Orth>
OK
05:51
<@Vornicus>
in http://pastebin.starforge.co.uk/156, 1 is handled by lines 30-40, and 2 is handled by, uh, 41-42.
05:52
<@Vornicus>
So you know where I am.
05:54
< Orth>
OK
05:55
< Orth>
This will be nontrivial, but let's do it then
05:55
<@Vornicus>
Anyway. Obviously we go grab ourselves a code (for loop?)
05:55
<@Vornicus>
Not trivial, no, but there's a lot of relatively simple stuff going on.
05:55
< Orth>
(hm, will need to check end conditions)
05:55 * Orth pokes McMartin inquisitively. Is a for loop the best way to sequentially grab data out of a list?
05:56
<@Vornicus>
Probably better to use iterator.
05:56
<@Vornicus>
http://java.sun.com/developer/Books/javaprogramming/corejava/page2.html
05:56
<@Vornicus>
iterator has similar performance characteristics over all list types.
05:57
<@Vornicus>
It may in fact be better to pass in one of those instead. http://java.sun.com/javase/6/docs/api/java/util/Iterator.html
05:58
<@Vornicus>
Lists support an .iterator() method that returns an appropriately-shaped iterator. You may wish to use Iterator<Byte> as your argument type, but that's another matter.
06:00
<@Vornicus>
er, Iterator<Integer>
06:01
< Orth>
OK
06:01
< Orth>
Will this make life a little easier for looping?
06:02
<@Vornicus>
Yeah. Follow the template on the first link.
06:05
<@Vornicus>
Once you've got /that/ in, I think it's time for a look at your code again.
06:05
< Orth>
... hasNext
06:05
< Orth>
zomg awesome
06:05
<@Vornicus>
yeah, not bad, eh?
06:07
< Orth>
hrn
06:08
< Orth>
It is not a data type, however, but a seperate thing we feed a hunk of data?
06:08
<@Vornicus>
Right, you don't really get to fill an iterator straight.
06:09
<@Vornicus>
It's not a big deal though - we're taking this in, we don't care how it works, we're just taking one in and leaving it be. The outside world gets to decide how to give you an iterator, all you care about is that you can iterate.
06:10
< Orth>
Aaah, so, I want to be declaring the method to use 'Iterator<Integer> encoded' ?
06:10
<@Vornicus>
Right.
06:12 * Orth tries to think of what you call the bit you get out of the encoded stream.
06:12
< Orth>
phraseNum?
06:12
<@Vornicus>
What, the number that we get from next()? I'd call it index
06:14 AnnoDomini [annodomini@Nightstar-af2cc94e.adsl.tpnet.pl] has joined #code
06:14 mode/#code [+o AnnoDomini] by Reiver
06:16
< Orth>
http://pastebin.starforge.co.uk/192
06:19
<@Vornicus>
perfect.
06:20
< Orth>
Yay!
06:20
< Orth>
Then all we need to do is, hm
06:20
<@Vornicus>
All we need to do now is a lot of things.
06:20
<@AnnoDomini>
BLOOD SACRIFICE.
06:21
<@Vornicus>
Oh, we're going to need an ArrayList to temporarily store our decoded phrase; we need to reverse it before writing it to the stream.
06:24
< Orth>
... reverse it?
06:27
<@Vornicus>
Well, technically, we'll be doing the reversing as we go, by adding to the beginning of the list instead of the end.
06:30
<@Vornicus>
Which actually makes it a more appropriate LinkedList candidate, ArrayList would have to do a lot of moving.
06:32 * McMartin pops in
06:32
<@McMartin>
So, Iterator.
06:32
<@McMartin>
There's a syntax in Java 1.5 and 1.6 that lets you do a foreach.
06:32
<@Vornicus>
orly
06:32
<@McMartin>
It's an Iterator under the hood, but if you have a Collection<Foo> cf, you can go
06:32
<@McMartin>
for (Foo i : cf) { ... }
06:33
<@McMartin>
Which will also handle all the relevant typecasting.
06:33
<@McMartin>
As a rule, you want to use List<Foo> instead of type-erased List whenever possible because it gives you a lot better compile-time checking.
06:34
<@McMartin>
(It's not any more efficient; type erasure happens during compilation and there's a checked downcast)
06:35
< Orth>
Huh. That's pretty awesome.
06:35
<@Vornicus>
so we really want to pass a Collection<Integer> and then just do for (Foo index: encoded) {...}
06:35
<@Vornicus>
Yes?
06:36
< Orth>
Isn't List an implementation of Collection?
06:36
< Orth>
Thus letting us do it?
06:36
<@Vornicus>
Exactly.
06:37
< Orth>
I mean, can we thus demand a List in the type check instead of Collection and still do it?
06:38
<@Vornicus>
Don't do that.
06:38
<@Vornicus>
Be generous.
06:38
<@Vornicus>
All we're doing is iterating.
06:44
<@Vornicus>
ANYWAY
06:44
<@Vornicus>
once we're in the goddamn loop, we have a few things to do with that index.
06:45
< Orth>
Righto
06:47
<@Vornicus>
But first let's clear() the LinkedList for our decoded phrase.
06:48
<@Vornicus>
(I did working_string = []. essentially the same thing)
06:49 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has quit [Client closed the connection]
06:49
< Orth>
OK
06:50
<@Vornicus>
Then we need to check whether index exists in our arrays yet - if it doesn't we've found The Special Case and we get slightly different actions next.
06:51 SmithKurosaki [Smith@Nightstar-b74e42f9.dsl.teksavvy.com] has quit [Connection closed]
06:51
<@Vornicus>
so check index against one of our array's lengths -- if it's less than, we're fine, otherwise we have special work to do. (line 30 in mine)
06:54
< Orth>
problem: Our array skips 0
06:55
<@Vornicus>
"skips"?
06:55
<@Vornicus>
Which one?
06:55
<@Vornicus>
Oh, jeez, you did the same thing again.
06:56
<@Vornicus>
line 7, use 0 and < 256
06:56
<@Vornicus>
And neither of your arrays technically "skip" 0 - we've filled that in, just not with anything useful.
06:56
< Orth>
But we don't want to use 0 do we?
06:57
< Orth>
Or do we just allow for index-1 to be the comparator?
06:57 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has joined #code
06:57 mode/#code [+o ToxicFrog] by Reiver
06:59
<@Vornicus>
We don't... uh...
06:59
<@Vornicus>
hell, that's a good point, you could do it that way.
06:59
<@Vornicus>
Either way works - right now you're set up with junk in 0 and index for the comparator.
07:00
< Orth>
Let's run with that, then.
07:01
< Orth>
index-1 is not an entirely foreign concept for a programmer converting real numbers to array positions.
07:01
<@Vornicus>
Anyway, we do this comparison. This tells us whether working_index should be index or previous_index
07:03
< Orth>
right
07:05
<@Vornicus>
(if we're out of the array, we want it to be previous_index -- because this index will have been generated just now by the encoder.)
07:06
<@Vornicus>
(which means that it was based on.... previous_index.)
07:07
< Orth>
http://pastebin.starforge.co.uk/193
07:07
<@Vornicus>
Also if we're out of the array we want to start our list of bytes to write with the last byte we saw generating our previous pile (for similar reasons. the logic is on the wikipedia lzw page)
07:08
<@Vornicus>
Don't do that prevIndex thing
07:08
<@Vornicus>
The first one, that is, prevIndex = workingIndex
07:08
<@Vornicus>
We want to do that /very last/ so that it happens when we're done using index and we don't care what prevIndex is any more (you'll see that there's another location where it gets used, and we check it for blankness first)
07:09
< Orth>
Oh, ok.
07:10
<@Vornicus>
(and then it's prevIndex = index, anyway)
07:11
<@Vornicus>
Also in the else we need to add workingByte to workingString
07:12
<@Vornicus>
(we haven't set workingByte yet, you'll note, so you want to just give it a cheese value to please the compiler, at the top.)
07:12
<@Vornicus>
(we will never see the else unless we're deeper in anyway.)
07:13
<@Vornicus>
Oh, and right at the top of the loop we want to do if (index == 0) break; because that's the stop code so we should stop.
07:15
< Orth>
Do we use the stop code to indicate efficiency, or only that the program has ended? Because the latter could be told by, y'know, running out of encodeds.
07:16
<@Vornicus>
We need the stop code for the packer.
07:16
<@Vornicus>
and unpacker.
07:16
< Orth>
Oh. OK.
07:16
< Orth>
Carry on then.
07:16
<@Vornicus>
(the packer and unpacker may find themselves packing and unpacking into a hostile environment: partway through a file.)
07:18
< Orth>
right
07:19
<@Vornicus>
Now that we've set up our beginning conditions, we need to fill up our list with bytes, and then throw that at our OutputStream.
07:20
<@Vornicus>
36-38 in mine are my list-filler. You'll see that we grab a working_char (working_byte for you) and update working_index by using working_index on our arrays.
07:21
<@Vornicus>
Then we stop when working_index is bad (for you, == -1)
07:25
< Orth>
hmm
07:25
<@Vornicus>
and then use http://java.sun.com/javase/6/docs/api/java/util/List.html#add(int, E) with an index of 0 to add it to the beginning of your string.
07:25
<@Vornicus>
hmmm?
07:27
< Orth>
hrn, fail
07:27 * Orth tries again.
07:28
< Orth>
Our arrays are... blarg
07:28
<@Vornicus>
I can't look over your shoulder here.
07:30 * Orth wipes that attempt, throws up the current state so we can try again.
07:30
< Orth>
http://pastebin.starforge.co.uk/194
07:32
<@Vornicus>
that "pretty sure I'm doing this wrong" is indeed wrong. currentString.add(0, workingChar), and inside the else clause.
07:33
< Orth>
Inside, eh
07:33
< Orth>
OK. I had thought workingByte dealt with that as it was, but ok
07:34
< Orth>
Adding at 0 moves it to the front of the list?
07:34
<@Vornicus>
It usually /does/, but in the situation where the else is hit, we need to do a little more.
07:34
<@Vornicus>
Yes
07:34
< Orth>
Thus negating the need to reverse it later. Clever.
07:34
<@Vornicus>
Exactly.
07:34 * Orth is starting to get how Linked Lists work! It's a start... >_>
07:36
<@Vornicus>
Well, this is a List. A Linked List gives us good performance for inserting at the start.
07:41
<@Vornicus>
Anyway after our preamble we need to fill in our list. while (workingIndex != -1) {workingByte = byteArray.get(workingIndex); workingIndex = indexArray.get(workingIndex); workingString.add(0, workingByte);} I think should do it.
07:45
<@Vornicus>
Then once that is done, we have to add our thing to the output stream. http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html#write(byte[]) <--- that should give you some idea.
07:46
< Orth>
Hm, ok.
07:46
<@Vornicus>
then lines 41-43 of mine should translate directly, and you're done - don't return anything.
07:47
< Orth>
Is all that after the else, or in it?
07:51
<@Vornicus>
The while, the outputting, and 41-43 are all outside the else, just as they are in mine.
07:54
< Orth>
OK
07:54
<@Vornicus>
Oh, and http://java.sun.com/javase/6/docs/api/java/util/List.html#toArray()
07:54
<@Vornicus>
Need that too.
07:55
< Orth>
hrm, I think I have a bug in my code
07:55
<@Vornicus>
Show Me
07:58 * Orth wonders why the hell uploads are so slow from here.
07:58
< Orth>
http://pastebin.starforge.co.uk/195 - highlighted them.
08:00
< Orth>
Pretty darn certain one or the other has to be wrong. >_>
08:00
<@Vornicus>
The bug is on 75.
08:00
<@Vornicus>
workingByte, not workingIndex, and move it into the else, not in the if.
08:00
< Orth>
Right, I was wondering
08:05
<@Vornicus>
Anyway, after the while you have a few things to do: add workingString to output, then update your arrays as shown in 41-42, and then set prevIndex to index as shown in 43.
08:06
< Orth>
hm
08:07
<@Vornicus>
(I gave you both pieces of the add workingString to output bit as API refs)
08:07
< Orth>
codes.append is my equivalent byteArray.add(foo) & indexArray.add(foo) ?
08:08
<@Vornicus>
Yes.
08:14
<@Vornicus>
I need sleep badly.
08:16
<@Vornicus>
So pastey, let me see, I'll beat it with any additional sticks, and then I will go to bed.
08:16
< Orth>
OK, one second
08:19
< Orth>
http://pastebin.starforge.co.uk/196
08:20
< Orth>
The //return getvalue bit is just a placeholder; I found it easier to overwrite your code than to flip windows to see what you were doing.
08:20
<@Vornicus>
previndex = index, and outside the if.
08:20
< Orth>
OK
08:21
< Orth>
All else good? (The while loop appears to be infinite, idly)
08:21
<@Vornicus>
Why infinite?
08:22
<@Vornicus>
we're replacing workingIndex inside it, and its value is strictly decreasing, and it will get to one of the one-byte codes eventually.
08:23
<@Vornicus>
Anyway, that's all right if the compiler likes it, I'm going to bed.
08:23
<@Vornicus>
ni.
08:23
< Orth>
Hrm. How is workingIndex decreasing inside the while loop?
08:23
< Orth>
Nini!
08:23
< Orth>
Thank you!
08:23
<@Vornicus>
line 27.
08:23
< Orth>
And sorry about leaving my car at university~
08:23
<@Vornicus>
It decreases by going to the array.
08:23
< Orth>
Oh, /right/
08:23
< Orth>
OK, nevermind
08:23
< Orth>
Cheers.
08:25 * Orth chases Vorn to bed, tucks him in.
09:03
< Rhamphoryncus>
yarr, I need a math geek.. is O(n**n) considered equivalent to O(n!)?
09:04
< Namegduf>
No.
09:06
< Rhamphoryncus>
what is O(n**n) called? It seems like it'd be common to me (permutations), but I've yet to find a reference to it
09:06
< Namegduf>
For an n of just 10, n! = 3,628,800, while n**n = 10^10 or 10,000,000,000
09:08
< Rhamphoryncus>
yeah, but I know there's often tricks for simplifying complexity classes to make them equivalent
09:12
< Rhamphoryncus>
same number of terms and the same largest value in the terms
09:19
<@McMartin>
Permutations is n!
09:19
<@McMartin>
n^n is "choose a random n n times" and is "n to the n"
09:19
<@McMartin>
It happens, you'll occasionally hear it called "hyperexponential", but anything beefier than 2^n by more than a constant factor can be legitimately called taht
09:26
< Rhamphoryncus>
hrm.. so is hyperexponential above factorial or below factorial?
09:26
<@McMartin>
n^n is a larger order of growth than n!.
09:26
<@McMartin>
This is easily proven by breaking it out into terms.
09:26
<@McMartin>
10, for instance.
09:26
<@McMartin>
10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1
09:27
<@McMartin>
That's 10!.
09:27
< Rhamphoryncus>
so "hyperexponential" is ambiguous then
09:27
<@McMartin>
For 10^10, take each of those and make them 10, which is at least as big as that term.
09:27
<@McMartin>
Always bigger.
09:27
<@McMartin>
hyperexponential means just what it says. hyper-exponential: bigger than exponential.
09:29
< Rhamphoryncus>
here's a nicely ambiguous table: http://en.wikipedia.org/wiki/Exponential_time
09:30
< Rhamphoryncus>
It actually lists n**n as an example of "exponential time" or EXPTIME
09:30
< Rhamphoryncus>
also lists n! right beside it >.>
09:35
< Rhamphoryncus>
at least I was right in that they're related
09:39
<@McMartin>
Generally speaking, once you hit EXPTIME, you give up
09:39
<@McMartin>
Anything in EXPTIME is basically intractible
09:41
< Rhamphoryncus>
well yeah, I had no intention of doing a naive approach :)
09:41
< Rhamphoryncus>
I was just curious about it
09:49 You're now known as TheWatcher
10:03 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
10:27 AnnoDomini [annodomini@Nightstar-af2cc94e.adsl.tpnet.pl] has quit [Ping timeout: 121 seconds]
10:29 AnnoDomini [annodomini@Nightstar-4cb682d6.adsl.tpnet.pl] has joined #code
10:29 mode/#code [+o AnnoDomini] by Reiver
10:29 Rhamphoryncus [rhamph@Nightstar-8931f88f.abhsia.telus.net] has quit [Client exited]
10:41 Attilla [Attilla@FBC920.482E2D.82B33A.EBFF0B] has joined #code
10:41 mode/#code [+o Attilla] by Reiver
11:32 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
11:41 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
11:43 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code
11:57 Tarinaky [Tarinaky@Nightstar-e7a8474e.adsl.virginmedia.net] has quit [Ping timeout: 121 seconds]
12:11 Tarinaky [Tarinaky@Nightstar-b6e9a965.adsl.virginmedia.net] has joined #code
12:18 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: *hums* Can't stay now!]
13:47 SmithKurosaki [Smith@Nightstar-b74e42f9.dsl.teksavvy.com] has joined #code
13:49 Orthia [orthianz@Nightstar-c9e2dca9.xnet.co.nz] has joined #code
13:51 Orth [orthianz@Nightstar-0562de92.xnet.co.nz] has quit [Ping timeout: 121 seconds]
13:55 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
14:18 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Connection closed]
14:21 GeekSoldier_ [Rob@Nightstar-e86e3e0d.ip.cablemo.net] has joined #code
14:21 GeekSoldier [Rob@Nightstar-e86e3e0d.ip.cablemo.net] has quit [Client closed the connection]
14:33 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has joined #code
16:19 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has quit [Client exited]
16:24 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has joined #code
16:57 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has quit [Client exited]
17:35 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has joined #code
17:35 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has quit [Client exited]
17:37 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has joined #code
18:20 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has quit [Client exited]
18:29
< gnolam>
http://techblog.wikimedia.org/2010/03/global-outage-cooling-failure-and-dns/ <- if you're wondering why Wikipedia is all f-ed up.
18:44 * TheWatcher eyes the first comment, fallover laughing
19:49 * McMartin is directed to http://en.wikipedia.org/wiki/Krungthepmahanakornamornratanakosinmahintarayutthay amahadilokphopnopparatrajathaniburiromudomrajaniwesmahasatharnamornphimarnavatar nsathitsakkattiyavisanukamprasit
19:50
<@McMartin>
TheWatcher: That comment made CNN~
19:50 * McMartin eyes the latest binutils, which is unnervingly recent.
19:54 Rhamphoryncus [rhamph@Nightstar-8931f88f.abhsia.telus.net] has joined #code
20:00
< gnolam>
Blargh.
20:01
< gnolam>
This feels like a rather easy problem, but for some reason I'm having trouble with it.
20:01
< gnolam>
I want to remap points on a square (0,0) to (1,1) to an arbitrary trapezoid given by four points, a b c d.
20:04
< gnolam>
I.e. something like http://www.lysator.liu.se/~gnolam/temp/remap.png
20:08
< gnolam>
For some reason (it might be the fever) I just can't seem to come up with a solution.
20:13 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has joined #code
20:20
< gnolam>
Anyone
20:20
< gnolam>
?
20:20
< celticminstrel>
?
20:28
<@Vornicus>
To /four/ points?
20:28
<@Vornicus>
You can only get three via a matrix.
20:29
< celticminstrel>
Is a sha1-encrypted string always the same length?
20:35
<@Vornicus>
gnolam: got it. interpolate along ab and dc via x, and then along ad and bc via y, and the point is the intersection.
20:36
<@Vornicus>
I mean, duh, but
20:40
< gnolam>
Err
20:40
< celticminstrel>
Now to get redirection working...
20:40
< gnolam>
I... don't quite see what you mean.
20:40
< gnolam>
The point is the intersection?
20:42
< PinkFreud>
er, sha1 encryption or hash?
20:43
< celticminstrel>
Hash, I think?
20:43
< PinkFreud>
if hash, then yes. keep in mind that a hash is NOT encryption.
20:43
< celticminstrel>
And why is it that as soon as I put in a call to http_redirect, the entire script suddenly fails?
20:43
<@Vornicus>
hashes are always the same size given their algorithm.
20:43
< celticminstrel>
(Hash is what I want.)
20:43
< PinkFreud>
it's one-way, whereas encryption implies that the output can be decrypted to return the original data.
20:43
< celticminstrel>
That's the idea.
20:43
< PinkFreud>
then yes, it'll always be the same size.
20:44
< celticminstrel>
Does the parameter (to http_redirect) need to be a full URL rather than a relative URL?
20:46
< celticminstrel>
I'm at a loss here... :/
20:46
< celticminstrel>
...hm.
20:48
<@Vornicus>
gnolam: get the line between ub + (1-u)a and uc + (1-u)d, and the line between vd + (1-v)a and vc + (1-v)b, intersect those.
20:49
< celticminstrel>
That didn't help.
20:57 Orthia [orthianz@Nightstar-c9e2dca9.xnet.co.nz] has quit [Client closed the connection]
20:59
< gnolam>
Mmmkay. Will try that.
21:03
<@Vornicus>
it is in fact i think How It's Done
21:05 Orthia [orthianz@Nightstar-c9e2dca9.xnet.co.nz] has joined #code
21:20 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has quit [Client exited]
21:25 Orth [orthianz@Nightstar-29730e5d.xnet.co.nz] has joined #code
21:27
<@McMartin>
"Oh joy, you do not have c:/MinGW/bin/make.exe. Keep it that way."
21:27 Orthia [orthianz@Nightstar-c9e2dca9.xnet.co.nz] has quit [Ping timeout: 121 seconds]
21:27
<@McMartin>
MSYS's documentation is in Comic Sans
21:27 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has joined #code
21:31
< Tarinaky>
McMartin: Who's going to start the fire?
21:31
<@McMartin>
HE WANTS TO TASTE THE CURB
21:31
<@McMartin>
Well, really, it's just the readme
21:32
< Tarinaky>
I'm having fun with my lab group.
21:33
< Tarinaky>
ATM I'm tempted to tell them to rotate it clockwise and shove it. :/
21:33
< Tarinaky>
But I don't want to escalate the situation.
21:33
< Tarinaky>
Just get a resolution where the other guy just copy and pastes from a pdf into a word document and just fixes the unicode :/
21:33
< Tarinaky>
Rather than expecting me to format everyone's work.
21:34
< Tarinaky>
Quite how you mishear tex as txt I have no idea.
22:23 * Vornicus pokes at binary packing and unpacking.
22:30
<@McMartin>
Man. Watching bash run traditional bash-y build scripts in a Windows Console does very strange things to my user experience
22:35
< Orth>
Morning, Vorn!
22:36
< Orth>
Ooh, McMartin, you there? I have a silly question for you.
22:48
<@McMartin>
Yes?
22:49
< Orth>
http://pastebin.starforge.co.uk/197 - line 69
22:49
< Orth>
I gather I have done some things wrong here; I am wondering as to the best way to fix them.
22:50
<@McMartin>
OK
22:50
<@McMartin>
indexArray is a collection of Integers.
22:50
<@McMartin>
-1 is an int, which is not an Integer.
22:50
<@McMartin>
Java, being rather more primitive than C#, does not automatically "box" values.
22:51
< celticminstrel>
Um. Yes it does?
22:51
<@McMartin>
It will unbox them, sometimes.
22:51
<@McMartin>
It never boxes them to my knowledge.
22:51
<@McMartin>
It certainly doesn't in the situation he has in his code.
22:51
<@McMartin>
If you have an ArrayList<Integer> a, you can't say a.add(3).
22:52
<@McMartin>
I don't think.
22:52
<@McMartin>
Unless they've improved that, in which case, OK.
22:52
<@McMartin>
If they have, the first test is for 69 to be for (int index : encoded) to make it automatically unbox it.
22:52
<@McMartin>
You can't do "Integer i = ...; if (i == 0)".
22:53 * McMartin miscounted lines, sorry
22:53
< Orth>
hrn
22:53
< Orth>
That's kind of funky if the case. Er.
22:53
<@McMartin>
I'm actually surprised that line 65 works, because it didn't in 1.4.
22:54
< Tarinaky>
"i just dont understand y ur not using the widely used yet popular microsoft office even apple user use it..."
22:54
< Tarinaky>
Actual email I just received.
22:54 * Tarinaky hulks out on a NNNNNnnnneeeeeerddddd raaaaaage.
22:54
<@McMartin>
"Assuming you're using it, those little red squiggly lines aren't just for show."
22:54
< Orth>
McM: Odd. It seems te behave according to Eclipse, at least.
22:54
< celticminstrel>
From Java 6, I believe, it automatically boxes and unboxes
22:54
< PinkFreud>
widely used yet popular, eh?
22:54
<@Vornicus>
why I use microsoft office: it actually fucking works.
22:55
< PinkFreud>
openoffice works for me.
22:55
< Tarinaky>
LaTeX ftw.
22:55
<@McMartin>
OpenOffice has failed to, among other things, correctly print multiple copies.
22:55
<@McMartin>
LaTeX is solving a different problem.
22:55
< PinkFreud>
and I work at a uni which has a signed agreement with MS to provide office for free on uni equipment.
22:55
<@Vornicus>
OpenOffice is, in my experience, completely incapable of doing most of the things I do with office.
22:55 GeekSoldier_ is now known as GeekSoldier
22:55
<@McMartin>
Orth: What, exactly, is the error?
22:56
< Tarinaky>
McMartin: The problem being writing a lab report...
22:56
< PinkFreud>
Vornicus: I'm impressed with OO 3.2. It managed to open password-protected excel spreadsheets.
22:56
<@McMartin>
Tarinaky: In which case you're using a text editor.
22:56
<@McMartin>
LaTeX is for typesetting.
22:56 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has quit [Client exited]
22:56
< Tarinaky>
McMartin: The Lab Report includes maths.
22:56
<@McMartin>
If they let you submit text files you wouldn't need LaTeX at all.
22:57
<@McMartin>
My point stands.
22:57
<@McMartin>
You want it to look a certain way.
22:57
< Tarinaky>
McMartin: Agreed. But they expect a deadtree copy handed in.
22:57
<@McMartin>
Text files can be printed out
22:57
< Tarinaky>
Aye. But they don't score marks for presentation.
22:57
<@Vornicus>
Among other things, I can't convince it to do just a chart, I can't get it to place figures with any degree of accuracy, I can't get it to do any of these things. It's slow, buggy, crashy, and does lots of things precisely wrong.
22:58
< Tarinaky>
LaTeX also includes macros for handling citation of sources. Which is -very- handy.
22:58
< Orth>
McMartin: Written alongside it in the comment.
22:58
<@McMartin>
Well.
22:58
<@McMartin>
That's BibTeX.
22:58
< Tarinaky>
LaTeX has a system as well. I'm informed it's not as good but it does the job.
22:58
<@Vornicus>
...iterator isn't iself an iterable?
22:58 * Vornicus shoots Java
22:58
<@McMartin>
... no, it wouldn't be.
22:59
<@McMartin>
No more than an integer is an array.
22:59
<@Vornicus>
should just return self.
22:59
<@McMartin>
... I can think of no language that does this.
22:59
<@Vornicus>
Python
22:59
<@McMartin>
"2:3" is not an array.
23:00
<@Vornicus>
iterator-likes generally return self from __iter__
23:00
< Tarinaky>
Still. I don't see why I should be expected to hand my portion of the report into them in a format that can only be written using a piece of software I do not own and cannot run on my computer. :/
23:00
<@McMartin>
Tarinaky: I'm not claiming this.
23:00
< Tarinaky>
Especially since they are my peers, not my lecturer.
23:00
<@McMartin>
However, I also dispute the claim that its alternatives are in any way acceptable products~
23:00
< Tarinaky>
McMartin: A pdf document is, you know... portable.
23:00
<@McMartin>
The last time I tried to use OO.o, I tried to print 2 copies of a 3-page document, duplex.
23:00
<@McMartin>
I got three pages, total.
23:01
< Tarinaky>
And yes. soffice sucks.
23:01
<@McMartin>
Also, if you're collaborating with somebody, it's not unreasonable to all be using the same document.
23:02
<@McMartin>
Vorn: Its idea of "iterator" is clearly not the same thing as C++'s.
23:02
<@McMartin>
That's like saying that attempting to dereference a non-pointer should return the object.
23:02
<@Vornicus>
Eh, anyway
23:02
<@McMartin>
Anyway, yes. Level-of-indirection confusion.
23:03
<@Vornicus>
(on the other hand I'd expect foreach to allow iterators too in /any/ case.)
23:03
<@McMartin>
(It's not clear whether that means "the thing it's an iterator for" or "here on")
23:04
<@Vornicus>
but whatever. switch out Iterator for Iterable and that should fix it, you'll be passing things in like a, well, there's a list of classes that implement it, but ArrayList is on there.
23:05
<@Vornicus>
http://java.sun.com/javase/6/docs/api/
23:05
<@Vornicus>
fucking frames
23:05
<@Vornicus>
http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html
23:06
< Tarinaky>
McMartin: Yeah, but expecting me to use their format is about as reasonable as expecting them to use mine.
23:15
<@Vornicus>
Okay I think i see how to do pack and unpack now.
23:16
< Orth>
Fixed!
23:16 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
23:17
< Orth>
Vorn: I had a shot last night, but met little success in working out how to do this versions, uh, version, of returning the string.
23:17
< Orth>
Is it a nonsensical concept?
23:17
<@Vornicus>
The string is in the OutputStream
23:17
< Orth>
So has no need to be returned or anything, because we've already done it?
23:19
<@Vornicus>
The same way you filled the array with read(byte[]) in encode, we're filling the OutputStream (be it a ByteArrayOutputStream or a FileOutputStream) with stuff in decode.
23:19
< Orth>
aha, right
23:19
<@Vornicus>
yeah.
23:20 AnnoDomini [annodomini@Nightstar-4cb682d6.adsl.tpnet.pl] has quit [[NS] Quit: I need sleeps.]
23:20
< Orth>
I find Java mildly maddening how it passes some things, not others
23:20
< Orth>
I am starting to work it out on the basis of Underlying Nature, but still...
23:21
<@Vornicus>
So if you still need it internally - you generally shouldn't in this case, but in the Real World you do - you use a BAOS and then use toByteArray() when it's done.
23:21
<@Vornicus>
(outside the function)
23:22
< Orth>
Okay.
23:22
< Orth>
So I can remove the line 90 entirely?
23:23
<@Vornicus>
Yeah don't do that.
23:23
<@Vornicus>
We didn't open the stream, we shouldn't close it.
23:24
< Orth>
righto
23:26 * Orth pokes McM curiously. Given how incredibly common it is to do, surely there is a class that handles the parsing of optional commandline arguements?
23:36
< Tarinaky>
Can someone remind me the name of the library for standard c terminal io?
23:37
<@Vornicus>
stdio
23:37
< Tarinaky>
Cheers. Stupid assignments. :/
23:38
<@McMartin>
Orth: It's common, but nobody agrees on how to do it~
23:38
<@McMartin>
That said, there might be; I don't know of any, but 1.6 added a *shitload* of standard libraries.
23:39
< Orth>
McM: >.<
23:39
< Orth>
OK, in that case
23:39
< Orth>
What is a simple method of doing it?
23:39
<@McMartin>
Iterate through args with an index, do a switch on each element; if it's the kind with extra components, bump up the index in the middle of the loop, thus "skipping" some iterations.
23:39
< Orth>
I need to be able to accept a filename, and an arguement in the "-X 40" style that is defaulted if omitted.
23:40
<@McMartin>
Yeah, so, you have some variable arg_X, set to the default
23:40
<@McMartin>
Then something like
23:41
<@McMartin>
for (i = 0; i < args.length; i++) { if args[i].equals("-X") { i++; arg_X = my_parse_arg(args[i]); } else { arg_filenames.add(args[i]); } }
23:41
<@McMartin>
Obviously, syntax is off, and if arg_X is an integer you'll need to parse the string and handle illegal arguments appropriately (also entirely missing ones if they do -X as the last arg)
23:42
< Orth>
Lovely.
23:42
< Orth>
Thank you for that; the way Java insists on doing this sort of crap is insane >_>
23:49
<@McMartin>
Only Perl lets you treat strings, integers, and booleans as all the same, and it is a dire warning to the rest of the world
23:49
<@McMartin>
Good old "0 but true"
23:52
< Orth>
what
23:53
<@McMartin>
In Perl, the false value is false, the integer 0 is false, and the strings "" and "0" are false. If you use the string "0 but true" as an integer, it will be treated as zero, but if you test it as a boolean, it is true because it is a string that is neither empty nor "0".
23:54 * Tarinaky grumbles.
23:55
< Tarinaky>
For some reason vim is making a close brace look red and I can't see why.
23:55
< Tarinaky>
It's making me think there's an error.
23:55
< Tarinaky>
I double checked and every line that needs one has a semi-colon.
23:56
< Tarinaky>
Ahah! Missing paran.
23:56
< Tarinaky>
Stupid c io. :/ I miss streams already.
23:57
<@ToxicFrog>
C doesn't have streams; do you mean C++?
23:58
<@ToxicFrog>
Er, wait
23:58
<@ToxicFrog>
Sorry, misread what you were saying.
23:59 * ToxicFrog personally hugely prefers C IO to C++
23:59
<@McMartin>
strstream >>>>>>> snprintf
--- Log closed Thu Mar 25 00:00:37 2010
code logs -> 2010 -> Wed, 24 Mar 2010< code.20100323.log - code.20100325.log >