code logs -> 2008 -> Mon, 24 Mar 2008< code.20080323.log - code.20080325.log >
--- Log opened Mon Mar 24 00:00:38 2008
00:03 Chalcedon [~Chalcedon@203.211.121.ns-21733] has quit [Connection reset by peer]
00:05
<@AnnoDomini>
Yay. I've made a program that beeps annoyingly.
00:06
<@AnnoDomini>
I think I will be hearing more than I'd care to of annoying beeps in a week and two day's time.
00:24 * ToxicFrog ponders how to properly handle signal connections
00:28 You're now known as TheWatcher[afk]
00:30
<@ToxicFrog>
I connect a widget with widget "Name in Glade file" { list of connected signal names }
00:30
<@ToxicFrog>
The return value of this is a GtkWidget handle I can use to talk directly to the widget if necessary.
00:31
<@ToxicFrog>
Internally, it extracts the widget ID from the GladeXML handle and foreach signal, connects it to the signal id "<widget>/<signal name>"
00:31
<@ToxicFrog>
The event loop then works as:
00:32
<@ToxicFrog>
- read signal id from gtk
00:32
<@ToxicFrog>
- split it into widget id and signal name
00:32
<@ToxicFrog>
- call widgets[id][signal]
00:33
<@ToxicFrog>
From this, setting up signal handlers looks something like:
00:33
<@AnnoDomini>
http://pastie.caboo.se/169526 <- Imagine 10 of similar noisy programs going on simultaneously in a small classroom.
00:34
<@ToxicFrog>
end_turn = widget "End Turn Button" { "clicked" };
00:34
<@ToxicFrog>
function widgets[end_turn].clicked() ...code goes here... end
00:35
<@ToxicFrog>
...for that matter, I can jigger the metatable so that I don't even need to use the widget ID
00:35
<@ToxicFrog>
I can ask for widgets["End Turn Button"] and it'll do the glade queries automatically.
00:35
<@ToxicFrog>
Or even widgets.EndTurnButton if I use a constently (de)mungable naming scheme.
00:38
<@ToxicFrog>
Sanity check and/or suggestions?
00:43 * AnnoDomini finishes that particular assembly task. Time for some non-annoying sounds.
00:51 Vornicus [~vorn@Admin.Nightstar.Net] has quit [Ping Timeout]
00:51 Vornotron [~vorn@Admin.Nightstar.Net] has joined #code
00:53 Vornotron is now known as Vornicus
00:54 Vornicus is now known as Finerty
01:20
<@AnnoDomini>
Hm. The next laboratory is apparently... printer control. o_O
01:20
<@AnnoDomini>
I wonder how that'll be handled. Do we all get printers?
01:20
<@AnnoDomini>
I somehow doubt it.
01:21
<@AnnoDomini>
But the code itself looks to be easy to do, since there was no explanation or example given.
01:58 AnnoDomini [AnnoDomini@83.21.9.ns-26932] has quit [Quit: Don't trust the skull.]
02:04 Attilla [~The.Attil@194.72.70.ns-11849] has quit [Quit: <Insert Humorous and/or serious exit message here>]
02:10 Attilla [~The.Attil@194.72.70.ns-11849] has joined #code
02:10 mode/#code [+o Attilla] by ChanServ
04:26 Finerty is now known as Vornicus
07:20 GeekSoldier|bed is now known as GeekSoldier
09:06 AnnoDomini [AnnoDomini@83.21.9.ns-26932] has joined #Code
09:06 mode/#code [+o AnnoDomini] by ChanServ
10:06 Vornicus [~vorn@ServicesOp.Nightstar.Net] has quit [Ping Timeout]
11:22 GeekSoldier [~Rob@91.18.80.ns-27083] has quit [Ping Timeout]
12:20 AnnoDomini [AnnoDomini@83.21.9.ns-26932] has quit [Ping Timeout]
12:27 AnnoDomini [AnnoDomini@83.21.58.ns-4219] has joined #Code
12:27 mode/#code [+o AnnoDomini] by ChanServ
12:59
<@AnnoDomini>
A question - how does one sanitize ones database inputs? As it is, it seems to me that a clever user could use my program to delete everything, via the method used in an XKCD strip.
12:59
<@AnnoDomini>
*one's
13:00
<@EvilDarkLord>
Many frameworks provide an existing function for this. What's yours?
13:01
<@EvilDarkLord>
If not, then I think it is sufficient for most cases to do a search-and-replace on " -> \" and ' -> \'.
13:02
<@EvilDarkLord>
Say you have a select, SELECT * FROM t1 where username='$blah', where $blah is a variable.
13:03
<@AnnoDomini>
Framework?
13:04
<@EvilDarkLord>
If someone makes $blah equal to "' -- DROP TABLE t1;" then Bad Things Happen if it doesn't get sanitized first.
13:04
<@AnnoDomini>
I'm doing this in Java using JDBC to connect to a Sybase Adaptive Server Anywhere 8 database.
13:04
<@EvilDarkLord>
I don't know what kind of tools Java offers, googling might be prudent. But you can write your own pretty simply.
13:06
<@AnnoDomini>
I seep.
13:07
<@AnnoDomini>
Heh. The field contents are growing to be ridiculous. "wrapInQuotes(getID((String)cbID_kategorii1.getSelectedItem()))"
14:00 Serah [~Z@87.72.35.ns-26506] has quit [Quit: Don't try to read the quit message, that is impossible. Instead only realize the truth; "there is no quit message" and you will see it is not you who read the quit message but the quit message who reads you.]
14:31 GeekSoldier [~Rob@91.18.96.ns-3955] has joined #code
14:31 mode/#code [+o GeekSoldier] by ChanServ
14:38 You're now known as TheWatcher
14:41 Vornicus [~vorn@Admin.Nightstar.Net] has joined #code
14:41 mode/#code [+o Vornicus] by ChanServ
17:53
<@AnnoDomini>
Hm... This query is giving me problems. I need to select all wares along with the date each was last sold at. I have tables: ORDERS, ORDERSWARES, and WARES. ORDERS keeps order_id and the date, among other things. WARES keeps product_id and name, among other things. ORDERSWARES keeps product_id and order_id as primary-and-foreign keys, allowing for multiple products to be handled with one order. Ho
17:53
<@AnnoDomini>
w would I do it?
17:55
<@AnnoDomini>
I've tried SELECT WARES.product_name, MAX(ORDERS.date_of_purchase) FROM ORDERS, WARES, ORDERSWARES GROUP BY WARES.product_name; but it's apparently not what I was looking for.
17:56
<@EvilDarkLord>
What does that give you?
17:56
<@jerith>
You need a wrench.
17:57
<@AnnoDomini>
A list of products with the last date in all orders.
17:57
<@jerith>
Specifically, a 3/17 occipital left-leaning heterodyne wrench.
17:57
<@AnnoDomini>
Hm... Wait, I might have figured it out. I'll go check against the tables.
17:59
<@AnnoDomini>
Hah! Yes.
18:00
<@AnnoDomini>
I needed to specify WHERE ORDERS.order_id=ORDERSWARES.order_id AND WARES.product_id=ORDERSWARES.product_id
18:06
<@EvilDarkLord>
Right, you had other duplicate keys in the tables too?
18:06
<@AnnoDomini>
These things are obviously connected.
18:07
<@AnnoDomini>
But I might be misparsing what you mean.
18:09
<@EvilDarkLord>
Well, if you had 'name' as a field in two of the tables, for example, the RDBMS might guess wrong when it tries joining them without explicit joining instructions.
18:10
<@EvilDarkLord>
Joining without explicit instructions really only works reliably when all your field names are prefixed by the table name or the equivalent.
18:10
<@AnnoDomini>
The only names of fields that exist in more than one table are keys. I always specify what table they belong to for queries.
22:47 Attilla [~The.Attil@194.72.70.ns-11849] has quit [Quit: <Insert Humorous and/or serious exit message here>]
23:08 Attilla [~The.Attil@194.72.70.ns-11849] has joined #code
23:08 mode/#code [+o Attilla] by ChanServ
23:46 AnnoDomini [AnnoDomini@83.21.58.ns-4219] has quit [Quit: Astro Cat will play for you... the Symphony of Space.]
--- Log closed Tue Mar 25 00:00:48 2008
code logs -> 2008 -> Mon, 24 Mar 2008< code.20080323.log - code.20080325.log >