code logs -> 2010 -> Sun, 28 Feb 2010< code.20100227.log - code.20100301.log >
--- Log opened Sun Feb 28 00:00:07 2010
00:01 You're now known as TheWatcher[T-2]
00:04 You're now known as TheWatcher[zZzZ]
00:20 AbuDhabi [annodomini@Nightstar-a5f94122.adsl.tpnet.pl] has quit [[NS] Quit: Out of the night and into the fight, it's Bixby!]
00:31 * Vornicus uses regex mostly to tokenize.
00:36 Rhamphoryncus [rhamph@Nightstar-8931f88f.abhsia.telus.net] has joined #code
01:05 * McMartin sets his spiders to re-index the ocremix site.
01:10
< celticminstrel>
Bobsentme: String[] NameOfArray = new String[] {"This", "Initializes", "The", "Array"};
01:10
< celticminstrel>
(If I recall correctly, that is; I've been using C++ more recently.)
01:11
< celticminstrel>
...though, I just noticed there's a gap in my log in which someone might have told you this.
01:19
<@McMartin>
At some point I should probably rewrite my OCR dataminer to not be written using only Mac system calls.
01:34
< celticminstrel>
Wait, what?
01:41 Orthia [orthianz@Nightstar-6607c026.xnet.co.nz] has quit [Ping timeout: 121 seconds]
01:41 Orthia [orthianz@Nightstar-6607c026.xnet.co.nz] has joined #code
01:41
<@McMartin>
OCR here is Over-Clocked Remix, a video game music site
01:42
<@McMartin>
I have a program that lets me keep an offline index of which songs are where, &c
01:42
<@McMartin>
It's written using the Foundation library, which is basically high level system calls on OS X. Not hugely portable.
01:42 * McMartin is now shifting the guts of it over to python.
01:43
< celticminstrel>
I think I was unaware that you use a Mac.
01:43 * McMartin uses everything.
01:43
< celticminstrel>
Hehe.
01:43
<@McMartin>
More seriously, basically every open-source project I'm on is tri-platform so I need to have access to all three to get anything reliably tested.
01:44
< celticminstrel>
I wish someone in the BoE project had that ability...
01:45
<@McMartin>
BoE?
01:45
<@McMartin>
Also, woo, that was easier than I expected. Thanks, Python!
01:45
< celticminstrel>
Blades of Exile.
01:45
<@McMartin>
Generally speaking it's actually pretty tough to write something decently game-ish that runs on Linux but not on OS X
01:45
<@McMartin>
Since both use POSIX and OpenGL as their core technologies
01:46
< celticminstrel>
Well, this game is currently written with Carbon and Win32 libraries.
01:47
<@McMartin>
Ah
01:47
<@McMartin>
In that case, it depends on degree, yeah
01:47
< celticminstrel>
And in the (relatively) brief period on activity last year (and possibly also other earlier periods), the two sources diverged somewhat.
01:47
< celticminstrel>
Which is bad.
01:47
<@McMartin>
Yeah
01:48
<@McMartin>
But if you aren't going cross-platform from the start (with, say, Qt, or SDL, or whatnot) you're asking for it from the start
01:48
< celticminstrel>
Well, it was originally a closed-source game written first for Mac, then ported to Windows.
01:50
< celticminstrel>
Since it's a game that lets users create scenarios, and it had become unable to run on newer computers, the author released it so as not to let others' work go to waste. Or something like that.
02:02 Tarinaky [Tarinaky@Nightstar-67136ba7.adsl.virginmedia.net] has joined #code
02:10 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
02:19
< celticminstrel>
Don't multidimensional arrays sometimes have padding between the "rows"?
02:20
< celticminstrel>
...wait, never mind. I'm not even using multidimensional arrays.
02:23
<@McMartin>
Ah. Legacy code. Yes.
02:23
<@McMartin>
That's why UQM took several years to produce anything that could be sensibly distributed. >_<
02:24
< celticminstrel>
Actually, not legacy code.
02:24
<@McMartin>
Oh, they didn't give the project the original code?
02:27
< celticminstrel>
I'm not working on that project at the moment.
02:27
< celticminstrel>
Actually, I'm currently considering scrapping this and going with my original idea.
02:29
< celticminstrel>
The BoE project was given the original code, as far as I know. Possibly even slightly older than that which actually got released in a few cases.
02:30
< celticminstrel>
I tend to have several projects going at once, in various stages of activity.
02:30
< celticminstrel>
^um, levels, not stages.
02:32
< celticminstrel>
Where would I put temporary files?
02:32
< celticminstrel>
In a portable manner?
02:58 Attilla [Attilla@FBC920.65CFFF.ADEEA3.DBDA33] has quit [[NS] Quit: ]
03:07
< celticminstrel>
ifstream and ofstream needn't be explicitly closed, right?
03:09
< Vornicus>
They'll hang around if you don't.
03:09
< celticminstrel>
Even after the function exits?
03:09
< celticminstrel>
I thought the destructor closes the file.
03:09
< celticminstrel>
But I wasn't sure.
03:09
<@McMartin>
I'm not sure if the destructor closes it, but I think it does; what you aren't guaranteed the destructor will be called if you've let the thing escape
03:10
< celticminstrel>
If I've let what happen?
03:11
< Vornicus>
If you've deleted the last reference to the object but you didn't call delete on it
03:11
<@McMartin>
Well, that's letting it leak, which is different and worse
03:11
< celticminstrel>
It's an automatic variable.
03:14
< celticminstrel>
So, McMartin, what do you mean by "escape"?
03:14
<@McMartin>
Escaping is when you aren't *intending* to delete it on function return
03:14
<@McMartin>
Because you're a factory method, or it's part of a constructor, &c
03:15
< celticminstrel>
Ah, okay. Well, the particular function in question at the moment is a simple wrapper around a function that takes a stream argument.
03:15
< celticminstrel>
So, it doesn't return the stream.
03:15
< Vornicus>
If it /takes/ the stream, then it won't destruct the stream when it's done
03:16
< celticminstrel>
But the calling function will.
03:27 Tarinaky [Tarinaky@Nightstar-67136ba7.adsl.virginmedia.net] has quit [Connection closed]
03:35
< celticminstrel>
What does the implementation of an <stdexcept> class actually do? Just store away a pointer and return it when what() is called?
03:36
< celticminstrel>
...sorry, a reference, not a pointer.
04:42 Orthia [orthianz@Nightstar-6607c026.xnet.co.nz] has quit [[NS] Quit: ]
04:43 Orthia [orthianz@Nightstar-d47b0b72.xnet.co.nz] has joined #code
04:56
< celticminstrel>
Arg. I need to make sure that every element is unique... without sorting.
05:00 Orthia [orthianz@Nightstar-d47b0b72.xnet.co.nz] has quit [[NS] Quit: ]
05:01 Orthia [orthianz@Nightstar-86fa52fb.xnet.co.nz] has joined #code
05:07
< celticminstrel>
I seem to have a solution. It's sort of elegant, but doubtless horribly inefficient.
05:08
< celticminstrel>
Since it's four nested loops. (Though the inner two only do anything if a duplicate is actually found.)
05:10
< ToxicFrog>
Iterate over elements, check each one for membership in a set, if not already in the set add it?
05:10
< Kazriko>
Hashtable?
05:11
< celticminstrel>
I'm basically iterating over the vector, and checking to see if each element appears earlier in the vector.
05:12
< celticminstrel>
If one does, I tweak it and start over.
05:14
< Kazriko>
Use a hashtable or set instead of iterating over the list again to find duplicates...
05:14
< Kazriko>
or at least that's what I'd use...
05:14
< celticminstrel>
Well, I need to preserve the set size and order...
05:14
< Kazriko>
well, you leave the vector alone...
05:14
< Kazriko>
you create a secondary hashtable/set to use for duplicate checking.
05:14
< celticminstrel>
Hm.
05:15
< Kazriko>
check current item, if not exists, insert, move to next item and repeat, like ToxicFrog said.
05:15
< celticminstrel>
Ah. I think I get it.
05:15 * celticminstrel wanders off to check the std::set documentation.
05:15
< Kazriko>
Would it improve the thing if you found all duplicates at once, would you be able to adjust it once?
05:16
< celticminstrel>
Um... not sure.
05:17
< celticminstrel>
Does std::set need operator< to enforce a total order, or would a partial order work?
05:17
< celticminstrel>
^ enforce probably isn't the right word, but I'm not sure what is.
05:19 Tarinaky [Tarinaky@Nightstar-67136ba7.adsl.virginmedia.net] has joined #code
05:21
< ToxicFrog>
Sets are unordered.
05:21
< celticminstrel>
...so?
05:21
< celticminstrel>
OH.
05:21
< celticminstrel>
D'oh.
05:21
< ToxicFrog>
So the concept of "enforcing order on a set" is meaningless.
05:21
<@McMartin>
TF: In C++, sets are in fact ordered.
05:21
< celticminstrel>
So I don't need operator< ?
05:22
< celticminstrel>
...fine then.
05:22
< ToxicFrog>
The utility here is that any sensible set implementation will give you O(1) add, remove, and check.
05:22
<@McMartin>
Because they are tree maps.
05:22
< Tarinaky>
Aren't they maps in...
05:22
< Tarinaky>
Yeah.
05:22
<@McMartin>
C++ STL is not "sensible".
05:22
< ToxicFrog>
McMartin: that's an implementation detail, though.
05:22
< celticminstrel>
So, do I need operator< or not?
05:22
<@McMartin>
It gives you O(log n) on all of these because god forbid you require a hash function.
05:22
< ToxicFrog>
;.;
05:22
<@McMartin>
Yes, and I believe it also needs to be a total ordering.
05:22
< ToxicFrog>
Why did they even bother calling it a set at that point
05:22
< celticminstrel>
I guess lexicographical would do then.
05:23
<@McMartin>
celticminstrel: Yes
05:23
<@McMartin>
TF: Because "set" means "no duplicates"
05:23
<@McMartin>
It does not mean "constant time access", which in fact I can think of no implementation which actually grants it
05:23
<@McMartin>
Even Union-Find, the fastest I know, is still faster than constant.
05:23
< celticminstrel>
Slower. :P
05:23
<@McMartin>
Er, yes
05:23
<@McMartin>
Slower.
05:23
<@McMartin>
But faster than any single-argument function.
05:24
<@McMartin>
Computing hash functions tends to be O(n) if you're using a real datatype for a key, anyway.
05:25
<@McMartin>
(While we're on the subject, Java has both Hash- and Tree-Sets, and Haskell sets are all both ordered and logarithmic-time access and update.)
05:25
< ToxicFrog>
McMartin: ok, to rephrase: a set based on a hash table will be O(hash function), and depending on your data types you can often get O(1) hashing.
05:25
<@McMartin>
OK.
05:25
< ToxicFrog>
And both of these assumptions are true for the sets I usually work with.
05:25
<@McMartin>
In my experience, hash sets are the exception, not the rule. Only Perl and Python use them by default.
05:26
< ToxicFrog>
(barring some pathological string-related edge cases)
05:26
< ToxicFrog>
Most of my set use is in python or lua (which also uses hashsets).
05:26
< ToxicFrog>
So.
05:26
<@McMartin>
Small sample sizes.
05:26
< ToxicFrog>
Yes.
05:26
<@McMartin>
(Java, like C, I am treating as "has no default")
05:26
<@McMartin>
It's considered bad form in Java to actually expose more than the "Set" interface type
05:27
<@McMartin>
IME, anyway
05:27
<@McMartin>
Once C++'s TR1 becomes actually implemented, there will be an unordered_set class that will require hash functions.
05:27
< ToxicFrog>
I think the amount of time it's been since I worked in a non-HLL may be showing.
05:28
<@McMartin>
My reference, celticminstrel, says "Elements follow a strict weak ordering at all times."
05:29
<@McMartin>
So you don't need a total ordering, but not all partial orders will work.
05:29
< celticminstrel>
Ah. Well, I'll just go with lexicographical order then, to be safe.
05:31
<@McMartin>
I'm baffled how you could get a sensible strict weak order on a data type that was not also a total order, though; the difference seems to be that you can have sets of elements be incomparable within the set.
05:31
<@McMartin>
Incomparable objects sounds Really bad.
05:31
< ToxicFrog>
"strict weak"?
05:31
< celticminstrel>
It's not that bad...
05:32
< Vornicus>
Strict ordering: comparisons are transitive.
05:32
<@McMartin>
Weak ordering: some elements are incomparable.
05:32
< Vornicus>
Bzzzzt
05:32
< celticminstrel>
...how is this different from a partial order?
05:32
<@McMartin>
What am I missing, then?
05:32
< Vornicus>
In a strong ordering, all elements are not only comparable, but compare differently unless they are the same object.
05:33
< Vornicus>
In a /weak/ ordering, non-identical objects can compare equally.
05:33
< celticminstrel>
Ah.
05:33
<@McMartin>
Strict weak means that if neither a < b nor b < a, and neither a < c nor c < a, then neither b < c nor c < b.
05:33
<@McMartin>
If I read this right.
05:34
<@McMartin>
OK. In CS terms, that means that you can chop bits out of the comparison.
05:34
< Vornicus>
Right.
05:34
<@McMartin>
If you have a key-value pair, you can have operator< apply solely to the key and set will still work.
05:34
<@McMartin>
Sort of.
05:35
<@McMartin>
(If you are actually doing pairs like this, you want a map, not a set)
05:35
< Vornicus>
In any total ordering - and total is assumed here - two things are either < or > or =
05:36
< celticminstrel>
Well, I think this'll work. Thanks.
05:36
< celticminstrel>
And good night.
05:36
< Vornicus>
In a strict ordering, a<b implies b>a, and a=b implies b=a.
05:37
< Vornicus>
In a strong ordering, a=b implies a is b.
05:37
<@McMartin>
Failing to have a=b -> b=a is offensive to the concept of =
05:37
< Vornicus>
Well yes, but it's also not hard to do.
05:37
< Vornicus>
Consider float comparison with a tolerance.
05:38
<@McMartin>
Violating equivalence class axioms means people get to beat you with sticks
05:38
< Vornicus>
erp, sorry, that's another thing
05:38
<@McMartin>
Much like making addition non-commutative
05:38
< Vornicus>
strict ordering also includes transitivity
05:38
< Vornicus>
a = b and b = c implies a = c; this is so easy to break it's not funny.
05:39
< celticminstrel>
Several things have non-commutative addition.
05:39
< celticminstrel>
Ordinal numbers, for example.
05:39
< Tarinaky>
Ordinal?
05:39
< celticminstrel>
...yes.
05:40 * Vornicus is a mathematician and does not understand ordinals.
05:40
<@McMartin>
celticminstrel: Well, it's really more that non-abelian groups are supposed to use *, not +.
05:40
< celticminstrel>
Non-abelian?
05:41
<@McMartin>
The three rules of = boil down to "must be able to partition stuff into equivalence classes with it": a=a, a=b <-> b=a, a=b & b=c <-> a=c
05:42
<@McMartin>
A group is a set with a closed operation * on it such that * is associative, so a*(b*c) = (a*b)*c, there's some identity value e such that x*e = e*x = x for all x in the set, and every element x has some value x' such that x*x' = x'*x = e.
05:42
<@McMartin>
This is enough to get you a large chunk of algebra.
05:42 Vornicus is now known as Vornicus-Latens
05:42
<@McMartin>
If * is commutative too, it's an Abelian group, which makes it work like addition.
05:43
<@McMartin>
If you have a + and a * such that it's an abelian group for + and the distributive laws work, it's a ring.
05:44
<@McMartin>
If * is also a group if you remove the identity for + from the set, it's a "division ring" or a field.
05:44
<@McMartin>
You can use these to sort out various exotic forms of arithemetic, or to directly model operations on some programming structures as mathematical operations in one of these exotic domains.
05:45
< celticminstrel>
I've heard/read some of these things, but not committed them to memory.
05:46
<@McMartin>
The only directly applicable takeaway, usually, is that the integers modulo a prime number results in a field.
05:47
< celticminstrel>
Hm. Is there an iostream equivalent of tmpfile()? I'm guessing not...
05:52
< celticminstrel>
...oh right. A stringstream should work.
05:56 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
05:58 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: *hums* Can't stay now!]
08:12 AnnoDomini [annodomini@Nightstar-a5f94122.adsl.tpnet.pl] has joined #code
08:12 mode/#code [+o AnnoDomini] by Reiver
08:54 Tarinaky [Tarinaky@Nightstar-67136ba7.adsl.virginmedia.net] has quit [Client closed the connection]
09:33 You're now known as TheWatcher
09:57 Bob_Work [NSwebIRC@051596.69129A.C96753.910884] has joined #code
09:57
< Bob_Work>
Ok, for all intents and purposes, a "java bean" is just a small piece of code stored somewhere other than the main .jsp file, no?
09:57
<@McMartin>
Depends on context.
09:58
<@McMartin>
A Java bean is a class whose field accessors are named according to a convention some tools expect.
09:58
< Bob_Work>
ah
09:59
<@McMartin>
Such a class would indeed not be a JSP, and I don't recall enough about the Servlet Framework to know if it requires beans for its out-of-JSP classes.
09:59
< Bob_Work>
I'm researching nested ResultSets and keep coming across two approaches to them: 1) WTF ARE YOU DOING!?! Write a Bean! and 2) Piece of cake (followed by 3 pages of code)
10:00
<@McMartin>
Mrrrr. Not my specialty, I fear
10:00
< Bob_Work>
No worries. You've gotten me a step further, as at least now I understand what they mean by beans.
10:03
< Bob_Work>
On related note: Going from PHP to JSP stinks. PHP is quick and easy. JSP is a labrynth of ugly and headaches.
10:03
<@McMartin>
PHP is the Dark Side.
10:03
<@McMartin>
Quicker, Easier, More Seductive,
10:03
<@McMartin>
but it devours your soul and all you hold dear
10:06
< Bob_Work>
But...but...it said it loved me!
10:15
< TheWatcher>
Bob: you think jsp is bad, you should look at the source for servlet containers like tomcat.
10:16
< TheWatcher>
Not sure quite what those guys are on, but it sure as hell isn't planet earth.
10:21 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
10:52
< Bob_Work>
heh
10:53
< Bob_Work>
Hrm. JSP Arrays / array lists aren't meant to be dynamic. One site says the best way to send results to an "array" is to use Vectors instead.
10:53
< Bob_Work>
Just gotta cast them first, or cast them back.
10:56
< Bob_Work>
anyways, time to go home and work on it. Later.
10:56 Bob_Work [NSwebIRC@051596.69129A.C96753.910884] has quit [[NS] Quit: Page closed]
12:07 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Connection closed]
12:34 Rhamphoryncus [rhamph@Nightstar-8931f88f.abhsia.telus.net] has quit [Client exited]
13:59 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code
14:02 GeekSoldier [Rob@Nightstar-e86e3e0d.ip.cablemo.net] has joined #code
14:53 Attilla [Attilla@FBC920.65CFFF.ADEEA3.DBDA33] has joined #code
14:53 mode/#code [+o Attilla] by Reiver
15:07 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
15:08 Orth [orthianz@Nightstar-6514bbe2.xnet.co.nz] has joined #code
15:10 Orthia [orthianz@Nightstar-86fa52fb.xnet.co.nz] has quit [Ping timeout: 121 seconds]
16:07 Vornicus-Latens is now known as Vornicus
16:20
< celticminstrel>
Agh! Why does Google fail me!?
16:25
< Vornicus>
Perhaps it is you that fails google.
16:25
< Vornicus>
What do you seek?
16:35 AbuDhabi [annodomini@Nightstar-49169604.adsl.tpnet.pl] has joined #code
16:38 AnnoDomini [annodomini@Nightstar-a5f94122.adsl.tpnet.pl] has quit [Ping timeout: 121 seconds]
17:05 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
18:09
< celticminstrel>
Code example to calculate a hash from a string. Everything I found used a built-in hash function.
18:26 Serah [Z@26ECB6.A4B64C.298B52.D80DA0] has joined #code
18:28
< Vornicus>
http://svn.python.org/view/python/trunk/Objects/stringobject.c?view=markup <--- look for string_hash; that's Python's implementation
18:33 Tarinaky [Tarinaky@Nightstar-67136ba7.adsl.virginmedia.net] has joined #code
18:54 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: *hums* Can't stay now!]
19:03 Tarinaky [Tarinaky@Nightstar-67136ba7.adsl.virginmedia.net] has quit [Connection closed]
19:11 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has joined #code
23:19 Rhamphoryncus [rhamph@Nightstar-8931f88f.abhsia.telus.net] has joined #code
23:28 Tarinaky [Tarinaky@Nightstar-67136ba7.adsl.virginmedia.net] has joined #code
23:33 Serah [Z@26ECB6.A4B64C.298B52.D80DA0] has quit [Ping timeout: 121 seconds]
23:42 celticminstrel [celticminstre@1AB00B.855209.A256BB.B16D09] has quit [Client exited]
--- Log closed Mon Mar 01 00:00:08 2010
code logs -> 2010 -> Sun, 28 Feb 2010< code.20100227.log - code.20100301.log >