|
Professor Science posted:Oh, I guess if we're going to talk about algorithms books we should talk about CLRS. Probably the Dragon Book for compilers, Dinosaur Book for high-level OS concepts, Russell and Norvig for AI, Computer Systems: A Programmer's Perspective for an intro to systems programming... I didn't like the dinosaur book, Tenenbaum was much better. Also, I would suggest Stevens - Advanced Programming in the Unix Environment.
|
# ¿ Feb 25, 2008 07:48 |
|
|
# ¿ Apr 29, 2024 06:22 |
|
Professor Science posted:isn't tenenbaum basically a source walkthrough of minix, though? that seems kind of silly. It's more the other way around -- minix is the example used in a book about how operating systems are written.
|
# ¿ Feb 26, 2008 02:51 |
|
JawnV6 posted:What's top's interface called? I have a static program that polls the state of a few machines, I'd like to just wrap it up and have it constantly update to the same screen, but I don't even know what to search for to rip off how top prints out to the terminal. I think top just uses ncurses, which is a generic console interface library, and basically what any console program with a UI at all uses.
|
# ¿ Feb 26, 2008 20:35 |
|
6174 posted:Interesting. I remember just opening the files in a text editor when I used to play with programs on my TI-86 and then 89. Maybe it was the linking software allows you to view the programs? You should be able to open them in the TI Connect software, or whatever it's called now. That's assuming they're in BASIC, if they're written in assembly you're kind of hosed, but I'm assuming that no one went to the trouble to hand-write QUADFORM in assembly And if you get a program from TI's official site, it's pretty much guaranteed to be BASIC.
|
# ¿ Feb 28, 2008 00:51 |
|
Milde posted:No need for the explicitly finally/close, the with statement sets it up so f.__exit__ is always called, which simply calls close() (and this __enter__/__exit__ protocol can be adapted to other kinds of classes, like database cursors, thread locks, etc.) That's kind of similar to RAII. I like Python more and more every day
|
# ¿ Mar 2, 2008 19:07 |
|
Mercurial question, couldn't think of a better place to ask: I'm setting up Mercurial to mirror an SVN repository with hgsvn. I'm on OS X. I installed mercurial with the usual sudo make install, and it seems to have installed the modules to /usr/local/lib/python-2.5/site-packages. With my PYTHONPATH set to that directory, I'm able to run 'hg' without it failing import, so that seems to be working. But when I run hgimportsvn, it fails: code:
code:
Anyone used hgsvn on OS X before and have some suggestions?
|
# ¿ Mar 5, 2008 18:17 |
|
Milde posted:I normally run "sudo python setup.py install" when I install Mercurial. I don't know if the Makefile differs, but the local site-packages directory is in /Library/Python/2.5/site-packages/ on 10.5, and I believe it lives inside the Python.framework folder on 2.4. That worked. Thanks!
|
# ¿ Mar 5, 2008 20:17 |
|
Avenging Dentist posted:Unless you want to use C++, the only way I can think of would be to use preprocessor macros. Something like Couldn't you just write a function? Unless you want to sprintf other stuff as well -- like: code:
|
# ¿ Mar 8, 2008 07:04 |
|
Wuhao posted:Is there an algorithm for exhaustively generating all unordered subsets of a particular set? Sounds like you want the power set (the set of all subsets of a set). It's relatively nontrivial, your best bet is a dynamic programming approach where you memoize the sets you've already generated so that you don't generate duplicates.
|
# ¿ Mar 8, 2008 19:08 |
|
Gary the Llama posted:Not sure if this is worthy of it's own thread so I thought I would just post it here. I just switched my hosting to NearlyFreeSpeech.NET and they don't support any fancy web frameworks like Django or Rails. No big deal, there's always PHP, except I hate PHP. They do however support CGI Python. I like Python, but I don't know much about CGI. All CGI means is that the webserver runs your script, with some environment variables set (like QUERY_STRING), and sets your stdout to the socket for the HTTP connection. In its simplest form, a python CGI script would look like this: code:
|
# ¿ Mar 13, 2008 17:07 |
|
Bender posted:Ada question: Congratulations on having the first Ada question in CoC, to the best of my knowledge.
|
# ¿ Mar 14, 2008 20:57 |
|
clockwork automaton posted:This was indeed true, I went back and rethought my logic. Each of the lines I was looking for was prefaced with a character to mark what the line did, so I just looked for those when I was reading in. The results are quite cool actually as I was reading in OBJ files. That is a lot of polys.
|
# ¿ Apr 9, 2008 21:02 |
|
two_beer_bishes posted:I want to put together a site that will allow me to track fuel economy and maintenance for my car. I would like it to have separate pages for fuel and maintenance and also a couple other car-related costs I want to track, but I want to keep the databases separate from each other (hopefully that makes it less complicated). I want the page to show the data in a spreadsheet type format and at the top of the page it'll have an entry form for the date/#of gal/$per gal/etc... Would PHP work best for something like this? Also, at some point I would like to be able to update this from my cellphone. If the site is lightweight enough I could just pull it up using the built in browser, so I don't think I'd need any extra coding. Honestly, why not use Excel or Google Docs for this? It's really a spreadsheet kind of app.
|
# ¿ Apr 12, 2008 20:44 |
|
magicalblender posted:Whoops vv In Unix, when you use a command like "showargs", it tries to find a program called "showargs" in each directory in your PATH environment variable, and runs the first one it finds. Unlike in Windows, the current directory (which can be abbreviated as a dot) is not generally included in your PATH. You can also refer directly to a specific program, regardless of whether it's in your PATH, by specifying a full or relative path to it. So ./showargs means "showargs, in the current directory."
|
# ¿ Apr 16, 2008 22:06 |
|
Scaevolus posted:Woops, for some reason I thought 0 worked as stdin-- on some systems stdin isn't defined in <stdio.h>, and 0 works fine. 0 is the file descriptor for stdin, but fgets() (along with fread, fwrite, fopen, etc) takes a FILE*. It also wouldn't work if you did read(stdin, buff, 100).
|
# ¿ Apr 19, 2008 00:59 |
|
Tomed2000 posted:I'm not, just a student right now. I was having a conversation with a professor and he claims that 90% of the industry programs in a UNIX environment and I thought that was pretty inaccurate. 90% is inaccurate. But if you're doing web development, for instance, you can often work in whatever environment you want to, so many shops leave it open. If you're writing Java for a big iron machine, it doesn't matter if the development platform is Windows, OS X, Linux, whatever, if it runs Java it's probably a legitimate dev environment. For scripting languages (PHP, Python, Perl, Ruby) it doesn't really matter either, especially since it's probably only going to be run on the servers, not on your dev machine. In this case, your dev machine is essentially a text editor.
|
# ¿ May 30, 2008 20:16 |
|
Factor Mystic posted:On the other hand, I for one would rather sit down and start coding instead of memorizing command line tools and other crap that stand between the program in my mind and the program-to-be on the computer. Plus, I love Visual Studio, so I'm biased here. I guess if you really love command line stuff, go for it, it certainly won't make you dumber. With C++ at least, I never actually understood the build process, linking model, and even aspects of the language until I stopped using IDEs. It was only then that I understood what a "translation unit" was, really. In my opinion, going from command line to IDE is easier than the other way around, and I'm glad I can work in both environments.
|
# ¿ May 31, 2008 19:11 |
|
nolen posted:Yeah, I can set the mode to passive then parse the IP and port that it returns. I guess I'm just confused about if I'm supposed to open another socket using that IP and port combination and then send my LIST and whatever commands over that socket instead of the control socket that's originally created. You still send all your commands over the control socket. The other socket you open is for data, so that's where the actual data will come from, and then you should get the response code over the control socket again.
|
# ¿ Jun 12, 2008 13:32 |
|
I'm drawing a blank coming up with a Google string for it, but a while ago (maybe 6 months) on The Daily WTF, there was a post with the output of a tool (or maybe just a quick perl script) that took Java code and printed only the control structures and method declarations (with no identifiers), so you were got "code" that looked like:code:
|
# ¿ Jun 13, 2008 00:46 |
|
Avenging Dentist posted:This? http://thedailywtf.com/Articles/Coding-Like-the-Tour-de-France.aspx Yeah, that's it... they didn't post the tool though. Nevermind. I'd like to do that same thing with some work code.
|
# ¿ Jun 13, 2008 00:59 |
|
Femtosecond posted:Argh. I'm wanting to write a bit of code to keep track of statistics about my memory pool. I want to set up this UpdateMemoryStats function as a global so I can call it anywhere (or in the main loop) and I only want one set of stats, so I figure I should make the stats static. Unfortunately I keep getting a drat unresolved external symbol error. I'm obviously missing something... I've gone over this a bunch and I think I just need someone else to look at this or something. Somewhere (and only one place) you need to put code:
|
# ¿ Jun 20, 2008 18:57 |
|
Skychrono posted:I believe your guesses are right - we pretty much just react to the game instructions instead of really understanding them. I know there are some systems we "understand," like the NES, that we can perfectly emulate. Other than that things like the Emotion Engine and Mode 7 chips provide specialized speed for games that utilize it in the same way that a PhysX card does for computer games - we can emulate it, but it uses up speed on something else. It's really more because game console hardware is a hell of a lot more complex than it was 20 years ago. Also, the operating systems and libraries on the consoles (those exist now) have to be duplicated almost exactly, and the only documentation for them (that you can get legally, at least) is how games use them. And, you don't have the source. It'd be like handing someone a copy of Office and the x86 spec and saying "emulate Windows running on a PC, but make it run on MIPS." It's theoretically possible, but it'd be a monumental effort.
|
# ¿ Jul 4, 2008 00:25 |
|
Plastic Jesus posted:alias wireshark='open -a /Applications/Wireshark.app' iTerm is perfectly acceptable, if that's what you're into. The only reason I used to like it was tabs, and Leopard's Terminal.app has tabs now. But it's certainly not inferior to Terminal.app.
|
# ¿ Jul 10, 2008 06:35 |
|
hey wiz posted:The problem here is that your List is declared within the scope of the constructor, so after the constructor exits, you won't be able to access that list. In C#, the language he's using, List is a generic class, which can be specialized and instantiated, which is what he's doing here.
|
# ¿ Jul 17, 2008 03:04 |
|
Runaway Five posted:Question: What would be a good way to detect and alert the user of a computer if their Internet connection has been dropped. I tried to google search to see if such a thing already existed. Other than attempting to establish a connection with some server outside the network, there's no reliable way to do this. For all intents and purposes, pinging google.com should never fail.
|
# ¿ Jul 31, 2008 06:47 |
|
Incoherence posted:The XOR trick probably works in more languages than tuple-unpacking in Python, but it has a significant effect on code clarity (what the gently caress are all of these ^=s doing in my code), and as an optimization it's fairly negligible. The XOR trick is not an optimization, it's a trick. On modern CPUs it's actually slower because of pipelining. It's a "clever" trick undergrads show off to their friends. swap_xor.c: code:
code:
code:
|
# ¿ Aug 26, 2008 16:24 |
|
inlined, no pointers:code:
code:
code:
edit: partially beaten, mine has the unoptimized assembly
|
# ¿ Aug 26, 2008 22:11 |
|
JawnV6 posted:Ugh what a stupid unreadable hack to zero out a register. I despise this 'xor trick' I used to use xor a on the Z80 because it was only 1 byte and like 2 cycles whereas the immediate move was 2 bytes and like 5 cycles or something. But to be fair that was the Z80.
|
# ¿ Aug 26, 2008 22:14 |
|
Scaevolus posted:s/partially/completely/; no one cares about unoptimized assembly, the whole point is for it to be savage
|
# ¿ Aug 26, 2008 22:15 |
|
Scaevolus posted:s/partially/completely/; no one cares about unoptimized assembly, the whole point is for it to be savage It's only 'savage' because it optimized out the swaps altogether :pwn; Triple post woo
|
# ¿ Aug 26, 2008 22:17 |
|
floWenoL posted:Okay, this is how you do the benchmark. First you post the code, making sure to put something in to prevent the compiler from optimizing the whole thing out: Ok, but I think my point still stands, the compiler optimizes out the xor trick because it's not actually an optimization.
|
# ¿ Aug 27, 2008 00:56 |
|
unknown posted:I've got a small code segment that's overflowing a string with the following: You're not freeing the memory pointed to by p->messageid (assuming it was malloc()'d) code:
|
# ¿ Sep 5, 2008 15:16 |
|
unknown posted:Yes - it overflows by a character (pushing a null into the beginning of the next string in memory, therefore basically making it null). Of course, it compiles cleanly on a different OS version. strdup() internally uses malloc() (or something equivalent), so the memory pointed to by the return value of strdup() is the burden of the caller to free. So you still need to free() p->messageid before you assign something else to it.
|
# ¿ Sep 6, 2008 02:36 |
|
haveblue posted:Partly because RMS is a big baby who doesn't want to mainline Objective-C at all (hence the perma-deprecated status of #import and GCC emitting punitive warnings about it). #import in the actual language would reduce compile times on a lot of large projects by at least 50% (at least on Windows)
|
# ¿ Nov 12, 2009 02:28 |
|
Triple Tech posted:Let's say we invented some sort of software-based intelligence... Read GEB.
|
# ¿ Dec 9, 2009 01:52 |
|
|
# ¿ Apr 29, 2024 06:22 |
|
rsjr posted:I should probably reword my question. A normal binary search won't check the bounds of the sub-haystack, but if this one does, it could early out as soon as it finds that the needle is outside the bounds of the sub-haystack. Example in a weird search pseudocode i just made up: code:
|
# ¿ Aug 31, 2011 00:00 |