code logs -> 2008 -> Fri, 04 Apr 2008< code.20080403.log - code.20080405.log >
--- Log opened Fri Apr 04 00:00:10 2008
00:38 Vornicus is now known as Finerty
01:10 Shoukanjuu [~Shoukanju@71.48.224.ns-3853] has joined #code
02:00 Finerty is now known as Vornicus
02:04 gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has quit [Quit: Z?]
02:12
< Shoukanjuu>
>_>
02:12
<@McMartin>
Evening, S.
02:12
< Shoukanjuu>
Heya, McM.
02:13
< Vornicus>
It's Shou!
02:14
< Shoukanjuu>
Where?! *looks*
02:15
< Shoukanjuu>
Now, then. You said something about structs.
02:15
< Vornicus>
Yes.
02:15
< Vornicus>
Got a ROM or something handy? Something with binary data in it that you might want to extract?
02:15
< Shoukanjuu>
Shall we begin, then? Or do you need to do something first?
02:15
< Vornicus>
I can begin.
02:16
< Vornicus>
Actually before we get properly to struct, I need to do some random things with files.
02:16
< Shoukanjuu>
An n64 ROM would do, yes?
02:16
< Shoukanjuu>
Okay.
02:17
< Vornicus>
I think so, yes, so long as you know where in the rom you want to look.
02:18
< Vornicus>
and what you're looking for.
02:18
< Vornicus>
Anyway, files.
02:18
< Vornicus>
To open an existing file for reading: open(filename_as_a_string, 'r')
02:19
< Vornicus>
To open a file (existing or otherwise) for writing, obliterating hte original contents: open(filename_as_a_string, 'w')
02:21
< Shoukanjuu>
Hrm.
02:22
< Shoukanjuu>
so if the filename was "something.py"
02:22 * McMartin has some C64 programs if you need Stuff To Look For.
02:22
<@McMartin>
Actually, I'm doing this *right now* to Java class files.
02:22 * McMartin found a 90%-complete Java disassembler he wrote, is writing the last 10%.
02:23
< Vornicus>
Shoukanjuu: then the filename you ask for is, of course, "something.py"
02:24
< Shoukanjuu>
alright.
02:24
< Shoukanjuu>
Just to make sure.
02:26
< Vornicus>
Now, reading a file is not all that complicated: you use the file's read method to read data from the file; read(5) will read five bytes from the file, and read() will read the whole file. Both return a string.
02:27
< Vornicus>
the readline method will give you one line; if you give it a number, it will read at most that many bytes.
02:27
< Vornicus>
readlines will give you a list of all the lines in the file.
02:27
< Shoukanjuu>
Okay...
02:28
<@McMartin>
<<OS WARNING>>
02:28
< Shoukanjuu>
>_>
02:28
<@McMartin>
On Windows, newlines act funny depending on an option to open.
02:28
< Vornicus>
oh, it should be mentioned - all of these things advance the "cursor" if you go f.read(5) and then f.read(5) again, the second one will give you the five characters /after/ the result of the first one.
02:28
< Shoukanjuu>
Very big ship coming at full throttle? [/ikaruga]
02:28
< Shoukanjuu>
I see
02:29
< JeffL>
(Hey, does he know about objects?)
02:29
< Vornicus>
Actually, all three major operating systems use a different character or character pair for newlines; in text mode (the default), Python understands all three and replaces them with \n
02:29
<@McMartin>
(Not yet)
02:29
< Vornicus>
(Not yet)
02:30
<@McMartin>
(MacOS is no longer major.)
02:30
<@McMartin>
(OS X follows POSIX)
02:30
< Vornicus>
(well, okay, Classic MacOS isn't, you're right)
02:30
< JeffL>
(doesn't open() return an object?)
02:30
<@McMartin>
(Yes, but you can ignore that)
02:31
<@McMartin>
(class and friends have not yet come up)
02:31
< Shoukanjuu>
<open file 'soemthing.py', mode 'r' at 0x593c8> >_>
02:32
< Vornicus>
You can also force it to use binary mode, where it does not convert newlines; this is preferable when you're trying to use things like struct.
02:32
<@McMartin>
( http://rafb.net/p/kIo5Il56.html )
02:32
<@McMartin>
(In OCaml!)
02:34
< Vornicus>
To make the computer open your file in binary mode, add 'b' to the thing that already says 'r' or 'w'
02:34
< Vornicus>
so 'rb' or 'wb' for instance
02:34
<@McMartin>
I'd add that when you want text mode, it's good form to use "rt" or "wt" just to indicate that you mean it
02:35
< Vornicus>
What McM said.
02:35
< Shoukanjuu>
I see
02:35
< Shoukanjuu>
But uh
02:36
< Shoukanjuu>
It opened it to what looks like a memory address
02:36
< Shoukanjuu>
Now r eading it...I would need to specify the address
02:36
< Vornicus>
No, no
02:36
< Vornicus>
The file is not a string; the file is a file. If you want to get a string from it, use the read methods.
02:38
< Shoukanjuu>
And reading the file? I should do this after opening it, but putting in read() yields a "read not defined" thing
02:38
< Vornicus>
(this also saves memory - if you have a 2GB file you can read it in chunks, process the chunks one at a time, and then they will be discarded later))
02:38
< Vornicus>
Show me how you opened it
02:38
< Shoukanjuu>
open("soemthing.py", 'r')
02:39
< Vornicus>
Okay. This opens the file, and returns a file object; you have to assign it to something to be able to use methods on it.
02:39
< JeffL>
(told you)
02:40
< Shoukanjuu>
It returned what I posted earlier
02:40
< Vornicus>
right
02:41
< Vornicus>
So you have to assign that to something. The usual name, if you're only working with one file, is f
02:42
< Shoukanjuu>
....>_> f = 0x593c8
02:43
<@McMartin>
That's just a magic number for debugging Python itself.
02:43
< Vornicus>
try f = open("something.py", 'r')
02:43
< Shoukanjuu>
Ah. Okay.
02:44
< Shoukanjuu>
Alright.
02:44
< Vornicus>
Then you call the methods on f
02:45
< Shoukanjuu>
It works :O
02:46
< Shoukanjuu>
f.read(5) yielded '#!/us' :D :D
02:46
< Vornicus>
Gasp
02:46
< Vornicus>
now try f.read(5) again.
02:46
< Shoukanjuu>
Should yield r/bin ...yes, it does
02:47
< Vornicus>
Okay, now try f.readline()
02:47
< JeffL>
(Argh, I really wish windows would let me close task manager windows once I open them)
02:47
<@McMartin>
(? Alt-F4 should work)
02:48
<@C_tiger>
JeffL try exit
02:48
< Shoukanjuu>
Read the rest of the line, ending with \n
02:49
< Shoukanjuu>
So it also shows where the newlines and assumedly, tabs are
02:49
< JeffL>
(Oh thank you McMartin. The first few days I was messing around with this computer, I accidentally found some way of triggering a way of changing the size... of the "master" bar that contains the minimize, maximize, and close buttons. And promptly somehow made it size 0, so I can't drag it to a decent size again, or reach the close button.)
02:49
< Shoukanjuu>
(I <3 Windows :D)
02:49
< Shoukanjuu>
(Wait no)
02:50
<@McMartin>
(If that's the bottom taskbar, there's this line that's still present you can drag near but not quite *at* the bottom of the screen)
02:50
< JeffL>
(Not the bottom taskbar)
02:50
<@McMartin>
(oh, wait, just read that again. o_O)
02:50
< JeffL>
(The thing that comes up when you press Ctrl-alt-del)
02:50
< Shoukanjuu>
(The heading bar for everything, where the three butons are in the vorner)
02:50
< JeffL>
(So if I ever need to end a process, I have that bar floating around above everything else... until I reboot.)
02:50
< Shoukanjuu>
(Corner, even. vV_)
02:51
< Vornicus>
Well, it fills the strings; what you're seeing in those returns is the "representation" of the string - a way of describing the string so that it can be read entirely in printable characters, without any unambiguity.
02:52
< Shoukanjuu>
Nifty :)
02:52
< Vornicus>
er
02:52
< Vornicus>
without any ambiguity
02:52
< Vornicus>
so if you were to take that string and dump it directly into another python script, it'd work as a string
02:52
<@C_tiger>
Jeff... "master bar"?
02:53
< Shoukanjuu>
Whoo :)
02:57
< Vornicus>
Aaaaanyway.
02:57
< Vornicus>
you can also iterate over files, using the for statement; it will consider each line in the file in turn.
02:58
< Vornicus>
(this is, obviously, only useful for text)
02:58
< Shoukanjuu>
Ah.
02:59
< Vornicus>
(but that's the first rule of data storage: if at all possible, Use Text Dammit)
02:59
< Shoukanjuu>
(XD)
03:00
<@C_tiger>
except when you want to frustrate other people.
03:00
< Shoukanjuu>
Heehee
03:00
< Vornicus>
There are of course exceptions; images, sounds, and movies, for instance, should all be in binary, because text would be silly.
03:01
< Vornicus>
Anyway.
03:02
< Vornicus>
You saw how earlier I talked about how you can open files for writing? There's only one method unique to writable files: write.
03:02
< Vornicus>
WHich will write any string you give it to the file.
03:03
<@C_tiger>
Question from the gallery: will it clobber?
03:03
< Vornicus>
That depends on the mode you opened the file in.
03:03
< Shoukanjuu>
Okay...
03:04
< Vornicus>
Using 'w', you will start at the beginning of the file, and you will clobber anything already in the file - even if the file was bigger than what you're putting in.
03:04
< Vornicus>
using 'a' instead, you will start at the /end/ of the file, and you will not clobber anything - the stuff just adds on to the end of the file.
03:04
< Shoukanjuu>
Okay. ^^
03:05
<@McMartin>
"append"
03:05
<@C_tiger>
You should be aware of which you're using.
03:05
< Vornicus>
(there's also "+" modes, which are a bit tricky)
03:05
<@C_tiger>
The key lesson to learn: know how you opened the file BEFORE you write to it.
03:06
<@McMartin>
Oh yeah, also, if you're writing text, you can corrupt print to your will.
03:06
<@McMartin>
print>>f, "anything else you'd send to a print statement"
03:06
<@McMartin>
will write that stuff to f, followed by whatever counts as a newline in your current OS.
03:07
< Shoukanjuu>
Ah.
03:08
< Vornicus>
Okay. Two last methods on files; these work on both kinds. seek and tell.
03:08
< Vornicus>
Seek will move the position of the cursor in the file; by seeking, you can skip to any point in the file.
03:08
< Vornicus>
Tell tells you the cursor's position in the file; it's kinda like the opposite of seek.
03:09 * Vornicus randomly floods the channels with rabites.
03:09
<@McMartin>
Oh, also
03:09
< Shoukanjuu>
...Rabites?
03:09
<@McMartin>
There are "files" that represent "the keyboard" and "the screen".
03:10 * Shoukanjuu gets the sword of mana out
03:10
<@McMartin>
DAAAAAAAAAAAAAAAAAA
03:10 * McMartin counters them with Rabbids.
03:10
< Shoukanjuu>
Oh?
03:10
< Vornicus>
Yes.
03:10
<@McMartin>
sys.stdin and sys.stdout are "standard input" and "standard output".
03:10
< Vornicus>
(you will, of course, have to import sys first)
03:10
<@McMartin>
You'll need to import sys first, of course.
03:10
<@McMartin>
Yeah
03:10
< Shoukanjuu>
Oh, okay :_
03:14 mode/#code [+ooooo Bobsentme JeffL Serah Shoukanjuu Vornicus] by Vornicus
03:14
<@Vornicus>
http://docs.python.org/lib/bltin-file-objects.html <--- here are all the methods on files.
03:15 * Shoukanjuu bookmarks this too
03:16
<@McMartin>
For struct meat, if you don't have a binary file of known format, I suggest grabbing http://www.stanford.edu/~mcmartin/misc/Hello.class
03:16
<@McMartin>
It's got some easy-to-grab stuff at the beginning, at least
03:16
<@McMartin>
(4 byte magic number, then 2-byte integers for minor version, major version, and constant count)
03:16
<@McMartin>
(all big-endian)
03:20 * Vornicus hunts around.
03:20
<@Shoukanjuu>
Mmm...
03:21
<@Vornicus>
Okay, let's use his.
03:21
<@McMartin>
Also, the Java Class magic number is entertaining.
03:21
<@Vornicus>
Okay, put that thing in a directory that you can navigate to easily.
03:23
<@Shoukanjuu>
done
03:23
<@Vornicus>
Okay. Now, in your interactive prompt: import struct
03:25
<@Shoukanjuu>
'okay
03:27
<@Vornicus>
struct has four functions in it: pack, unpack, pack_into, and unpack_from. We'll be working mainly with pack and unpack.
03:28
<@Vornicus>
Okay, so: f = open("Hello.class", 'r') or whatever the appropriate path to get to that file is.
03:28
<@McMartin>
rb
03:28
<@Vornicus>
oh, yes
03:28
<@Vornicus>
rb.
03:28
<@Vornicus>
want to make sure you're in binary mode, because this is a binary file.
03:28
<@Vornicus>
(we are living in a binary world, and I am a binary girl...)
03:30
<@McMartin>
(The classfile is just a Hello World program; I posted its disassembly about an hour ago here)
03:30
<@Vornicus>
Then let's read ten bytes from that file, and call it, idunno, header
03:31
<@Shoukanjuu>
Okay
03:31
<@Shoukanjuu>
\xca\xfe\xba\xbe\x00\x00\x002\x00\x1d
03:31
<@Vornicus>
There you are.
03:32
<@Vornicus>
Now: we need to take that, and unpack it into the numbers that it represents.
03:32
<@Vornicus>
unpack takes a format string and a string full of data, and returns a tuple of the stuff.
03:34
<@Vornicus>
so, here: struct.unpack(">I3H", header)
03:34
<@Vornicus>
actually, assign that to unpacked_header
03:37
<@Shoukanjuu>
struct.unpack(">l3H", unpacked_header) ?
03:37
<@McMartin>
Capital i.
03:37
<@Vornicus>
no
03:37
<@Shoukanjuu>
Also, is that a capital i or a lowercase l ?
03:37
<@Shoukanjuu>
Okay
03:37
<@Vornicus>
Capital i, and unpacked_header = struct.unpack...
03:37
<@Shoukanjuu>
The font I'm using barely differentiates the two
03:37
<@C_tiger>
Shoukanjuu use one that does.
03:39
<@Shoukanjuu>
headr notdefined? O_o;
03:39
<@Vornicus>
header? And did you assign the stuff from before to it?
03:40
<@Shoukanjuu>
not yet Xd;
03:41
<@McMartin>
You'll have to reopen the file then or you'll be trying to decode the constant pool instead of the header
03:41
<@Shoukanjuu>
so header = \xca...
03:42
<@Vornicus>
Or, you can just copy past
03:42
<@Vornicus>
and use quotes around that.
03:42
<@Shoukanjuu>
Okay
03:44
<@Vornicus>
Once you have the unpack working, tell me
03:46
<@Shoukanjuu>
I think I got it
03:46
<@Shoukanjuu>
a long number is included >_>
03:46
<@Vornicus>
All right.
03:46
<@McMartin>
Try passing that long number to hex().
03:47
<@Shoukanjuu>
Okay
03:47
<@McMartin>
(Despite being a 32-bit number, it's larger than will fit in 32-bit signed, so it was promoted to long automatically)
03:50
<@McMartin>
Anyway, doing this should grant you something readable, once you strip off the "0x" at the front and the "L" at the end.
03:50
<@McMartin>
That's the so-called "magic number" for the binary file, that indicates which value it is.
03:50
<@Shoukanjuu>
I see
03:51
<@McMartin>
The other three values are, in order, "minor version", "major version", and "size of the constant pool"
03:51
<@Shoukanjuu>
Okay :)
03:51
<@Vornicus>
The magic number on a binary file is a number used to identify that kind of file.
03:51
<@McMartin>
So you should now be able to write a script that, given a filename:
03:52
<@McMartin>
(a) tells you whether or not it's a Java Classfile
03:52
<@McMartin>
(b) If it is, tells you the version number (major.minor, as in "46.3") and the size of the constant pool
03:54
<@McMartin>
(Java class files have a magic number that spells stuff out in hex; many others spell stuff out in ASCII)
03:56
<@McMartin>
(an iNES file, for instance is "NES" and then binary 26, the DOS EOF character)
03:57
<@McMartin>
(And a .png file has 0x89 and then "PNG")
03:58
<@Shoukanjuu>
Ahhhh.
03:59
<@McMartin>
Hmm. Actually
04:00
<@McMartin>
It's that, and then 0x0d, 0x0a, 0x1a, 0x0a.
04:00
<@McMartin>
Which is a Windows Newline, a Windows EOF, and then a POSIX newline.
04:00
<@Shoukanjuu>
Ooh.
04:01
<@Vornicus>
PNG is designed to go "oh, shit, your transfer modes are messed up" when your transfer modes are messed up.
04:03
<@Shoukanjuu>
bebafeca is the magic number for the javascript
04:03
<@Vornicus>
nope.
04:03
<@Vornicus>
cafebabe
04:03
<@Shoukanjuu>
It isn't in that order >_>
04:03
<@McMartin>
You forgot the >, I suspect.
04:04
<@McMartin>
Time for me to get dinner.
04:05
<@McMartin>
But before I go, a quick reminder that Java != Javascript
04:34
<@Vornicus>
Anyway.
04:35
<@Vornicus>
Given the format, and a tuple similar to the one generated by unpack, you can use pack, and it works backwards - it will give you a string.
04:36
<@Shoukanjuu>
o the tuple that was the long number, minor, major, and constant pool size
04:36
<@Shoukanjuu>
in conjunction with 'pack'
04:36
<@Shoukanjuu>
will give me a string vaguely reminiscent of the one earlier. I got it, I think.
04:38
<@McMartin>
Should be identical
04:38
<@Shoukanjuu>
The same one, identical, or identical in syntax?
04:38
<@Shoukanjuu>
Er...Not syntax. Not the word I'm looking for... :/
04:39
<@Vornicus>
The same exact string.
04:39
<@Shoukanjuu>
Okay, then.
04:40
<@Shoukanjuu>
And the magic number will be different for other file types, yes?
04:41
<@McMartin>
Right.
04:41
<@McMartin>
Also how long it is, etc.
04:41
<@Shoukanjuu>
Whoo.
04:41
<@McMartin>
Basically, well-designed binary files have some way of identifying what kind of file they are.
04:42
<@Shoukanjuu>
Okay O:
04:43
<@McMartin>
(Not all files are well-designed, but the chances of a non-well-designed file accidentally having the right magic number are slim indeed)
04:43
<@Shoukanjuu>
(I would imagine s)
04:43
<@Shoukanjuu>
(so&*)
05:00 AnnoDomini [AnnoDomini@83.21.59.ns-4888] has joined #Code
05:00 mode/#code [+o AnnoDomini] by ChanServ
05:07
<@Vornicus>
Shoukanjuu: so, the reason I was wondering about ROMs - you can run a hex editor, right?
05:07
<@Shoukanjuu>
Yes
05:08 JeffL [JPL@Nightstar-12038.dsl.sndg02.pacbell.net] has quit [Connection reset by peer]
05:08
<@Vornicus>
Haven't you occasionally said "dammit, I wish I didn't have to do all this crap by hand"?
05:09
<@Shoukanjuu>
Not really
05:09
<@Vornicus>
Heh. Well, okay. The point of struct is, you don't have to do all this crap any more.
05:10 JeffL [JPL@Nightstar-12038.dsl.sndg02.pacbell.net] has joined #code
05:11
<@Shoukanjuu>
:O
05:11
<@Shoukanjuu>
Find and replace? XD
05:12
<@C_tiger>
Ok, find and replace is a sign of bad programming practice :P
05:12
<@Vornicus>
Only if you're using it to program.
05:13
<@Shoukanjuu>
Well, I never used it
05:13
<@Shoukanjuu>
It was nasty >.>
05:15
<@Vornicus>
YOu can use struct to take apart a big chunk of data, then edit it at your leisure (programmatically or by hand!) and then stuff it back together and put it back in place.
05:16
<@Shoukanjuu>
Ooh.
05:17
<@Vornicus>
I'm currently using struct to reverse engineer the probability distribution for planet and star types from Master of Orion.
05:17
<@Shoukanjuu>
>_>
05:18
<@C_tiger>
Don't forget, vorn-level crazy isn't the same as everyone-else-level crazy.
05:18
<@Shoukanjuu>
hehe
05:18
<@Vornicus>
(I open MoO, make a game, save it, then point the script at it)
05:19
<@Shoukanjuu>
See, I started with messing around with growth percentages in Fire Emblem games >_>
05:19
<@C_tiger>
This is one reason not to save your data in parseable text.
05:20
<@Vornicus>
What?
05:20
<@C_tiger>
vorn-hacking.
05:20
<@Vornicus>
reverse engineering? If you want to prevent that, you have to /encrypt/. Just not documenting isn't enough, when faced with a dedicated hacker.
05:21
<@C_tiger>
True.
05:21
<@Vornicus>
And even encryption won't stop the real crazies. They'll attach a debugger.
05:22
<@C_tiger>
I was trying to be funny... I guess vorncrazy is not QUITE the highest level of crazy there is.
05:22 * Vornicus is not as crazy as TF.
05:22
<@Shoukanjuu>
Hehehe
05:23
<@Vornicus>
TF, see, one of his main projects is a level editor for System Shock.
05:24
<@Vornicus>
Where the data files are compressed with an absolutely insane algorithm.
05:26 * McMartin uses Python a lot for reorganizing large chunks of the UQM codebase.
05:26
<@Vornicus>
ah, code that writes code.
05:40
<@McMartin>
Sort of
05:40
<@McMartin>
More "too much data to collate by hand" these days
05:41
<@Vornicus>
Well, okay.
05:41
<@McMartin>
I'M GIVE UP YOUR APPELLATION'S TECHNICAL MONKEY
05:41
<@Vornicus>
okay.
05:42 * Vornicus imagines the guy from Zero Wing saying that.
05:42
<@McMartin>
That's actually Gradius III
05:42
<@McMartin>
I have no idea.
05:42
<@Shoukanjuu>
Say what
05:42
<@Shoukanjuu>
I have pings on Gradius III
05:42
<@Shoukanjuu>
>_>
05:43 * McMartin was watching a tool-assisted superplay video of Gradius III - that line appeared after the credits.
05:43
<@Shoukanjuu>
Hehe
05:43
<@Shoukanjuu>
I beat Gradius III in hard without options :3
05:43
<@McMartin>
Which edition?
05:44
<@Shoukanjuu>
SNES
05:44
<@Vornicus>
"superplay" video? What, does he kill /everything/?
05:45
<@Shoukanjuu>
Well
05:45
<@McMartin>
Vornicus: Almost. Stage 7 it is physically impossible to do so.
05:45
<@Shoukanjuu>
Yeah >_>
05:45
<@Vornicus>
...wow.
05:45
<@Shoukanjuu>
See, in Hard Mode, when you aren't using Options
05:45
<@Shoukanjuu>
Superplay can mean any mumber of things.
05:45
<@Shoukanjuu>
Like surviving.
05:46
<@McMartin>
This was "Arcade Mode"
05:46
<@McMartin>
Which is even worse
05:46
<@McMartin>
And still vastly weaker than the actual arcade mode.
05:46
<@McMartin>
None of the After Burner stages, for one.
05:46
<@McMartin>
(Actual Arcade Mode available with Gradius IV for PS2!)
05:47
<@Shoukanjuu>
Hehe
05:47
<@Shoukanjuu>
Ikaruga!
05:47
<@McMartin>
Ikaruga didn't do it for me.
05:47 * McMartin is Not A Fan of bullethell shooters.
05:48
<@Shoukanjuu>
Heheh
05:48
<@McMartin>
Particularly not ones that mandate the use of some gimmick, which seems to be a defining feature.
05:48
<@McMartin>
Also not a fan of memorization shooters, which pretty much leaves the Gradii and a few special cases.
05:48
<@McMartin>
Zanac being the big one.
05:49
<@Shoukanjuu>
Heh
06:11
<@Kazriko>
Like Superstardust HD? :)
06:14
<@Shoukanjuu>
Ikaruga and Vic Viper prints :3
06:15
<@Shoukanjuu>
We've got the Ikaruga http://i210.photobucket.com/albums/bb76/TruthinLies/100_0925.jpg and Vic Viper http://i210.photobucket.com/albums/bb76/TruthinLies/100_0931.jpg
06:16 * Vornicus tried McM on Bullet Heck, Bullet Jeez, and Bullet Aw Fiddlesticks shooters.
06:16
<@Shoukanjuu>
I like calling it Bullet Hail instead of Hell
06:16
<@Shoukanjuu>
Because nothing gets the blood pumpimg like OMG BULLETS *dead*
06:16
<@Vornicus>
tries*
06:17 * Vornicus also tries Bullet Phooey.
06:25
<@McMartin>
Well, see, OMG BULLETS I don't mind as long as it's relying on sweet spots instead of quirky defensive mechanics.
06:26
<@Vornicus>
What is your opinion on Meritous?
06:26
<@McMartin>
I haven't played it.
06:26
<@Shoukanjuu>
Nor have I.
06:26
<@Vornicus>
(Meritous is... hard to describe, frankly)
06:27 * Shoukanjuu traps Vornicus in Parodius
06:27 * Vornicus is attacked by a very large woman.
06:28
<@McMartin>
Wielding ears of corn.
06:28
<@Vornicus>
(it's a top-down rooms-shooter, vaguely like SmashTV; but your weapon is a circular shockwave)
06:29
<@Shoukanjuu>
Parsec47 D:
06:43 * McMartin fires up Geometry Wars Galaxies for the first time in awhile.
06:44
<@Shoukanjuu>
Geometry Wars is fun :>
06:44 * Vornicus does not know this Geometry Wars.
06:45 Thaqui [~Thaqui@Nightstar-123.jetstream.xtra.co.nz] has joined #code
06:45 mode/#code [+o Thaqui] by ChanServ
06:47
<@Shoukanjuu>
I have it for DS (usign the R4DS) and for Wii( D2pro ftw >.>)
06:50
<@McMartin>
Vornicus: Robotron meets tempest.
06:50
<@McMartin>
With lots and lots of gimmicks
06:50
<@McMartin>
GW:RE is the base game which isn't nearly as much fun
06:53
<@McMartin>
Still only Bronze on CLATRIS. =(
06:53
<@Shoukanjuu>
which one was that?
06:54
<@McMartin>
Well, like it says on the tin, it's the third "classic" board.
06:54
<@McMartin>
Also the first planet in Delta system.
06:54
<@Shoukanjuu>
Ah.
06:55
<@Shoukanjuu>
I got 11,172,975 on it
06:56
<@Shoukanjuu>
SURTRIS fails ; ;
06:57 * McMartin has a silver on SURPENTE.
06:57 * McMartin is mainly just collecting XP for the last few drone behaviors now.
07:00
<@McMartin>
Got my silver in BATTRIS.
07:00 * Shoukanjuu only bothered maxing out sweep
07:06
<@Vornicus>
Aha
07:12
<@McMartin>
So. COLLECT drone. Noooot one of my favorites.
07:12 * McMartin just maxed out RAM.
07:12 * McMartin is also fond of Attack, Defend, and Snipe.
07:12
<@McMartin>
Defend is particularly nice on survival missions.
07:12
<@McMartin>
Still sucking at the VAR and CLA boards, though.
07:12
<@McMartin>
Oh, and FLI and ORB. =(
07:12
<@McMartin>
MAS I'm pretty decent on, though.
07:14
<@McMartin>
YES
07:14
<@McMartin>
Got the Bronze on SURTETRA.
07:27
<@McMartin>
And on CLAPENTE. And Collect is up to level 5.
07:27
<@McMartin>
That's good enough for tonight, I think.
07:57 Vornicus is now known as Vornicus-Latens
08:26 gnolam [lenin@85.8.5.ns-20483] has joined #Code
08:26 mode/#code [+o gnolam] by ChanServ
09:08 GeekSoldier|bed is now known as GeekSoldier
10:20 AFKSkull [~none@Nightstar-7066.dyn.optonline.net] has quit [Ping Timeout]
10:21 AFKSkull [~none@Nightstar-7066.dyn.optonline.net] has joined #code
10:36 Thaqui [~Thaqui@Nightstar-123.jetstream.xtra.co.nz] has left #code [Leaving]
11:28 Attilla [~The.Attil@194.72.70.ns-11849] has quit [Quit: <Insert Humorous and/or serious exit message here>]
11:39 Attilla [~The.Attil@194.72.70.ns-11849] has joined #code
11:39 mode/#code [+o Attilla] by ChanServ
13:20 AnnoDomini [AnnoDomini@83.21.59.ns-4888] has quit [Ping Timeout]
13:28 AnnoDomini [AnnoDomini@83.21.25.ns-2874] has joined #Code
13:28 mode/#code [+o AnnoDomini] by ChanServ
15:41 gnolam [lenin@85.8.5.ns-20483] has quit [Quit: Gone]
16:05 Doctor_Nick [~nick@Nightstar-23600.hsd1.fl.comcast.net] has joined #code
16:35 GeekSoldier [~Rob@91.18.80.ns-26841] has left #code []
16:35 GeekSoldier [~Rob@91.18.80.ns-26841] has joined #code
16:36 mode/#code [+o GeekSoldier] by ChanServ
17:14 GeekSoldier is now known as GeekSoldier|bar
17:29 Doctor_Nick [~nick@Nightstar-23600.hsd1.fl.comcast.net] has quit [Client exited]
18:16 GeekSoldier|bar [~Rob@91.18.80.ns-26841] has quit [Ping Timeout]
18:28
<@Bobsentme>
Ok, after asking several people, reading half the internet, and so forth, I am still at a loss.
18:29
<@Bobsentme>
I cannot, for the life of me, figure out how to turn the second field of a text file into a variable in bash
18:56
<@Vornicus-Latens>
You'll need to use awk, but I don't know awk
18:56
<@C_tiger>
I didn't know text files had multiple fields :(
19:00 AnnoDomini is now known as Lance
19:04
<@ToxicFrog>
You don
19:04
<@Bobsentme>
C_tiger: That may very well be my problem.
19:04
<@ToxicFrog>
t need awk, but it makes things easier
19:04
<@ToxicFrog>
However, the way I generally do it -
19:05
<@ToxicFrog>
cat file | { while read first second rest; do echo "first field is $first, second is $second, the rest of the line is $rest"; done }
19:05
<@Bobsentme>
The goal is to take two text files, formatted as "NAME PHONE#" and "NAME DAYOFWEEK" and make one file that has "NAME PHONE# DAYOFWEEK"
19:06
<@Bobsentme>
Oh, and just to make it hard, we HAVE to use a FOR loop
19:06
<@Vornicus-Latens>
Okay, /that/ has awk /all over it/
19:06
<@ToxicFrog>
Personally I wouldn't use awk for that either
19:06
<@Vornicus-Latens>
no?
19:07 * ToxicFrog fiddles for a moment
19:07
<@Vornicus-Latens>
...well, true, you'll probably want something that throws objects around, drop into perl or python or something
19:07
<@ToxicFrog>
No, I mean, I'd use plain bash
19:07
<@Bobsentme>
crap, I got my scripts mixed up. THIS one doesn't need a for loop.
19:08
<@C_tiger>
Oh... as in a text file with multiple columns?
19:08
<@Bobsentme>
I thought it would be easier to use one though.
19:08
<@Bobsentme>
c_tiger: technically, no. There is only 1 space after each name, and the names are varying lenghts
19:09
<@ToxicFrog>
It made slightly more complicated by having multiple input files, but not hugely so
19:09
<@Bobsentme>
lengths.
19:09
<@C_tiger>
Bobsentme: ok, but it's all one text file.
19:10
<@C_tiger>
Somehow I was under the impression that you had a magic text file with two "parts"
19:10
<@ToxicFrog>
No, he has two text files containing newline-seperated records with space-seperated fields
19:10
<@C_tiger>
Like you'd read halfway, hit a EOF but there's a second magic section.
19:10
<@Bobsentme>
yes, "NAME(space)PHONE#" is one, and "NAME(space)DAYOFWEEK" is the second.
19:10
<@Vornicus-Latens>
Do they both have the same names in them?
19:11
<@Bobsentme>
I have to combine them into text file #3 as columns with "NAME PHONE# DAYOFWEEK"
19:11
<@Bobsentme>
Yes
19:11
<@ToxicFrog>
Oh, right, that makes it trivial
19:11
<@Vornicus-Latens>
Are they sorted?
19:11
<@ToxicFrog>
You don't even need to sort it
19:11
<@Bobsentme>
No, but I know how to sort them.
19:11
<@ToxicFrog>
Although that will help if you can guarantee that each contains exactly the same set of names
19:11
<@Bobsentme>
My problem is string manipulation. Every loop I do counts the space as a new line
19:12
<@C_tiger>
Are any of the names repeated?
19:12
<@C_tiger>
can you guarantee that the names are the same and in the same order?
19:12
<@Bobsentme>
So, when I do: for name in `cat textfile1`; do echo $name; done; I get the name AND Phone #
19:13
<@Bobsentme>
The names are the same, but in different orders
19:13
<@C_tiger>
Ok, do the names have spaces in them?
19:13
<@ToxicFrog>
I'd just do it like: cat file1 | { while read name phone; do egrep "^$name" file2 | read _ date; echo "$name $phone $date"; done }
19:13
<@Bobsentme>
No, it's just first names
19:13
<@ToxicFrog>
Or similar.
19:14 * Vornicus-Latens Learns!
19:14
<@ToxicFrog>
You could alternately do entertaining things by opening both files at once and feeding them to read usig the -u option, which has the advantage of being much faster
19:14
<@Bobsentme>
-u option?
19:15
<@ToxicFrog>
you can go "read -u fd" to read from a given file descriptor rather than stdin
19:16
<@ToxicFrog>
Like, say:
19:16
<@ToxicFrog>
5<>file1
19:16
<@ToxicFrog>
6<>file2
19:17
<@ToxicFrog>
read -u 5 name date; read -u 6 _ phone;
19:17
<@ToxicFrog>
echo $name $date $phone
19:17
<@Vornicus-Latens>
That there only works if they're in the same order;
19:17
<@ToxicFrog>
Aah, yes
19:17
<@Vornicus-Latens>
you should sort first if you do it that way.
19:18
<@ToxicFrog>
So you sort them first
19:19
<@Bobsentme>
http://rafb.net/p/0Hph6b89.html
19:19
<@Bobsentme>
That's file one
19:20
<@Bobsentme>
File 2
19:20
<@Bobsentme>
http://rafb.net/p/3Bias272.html
19:20
<@Bobsentme>
AFTER the sort.
19:20 Vornicus-Latens is now known as Vornicus
19:25
<@Bobsentme>
I think name is already taken, as when I just tried to echo it, it echoed MY name
19:26
<@Bobsentme>
Which is nowhere in the file. XD
19:42
<@Vornicus>
There are some reserved names
19:43
<@Vornicus>
So, use something other than "name"
19:43
<@Vornicus>
say "on_call_name", or something silly
19:43
<@Bobsentme>
right
19:45
<@Bobsentme>
ok, I'm lost.
19:46
<@Bobsentme>
Per you guys, use a while loop, with read -u fd, right?
19:46
<@Vornicus>
Looks it, yes.
19:46
<@Bobsentme>
ok, just checking.
19:50
<@Bobsentme>
sadly, I think I am now more confused than I started.
19:52
<@Bobsentme>
I was hoping there was some bash equivilent to just typing "for %f %f in (file1) do echo %f %g", but it looks like there isn't.
20:23 Alek [~omegaboot@70.131.130.ns-21959] has joined #code
20:23
< Alek>
grep '[n-z](ac)+k'
20:23
< Alek>
what does this do? >_>
20:26
<@jerith>
Searches (on stdin, unless you give it a list of files) for something that matches "any lowercase letter from n to z, followed by one or more instances of 'ac', followed by k".
20:26
<@jerith>
Examples of matching strings are "lacack" and "yack" and "nacacacacacacack"
20:27
<@jerith>
I heartily recommend finding and read a good regular expression tutorial.
20:32
< Alek>
interestingly enough, it requires either egrep or the -e option, apparently.
20:33
< Alek>
or whatever the option is to force extended. I forget.
20:33
< Alek>
with plain grep, it returns nothing.
20:33
< Alek>
no matches.
20:38
<@jerith>
Oh, because of the grouping.
20:38
< Alek>
how do you tell sed to use more than one pattern file?
20:38
<@jerith>
Try \( and \) in plain grep.
20:38
< Alek>
sed -f pattern -f pattern file
20:38
< Alek>
will that work?
20:38
<@jerith>
Dunno. I tend to chain seds if I need more than one.
20:39
< Alek>
If you had more than one sed command (cmd1 and cmd2) to execute
20:39
< Alek>
again a file (inFile), identify 2 different ways (with a single sed command)
20:39
< Alek>
that you could process these sed commands:
20:48 * Bobsentme sighs
20:49
<@Bobsentme>
all I get when testing commands are errors.
20:55
<@Bobsentme>
What if I do if statements? Something along the lines of "If $name in `cat file1` != $name in `cat file2`, do echo $name >> phonelist else $name >> name"
21:06
<@Bobsentme>
Interesting to note:
21:06
<@Bobsentme>
When you say: oncall=`cat file1`
21:06
<@Bobsentme>
it sets $oncall to the entire file
21:07
<@Bobsentme>
If you try "for oncall in `cat file1`; echo $oncall; done", you get ONE LINE AT A TIME
21:08 * Bobsentme beats bourne
21:17
< Alek>
huh
21:17
< Alek>
-f -f works
21:24 Lance is now known as AnnoDomini
21:50 Alek [~omegaboot@70.131.130.ns-21959] has left #code []
22:04
<@Bobsentme>
?
22:08 GeekSoldier|bar [~Rob@91.18.114.ns-12584] has joined #code
22:12 GeekSoldier|bar is now known as GeekSoldier
23:09 AnnoDomini [AnnoDomini@83.21.25.ns-2874] has quit [Quit: We sense... something... something ancient... a sickly smell... a chilling wind. My ancestors scream from within their chambers in my mind but I cannot understand their words. This feeling... a memory? It sickens us, and for the first time in our lives for the first time in generations... We fear.]
23:34 Bobsentme [Bobsentme@99.149.240.ns-12157] has quit [Quit: Now running PassedOut.bat]
--- Log closed Sat Apr 05 00:00:21 2008
code logs -> 2008 -> Fri, 04 Apr 2008< code.20080403.log - code.20080405.log >