--- Log opened Sat May 17 00:00:31 2008 |
00:31 | | * Chalain prods ToxicFrog (or any other Lua geeks) |
00:32 | <@ToxicFrog> | Meep? |
00:32 | <@Chalain> | I'm bashing out a quick lua script for mysql-proxy, and trying to remember all my lua from before (and failing) |
00:32 | <@Chalain> | What's the shorthand for table.append(foo, x) ? |
00:32 | <@Chalain> | Isn't there something like foo[] = x or sommat? |
00:32 | <@ToxicFrog> | table.insert, which defaults to "inserting" at the end |
00:32 | <@Chalain> | Ah, okay. |
00:32 | <@ToxicFrog> | Alternately, foo[#foo+1] = x |
00:32 | <@ToxicFrog> | Which I dislike because I think it looks less ugly, but which is faster. |
00:33 | <@ToxicFrog> | Err, looks more ugly. |
00:33 | <@Chalain> | Is there an idiomatic way to turn an int into a string? E.g. 42 => "42" ? |
00:33 | <@ToxicFrog> | tostring() |
00:33 | <@Chalain> | "" .. i ? |
00:34 | <@ToxicFrog> | There's also tonumber() |
00:34 | <@ToxicFrog> | That will work, but is icky and AFAIK never used in practice. |
00:34 | <@Chalain> | k |
00:34 | <@Chalain> | That's an old js trick. :-) |
00:35 | <@ToxicFrog> | (there's also string.format(), if you need precise control over how the number is formatted) |
00:35 | <@Chalain> | So does this make sense: |
00:35 | <@Chalain> | table.insert(proxy.response.resultset.fields, { type=proxy.MYSQL_TYPE_LONG, name=tostring(i) }) |
00:36 | <@Chalain> | p.r.rs.flds is a list of structs, each having .type and .name |
00:36 | <@Chalain> | And i is loop index, from 1 to 24. (I'm emitting an hourly stats table) |
00:36 | <@ToxicFrog> | Yep |
00:36 | <@Chalain> | Schweet. |
00:37 | <@Chalain> | I thank you kindly, sir. |
00:37 | <@Chalain> | Oh, you'll be happy to know I'm not testing all my Lua on my PDA cellphone anymore. :-) |
00:37 | <@ToxicFrog> | No problem |
00:37 | <@ToxicFrog> | Heh |
00:48 | < Vornicus> | Hm. Naming question. |
00:50 | <@ToxicFrog> | ? |
00:50 | < Vornicus> | Consider, for instance, Magic the Gathering. You've got a bunch of cards, and they all have state - they're in play, or in your hand, or whatever. But then they have, in addition to this, state and behavior unique to the kind of card they are. So an individual card keeps a reference to that. |
00:51 | < Vornicus> | I need to name two things: 1. a "kind of card", like, say, "Shivan Dragon" (as opposed to "Creature - Dragon"), and 2. a specific card, like, "the Shivan Dragon that's in my hand" |
00:52 | <@ToxicFrog> | "a Shivan Dragon", "this Shivan Dragon"? |
00:52 | < Vornicus> | I'm looking more for a general principle than specific names, though. I can see it coming up a lot. |
00:52 | < Vornicus> | Er |
00:52 | < Vornicus> | The classes, more like |
00:53 | <@ToxicFrog> | "cards in your hand" doesn't strike me as a distinct class from "cards in general" |
00:54 | < Vornicus> | If it were cars, I'd have "Toyota Corolla" and "Ford Focus" as members of one class, and "The Toyota Corolla with VIN#1234567890" as a member of another class, that references the members of the first. |
00:54 | <@ToxicFrog> | Oh, classes as in sets, not as in prototypes? |
00:55 | < Vornicus> | Yes. |
00:55 | < Vornicus> | wel, instances of one class. |
00:56 | <@ToxicFrog> | Now I'm confused again. |
00:56 | | Chalcedon [~Chalcy@Nightstar-488.ue.woosh.co.nz] has joined #code |
00:56 | | mode/#code [+o Chalcedon] by ChanServ |
01:00 | | * ToxicFrog pounces Chalcedon |
01:02 | < Vornicus> | the Toyota Corolla object is an object that describes all the properties of a generic Toyota Corolla. |
01:03 | < Vornicus> | then there is My Toyota Corolla, which is an object that describes the properties of /my specific/ Toyota Corolla. |
01:03 | < Vornicus> | And the latter references the former. |
01:04 | < Vornicus> | Now, the former is an instance of a class which also has instances called Ford Focus and Audi A3 |
01:04 | < Vornicus> | the latter is an instance of a class which also has instances called Bob's Toyota Corolla and Joe's Ford Focus and so forth. |
01:05 | < Vornicus> | it is these two classes which I need to name. |
01:06 | <@ToxicFrog> | CarModel and Car (or possibly SpecificCar or CarInstance or the like) |
01:08 | < Vornicus> | ...Model is a good one. I fear the name collision with MVC, but only slightly |
01:14 | < Vornicus> | though I guess MVC does aim generally toward not calling the model a Model |
01:14 | <@ToxicFrog> | Yes. It should be something less generic and more descriptive. |
01:17 | < Vornicus> | Right. Thank you! |
01:23 | < Doctor_Nick> | hah |
01:23 | < Doctor_Nick> | i just made a reservation for a rental car :p |
01:31 | < gnolam> | Does it come with air conditioning and Trample? |
01:34 | <@Chalain> | My SUV comes with Trample. And Rage: 2 |
01:45 | < Vornicus> | ...minor bit of Excel Awesome, vol. 4: if you've got a formula that depends on stuff all in a row, and you start filling the row after the last instance of the formula, it will copy the formula down when it's got all the information it needs. |
02:15 | < gnolam> | Chalain: yeah, but you need to tap a Middle-Eastern Country for its upkeep. |
02:15 | | * gnolam hides. |
02:18 | | Thaqui [~Thaqui@Nightstar-711.jetstream.xtra.co.nz] has joined #code |
02:18 | | mode/#code [+o Thaqui] by ChanServ |
02:21 | <@Chalain> | Cumulative Upkeep: 2 MEC |
02:22 | < Vornicus> | So, uh |
02:22 | < Vornicus> | After about four turns you can't keep it up any more? |
02:22 | <@Chalain> | Preeetty much. |
02:24 | <@Chalain> | It wouldn't be like that, but with the Iraq War Machine artifact in play, all OPEC-related upkeeps are doubled and cumulative. |
02:25 | < Vornicus> | cute |
02:25 | < Vornicus> | ...all this reminds me, I have about 10k magic cards to sort through. |
03:00 | < Doctor_Nick> | i have to sell my magic cards |
03:03 | < Vornicus> | That's why I have to sort through them |
03:10 | | gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has quit [Quit: Z?] |
04:46 | | * Reiver pokes McM. If you need me to beta-test FoTH, throw me the latest and I'll be a pedant, hokay? |
04:46 | | * Reiver has been struck by the desire to play an IF. Yours is a good one. ;) |
06:42 | | AnnoDomini [AnnoDomini@Nightstar-29390.neoplus.adsl.tpnet.pl] has joined #Code |
06:42 | | mode/#code [+o AnnoDomini] by ChanServ |
07:29 | | Vornicus is now known as Vornicus-Latens |
09:07 | | Pi [~sysop@Nightstar-6430.hsd1.wa.comcast.net] has quit [Ping Timeout] |
09:18 | | Thaqui [~Thaqui@Nightstar-711.jetstream.xtra.co.nz] has quit [Quit: This computer has gone to sleep] |
09:47 | | Chalcedon [~Chalcy@Nightstar-488.ue.woosh.co.nz] has quit [Quit: Leaving] |
10:42 | | gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has joined #Code |
10:43 | | mode/#code [+o gnolam] by ChanServ |
11:05 | | Pi-2 [~sysop@Nightstar-6430.hsd1.wa.comcast.net] has joined #code |
11:20 | | GeekSoldier [~Rob@Nightstar-8224.dip.t-dialin.net] has quit [Ping Timeout] |
12:56 | | Pi-2 [~sysop@Nightstar-6430.hsd1.wa.comcast.net] has quit [Ping Timeout] |
12:57 | | Pi-2 [~sysop@Nightstar-6430.hsd1.wa.comcast.net] has joined #code |
13:39 | <@gnolam> | http://www.xkcd.com/424/ |
14:03 | | You're now known as TheWatcher[afk] |
14:33 | | GeekSoldier [~Rob@Nightstar-7408.dip.t-dialin.net] has joined #code |
14:33 | | mode/#code [+o GeekSoldier] by ChanServ |
15:45 | | You're now known as TheWatcher |
16:52 | | Vornicus-Latens is now known as Vornicus |
16:53 | <@AnnoDomini> | http://42.pl/ipcalc/?a=83.26.2.176&m=0 <- Hehehe. |
16:54 | <@AnnoDomini> | The last line says, "hosts in the network: too many". |
17:13 | | You're now known as TheWatcher[afk] |
18:05 | | Mango [~Mango@Nightstar-27037.rd.shawcable.net] has joined #code |
18:07 | | * Mango monologues |
18:07 | < Mango> | Thinking about rebuilding my accounts receivable database |
18:07 | < Mango> | A transaction can have many items. |
18:07 | < Mango> | Each item has an account number. |
18:08 | < Mango> | The account number and the subtotal must be passed to the external accounting software. |
18:08 | < Mango> | What I'm thinking about doing |
18:08 | < Mango> | is adding the ability to have multiple payments for a single transaction. (Currently we only allow one.) |
18:09 | < Mango> | ah! |
18:09 | < Mango> | all I'd have to do |
18:09 | < Mango> | is double-entry items |
18:09 | < Mango> | with debits and credits |
18:11 | < Mango> | so the table would look like |
18:11 | < Mango> | account_id |
18:11 | < Mango> | date |
18:11 | < Mango> | amount |
18:11 | < Mango> | account |
18:11 | < Mango> | comment |
18:12 | < Mango> | method |
18:12 | < Mango> | deposit |
18:12 | < Mango> | transaction_id |
18:12 | < Mango> | item_id |
18:15 | < Mango> | now |
18:15 | < Mango> | what will I do |
18:15 | < Mango> | if a customer wants to pay for an order with two credit cards |
18:15 | < Mango> | one is approved, and one isn't? |
18:15 | | * Mango ponders this. |
18:16 | < Doctor_Nick> | no |
18:16 | < Doctor_Nick> | yes |
18:16 | < Mango> | ? :) |
18:16 | < Mango> | Probably the most flexible thing |
18:17 | < Mango> | would be to just allow for unbalanced transactions |
18:18 | < Mango> | If a transaction is unbalanced, display a warning when the customer's account is opened |
18:19 | < Mango> | this could work as an invoicing module |
18:19 | | * Mango ponders this |
18:20 | < Mango> | or |
18:21 | < Mango> | no |
18:21 | < Mango> | this is better |
18:21 | < Mango> | ask the staff for all the credit card numbers at once |
18:21 | < Mango> | that way |
18:21 | < Mango> | you can verify the total to charge to each card |
18:21 | < Mango> | then |
18:21 | < Mango> | either do a pre-auth on each card, once approved, do a completion |
18:21 | < Mango> | or |
18:22 | < Mango> | charge each card, and if one is not approved, void the previous transactions |
18:22 | < Mango> | that way |
18:22 | < Mango> | transactions are always balanced |
18:37 | | You're now known as TheWatcher |
19:01 | <@AnnoDomini> | Hm. Is there perchance a Java class specifically made as a container for IP addresses? One with methods for calculating stuff like network it belongs to, and stuff like that thereL? |
19:01 | <@AnnoDomini> | -L |
19:03 | <@AnnoDomini> | Ah, here's something. |
19:07 | <@AnnoDomini> | But it doesn't have much in the way of what I need. |
19:12 | <@jerith> | AnnoDomini: Not that I have found. |
19:12 | <@jerith> | I use strings and a couple of utility methods. |
19:14 | <@AnnoDomini> | Hrm. Given an address and mask, what operation would one perform to establish the network address? I'm sure there is some easy way, but I can't wrap my head around it ATM. |
19:14 | <@gnolam> | The Java standard libraries: everything but the kitchen sink you happen to need. |
19:16 | <@jerith> | I convert them both to numbers xor. |
19:17 | <@jerith> | Well, mask/xor. |
19:19 | <@AnnoDomini> | So you just need to xor the address with the mask, and you'll get the network address? |
19:19 | <@jerith> | Oh, AND it. |
19:19 | <@AnnoDomini> | XOR then AND? |
19:20 | <@jerith> | I was thinking of verifying that an address was in a subnet. |
19:20 | < Vornicus> | no |
19:20 | < Vornicus> | just AND |
19:20 | <@jerith> | Just AND. |
19:21 | <@AnnoDomini> | Okay, thanks. |
19:22 | <@AnnoDomini> | Hrm. Why's this bastard final? That's not what I want. |
19:27 | | * AnnoDomini decides to make his own damn container. |
19:28 | <@AnnoDomini> | Hm... Is there some easy way to use String functions to get the four parts of an address? |
19:29 | | * AnnoDomini goes try with substring and indexOf. |
19:31 | <@jerith> | AnnoDomini: I sadly don't have my code andy. |
19:31 | <@jerith> | *handy |
19:32 | <@jerith> | I think I use a split() function that somsone else wrote, though. |
19:34 | <@AnnoDomini> | Hm. There's a split() function in co-- Heh. I almost said 'core'. Damn DnD. :p |
19:34 | <@ToxicFrog> | Doesn't Java have split()? |
19:34 | <@jerith> | Maybe it was join() we wrote, then. |
19:35 | <@AnnoDomini> | "String[] split(String regex)", where regex would be the divider. It apparently returns a string array with the split items. |
19:36 | <@AnnoDomini> | Okay, next question. Arrays work in Java mostly as they do in C++, right? |
19:41 | < Doctor_Nick> | People who use Iced Tea: have you found applets that you haven't been able to run properly yet? |
19:50 | <@AnnoDomini> | How do you compute broadcast address? Visually, it seems I have to put 1 on every position where the mask is 0, and whatever the address' bit is where the mask is 1. |
19:50 | <@AnnoDomini> | ... |
19:50 | <@AnnoDomini> | Nevermind. |
19:50 | <@AnnoDomini> | I'll use a multiplexer. |
19:50 | <@ToxicFrog> | Doctor_Nick: loads. |
19:51 | <@ToxicFrog> | The only applet I can think of offhand that did work for me is the Java Version Test on sun's website. |
19:51 | <@AnnoDomini> | Or maybe not. |
19:51 | <@AnnoDomini> | These things work with integers, rather than bits. |
19:56 | <@AnnoDomini> | Hah. Google is my friend. |
19:58 | < Doctor_Nick> | ToxicFrog: really? iced tea was that poorly compatible? |
20:04 | <@ToxicFrog> | Yes. |
20:04 | <@ToxicFrog> | After trying it on several computers, I've arrived at the conclusion that on a 32-bit system, it |
20:04 | <@ToxicFrog> | 's better to use Sun java |
20:04 | <@ToxicFrog> | And on a 64-bit system, it's better to install a 32-bit browser, and use Sun java |
20:05 | < Doctor_Nick> | heh |
20:05 | < Doctor_Nick> | windows and linux? |
20:05 | <@ToxicFrog> | Never tried it on windows. |
20:05 | < Doctor_Nick> | oh |
20:05 | <@ToxicFrog> | I don't do anything on windows but gaming, what would be the point? |
20:06 | < Doctor_Nick> | well, i was wondering why this package used wine to interface with iced tea |
20:06 | <@ToxicFrog> | ...good question. |
20:06 | <@ToxicFrog> | None of the ones I've used did. |
20:07 | < Doctor_Nick> | this is an unofficial distro |
20:07 | < Doctor_Nick> | it might just be a hack to make it work |
20:07 | <@ToxicFrog> | "unofficial distro"? |
20:07 | < Doctor_Nick> | Ubuntu ultimate edition |
20:07 | <@ToxicFrog> | Aah. So it's a mod to another distro. |
20:07 | < Doctor_Nick> | im looking at what changes this guy made to hardy mainline |
20:07 | < Doctor_Nick> | yeah |
20:08 | < Doctor_Nick> | it looks like he has the icedtea plugin for firefox using the iced tea windows binary through wine |
20:08 | < Doctor_Nick> | which is ridiculous |
20:08 | <@ToxicFrog> | Does it work? |
20:08 | < Doctor_Nick> | I dunno |
20:08 | < Doctor_Nick> | I need to install this |
20:08 | <@ToxicFrog> | Because if so, that puts it ahead of the native version you get in mainline~ |
20:09 | < Doctor_Nick> | I can't wait until openjdk is done |
20:17 | <@AnnoDomini> | What's the default size of integers in Java? |
20:17 | <@AnnoDomini> | 32-bit? |
20:18 | <@gnolam> | Yep. |
20:19 | <@AnnoDomini> | I'm trying to get the number of hosts in the network. A.B.C.D is address, E.F.G.H is mask. |
20:19 | <@AnnoDomini> | (((~E)*256*256*256) + ((~F)*256*256) + ((~G)*256) + (~H))-2 |
20:19 | <@AnnoDomini> | Am I doing it right? |
20:25 | < Doctor_Nick> | oh |
20:26 | <@C_tiger> | AD, I don't think so. |
20:26 | <@Kazriko> | hmm. |
20:27 | <@Kazriko> | i think you have to count the zero bits rather than the 1 bits... |
20:27 | <@Kazriko> | ah. i see. |
20:27 | | * Kazriko hates when he forgets ~ :) |
20:27 | <@AnnoDomini> | Doing a bitwise not there. :P |
20:27 | <@AnnoDomini> | But is otherwise my thinking correct? |
20:28 | <@C_tiger> | either way, that gives way too many possible hosts if the mask is 0.0.0.0 I think. |
20:29 | <@AnnoDomini> | !roll (((255)*256*256*256) + ((255)*256*256) + ((255)*256) + (255))-2 |
20:29 | < DiceBot> | [AnnoDomini] (((255)*256*256*256) + ((255)*256*256) + ((255)*256) + (255))-2 = 4294967293. |
20:29 | <@AnnoDomini> | !roll 2^32-2 |
20:29 | < DiceBot> | [AnnoDomini] 2^32-2 = 4294967294. |
20:29 | <@C_tiger> | hmmm... maybe not. |
20:30 | <@AnnoDomini> | I'm off by 1 for some reason. |
20:30 | <@C_tiger> | Yeah, you need to add one. |
20:30 | <@AnnoDomini> | Ah, right. 0-indexed. |
20:45 | <@Kazriko> | ahh. |
20:47 | <@AnnoDomini> | Now I'm trying to convert a 32-bit integer back into a String address. |
20:53 | <@C_tiger> | I suck at bitmath |
20:54 | <@AnnoDomini> | I'm much better at the bit level, rather than the number level. |
20:58 | <@C_tiger> | in perl, I'd do: $string = $int-$int%256; $string = ($int%256).'.'.$string for (1..3); |
20:59 | <@C_tiger> | which isn't exactly the most efficient way but it works :) |
21:01 | < Doctor_Nick> | if you're using perl, you're not worried about efficiency anyway :p |
21:01 | <@C_tiger> | true. |
21:17 | | JeffL [JPL@Nightstar-12285.dsl.sndg02.pacbell.net] has joined #code |
21:45 | <@AnnoDomini> | Heh. Oops. I think I've forgotten these bastards are 32-bit, not 8-bit. |
21:47 | <@AnnoDomini> | Hrm. How do you make unsigned bytes in Java? |
21:56 | < Doctor_Nick> | unsigned char? |
21:57 | <@AnnoDomini> | Eh, I'm trying to make these things conform otherwise, via use of XOR. |
21:58 | < Doctor_Nick> | unsigned short? |
21:59 | < Doctor_Nick> | oh, thats 16 bits |
21:59 | <@AnnoDomini> | There is no unsigned keyword in Java. |
22:00 | < Doctor_Nick> | jguru.com/faq/view.jsp?EID=13647 |
22:00 | < Doctor_Nick> | this guy says you should use signed ints |
22:00 | < Doctor_Nick> | I don't know how valid that is |
22:01 | | mode/#code [+oooooo AFKSkull Attilla DiceBot Doctor_Nick JeffL Mango] by AnnoDomini |
22:01 | | mode/#code [+oo Pi-2 Vornicus] by AnnoDomini |
22:01 | <@Doctor_Nick> | ta |
22:03 | <@AnnoDomini> | Well, I'm getting around the problem by XORing with 255 rather than negating. |
22:17 | <@AnnoDomini> | Bastard, bastard, bastard. Who the hell in Sun thought that having every damned integer type to be signed, and only signed? |
22:17 | <@AnnoDomini> | *+was a good idea |
22:22 | <@AnnoDomini> | Victory. The damned things work, though Java fails utterly at giving people easy ways to work on bits. |
22:24 | <@gnolam> | Yeah. One would thing that the primitive named "byte" would be an 8 bit unsigned byte but nooo. |
22:40 | <@Doctor_Nick> | Objeeeeeeeeeeeects |
22:42 | <@C_tiger> | AnnoDomini, you can also subtract-from-255 |
22:43 | | * AnnoDomini shrugs. |
22:43 | <@AnnoDomini> | It's more intuitive for me this way. |
22:46 | | * AnnoDomini WTFs. These are *J*Labels, HTML should work! |
22:47 | <@AnnoDomini> | ... |
22:47 | | * AnnoDomini forgot. They require correct HTML. |
22:52 | <@Vornicus> | AnnoDomini: Java's version of HTML isn't "correct" |
22:55 | <@AnnoDomini> | I know, I know, but it still requires <html></html> tags to work. |
22:57 | <@Vornicus> | ah, well |
23:10 | <@Mango> | If I stored an MD5 of clients' credit card numbers on a shared server, would that be bad? |
23:11 | <@Vornicus> | MD5 is not very secure, and I would be rather surprised if somebody hadn't rainbow tabled that one yet. |
23:11 | <@Mango> | right. thanks. |
23:15 | <@JeffL> | Rainbow table? |
23:16 | <@Mango> | a lookup table |
23:55 | <@AnnoDomini> | I seem to have stumbled upon an interesting problem. |
23:55 | <@Mango> | Oh? |
23:55 | <@AnnoDomini> | Setting watches. |
23:56 | <@AnnoDomini> | There are N people. Everyone must sleep 8 hours + 1 hour per interrupt in sleep. How do they minimize time spent camping? |
23:57 | <@Vornicus> | Must have at least one watchman at all times? |
23:57 | <@AnnoDomini> | Yes. |
23:57 | <@AnnoDomini> | Else monsters eat them. |
23:57 | <@Vornicus> | Okay. |
--- Log closed Sun May 18 00:00:38 2008 |