|
Magicmat posted:ints don't hold decimals, they automatically are truncated to, well, integers. So your statements are compiled as: I changed the ints to doubles and it worked perfectly. Thanks!
|
# ? Oct 26, 2010 02:22 |
|
|
# ? May 22, 2024 22:14 |
|
Waltzing Along posted:I figured it out. Thanks! Come on, don't do this. Leave your question in place so others can see the solution.
|
# ? Oct 26, 2010 14:06 |
|
Is there a website where you can input a hex color code and it tells you what color it is?
|
# ? Oct 26, 2010 18:00 |
|
God Exists. posted:Is there a website where you can input a hex color code and it tells you what color it is? If you mean the color name there's this: http://www.december.com/html/spec/colorcodes.html If you mean what #FF046C makes, or something like that, try this: http://html-color-codes.info/ Both of these were found by Googling for "hex color codes"
|
# ? Oct 26, 2010 18:42 |
|
I'm working on a standard dynamic linked list assignment for a 200 level computer science class. We had a question on the last test to the effect of "if these cout << ... lines were added to the different constructors, destructor, and assignment operator, what would the output be for these code snippets?" Basically, a roundabout way of asking which bit of code you're dealing with on the back end to do various tasks. So now, back to the program at hand, I've got things ready to hand in and working gloriously (the assignment was actually to make some modificatins to the author's code from our textbook) but I decided to try adding a cout to the destructor on a whim and it just doesnt loving do anything unless I manually call the destructor, even with the author's code, in either Visual C++ or Bloodshed. It compiles and runs without so much as a warning, and won't compile at all if I comment out the destructor. But no matter what I do, I can't get output from within the destructor to show up unless I call it myself. Is this a normal thing? Or am I actually possibly doing something wrong? For reference, it's based on bag3.h/node1.h from here: http://www.cs.colorado.edu/~main/chapter5/. e: its awesome because I can post from school but edit doesnt work so I hit post by accident with a trailing sentence on the end here yeaahh poverty goat fucked around with this message at 23:30 on Oct 26, 2010 |
# ? Oct 26, 2010 19:50 |
|
You're at least expecting something wrong. Since this is a linked list, my guess is that you've got a lot of heap-allocated objects and you're not actually deleting them, in which case you've got a memory leak. Although the API in that header kindof suggests that deleting nodes is the responsibility of the callers, except possibility after list_clear.
|
# ? Oct 26, 2010 20:19 |
|
If you don't get output from a print statement in a destructor when you it's called on object destruction, but do when you call it directly... yeah, I'd say the most likely reason is that your objects are not actually getting destroyed. That, or you forgot to flush the output stream . You'll want to post the actual code you wrote. Being able to see what you're trying to reason about has a tendency to make debugging easier.
|
# ? Oct 26, 2010 20:44 |
|
gggiiimmmppp posted:I'm working on a standard dynamic linked list assignment for a 200 level computer science class. We had a question on the last test to the effect of "if these cout << ... lines were added to the different constructors, destructor, and assignment operator, what would the output be for these code snippets?" Basically, a roundabout way of asking which bit of code you're dealing with on the back end to do various tasks. Is your destructor declared as virtual? If not, add that and see if it fixes the problem.
|
# ? Oct 26, 2010 20:45 |
|
I think this is the right thread to put this in: I'm trying to get a web service up and running, just to learn J2EE stuff, and it seems like the world is trying to stop me from doing this. First, tomcat won't run because of an error that no one seems to know about ([408 prunsrv.c] [error] The system cannot find the file specified.), then I tried the Sun Java System Application Server, and found that it simply wouldn't start any of the domains I created for it. So I'm going a little crazy here just trying to set up a simple drat server. So I guess I'm wondering if anyone has a very simple, very step-by-step tutorial to these things that takes into the account that something might go wrong.
|
# ? Oct 27, 2010 05:26 |
|
God Exists. posted:Is there a website where you can input a hex color code and it tells you what color it is? Not that I know of, but I imagine it would be easy to make one using the data from XKCD's color survey experiment. It might be a good project for learning to use Google AppEngine.
|
# ? Oct 27, 2010 05:51 |
|
God Exists. posted:Is there a website where you can input a hex color code and it tells you what color it is? http://www.somacon.com/p142.php may have more colors listed than the one csammis posted - hosed if I'm gonna sit and count them.
|
# ? Oct 27, 2010 17:02 |
|
I have a project coming up which is going to need some code to read data out of a hardware buffer at least once every 4 milliseconds to prevent overflow. I'm a bit nervous since this will be running on an older XP machine with a single-core CPU. In my brief investigations (totally new to this kind of tight timing) I've read that the XP thread manager switches between threads with a quantum of 10 to 15 mS depending on hardware configuration. Does this imply that I'm totally hosed in trying to get guaranteed 4mS timing, or is that just a worst-case scenario that means any given thread can run up to 10 or 15 mS before switching. If 10 mS is just an upper bound, is there anything I can do to lower it? I also assume I'll want to run my own process as high priority and make sure as little other crap as possible is running at the same time. Are there any guides to stripping down an XP system to a minimum? Thanks.
|
# ? Oct 28, 2010 00:55 |
|
PDP-1 posted:I have a project coming up which is going to need some code to read data out of a hardware buffer at least once every 4 milliseconds to prevent overflow. I'm a bit nervous since this will be running on an older XP machine with a single-core CPU. 4ms is shorter than the average disk read latency for even the fastest mechanical drive. In other words, doing your task is flat out impossible in userland. You need something kernel level to read the buffer, and I think DPCs are what you're looking for.
|
# ? Oct 28, 2010 03:48 |
|
Thanks for the reply. I think I panicked a bit early when I read that the hardware system was going to be sending bursts of 1 megabyte/sec into a 4k buffer. In reading a bit more of the documentation it looks like the interface card sets up a DMA channel that handles the data flow without my program having to be directly involved. That makes a lot more sense, but was non-obvious given that the documentation for this thing is horrible and scattered in a half-dozen random pdf files on the manufacturer's website. I'd still be interested in any guides as to what stuff I can rip out of an XP system to ensure that there are as few background processes running as possible, if anyone knows of such a thing.
|
# ? Oct 28, 2010 14:06 |
|
I don't know of any guides offhand, but basically what you want is to recreate TinyXP, using nLite. Even without a guide though, it's easy to figure out a lot of things that can be removed with nLite.
|
# ? Oct 28, 2010 16:08 |
|
I'm trying to do some simple winsock2 stuff. If you want to make fun of me for winsock2 keep it to yourself. The Microsoft sample code says to call send() shutdown(..., SD_SEND) and then go about recv()'ing data. So this works just fine in the debugger, but when I have it run normally the recv() doesn't get any data, returns 0. It only seems to work if there's some time that passes between the send() and the shutdown() call. Otherwise recv immediately returns 0 with no data returned. I'd rather not try any hacks that force the thing to wait one second between send and shutdown. Anybody have a clue?
|
# ? Oct 28, 2010 20:04 |
|
Maybe I'll get more responses to the above question if I post some code: http://pastebin.com/N1vb2fU0 Here's just the relevant part: code:
|
# ? Oct 29, 2010 22:59 |
|
You could try setting SO_SNDBUF to 0.
|
# ? Oct 30, 2010 03:15 |
|
So I'm using mplayer in my python library for getting info like video resolution and bitrate. This library will be part of an app that I'm not the main developer on. As a mainly Windows guy, I'm planning on just including the Win32 mplayer binary and various other files required by the mplayer license, but I'm not positive of what the right way to do this on linux is. Is it considered "bad" to do this? The main developer of the app really doesn't want people to have to go installing dependencies on their own.
|
# ? Oct 30, 2010 04:02 |
|
The right way to do it on linux is to package it and list the dependency in the package, and then let the package manager go install dependencies. Distributing binaries from other projects instead of depending on having shared libraries installed is considered more than a little "bad".
|
# ? Oct 30, 2010 07:25 |
|
Anyone know of a program I can use to see if a certain string could be generated by a given context-free grammar? I don't need to parse anything, I just need to know whether it matches or not.
|
# ? Oct 31, 2010 21:46 |
|
I don't know of any program specifically for this purpose, but you should be able to whack the CFG into any parser generator or parser combinator of your choice, then feed the string to it and see if it accepts.
|
# ? Oct 31, 2010 22:05 |
|
Jonnty posted:Anyone know of a program I can use to see if a certain string could be generated by a given context-free grammar? I don't need to parse anything, I just need to know whether it matches or not. I am not 100% sure (correct me if I'm wrong), but I think you just asked a question that is equivalent to "The halting problem". The only way to determine if it matches is to run it.
|
# ? Oct 31, 2010 22:06 |
|
A parser is what you want.
|
# ? Oct 31, 2010 22:06 |
|
litghost posted:I am not 100% sure (correct me if I'm wrong), but I think you just asked a question that is equivalent to "The halting problem". The only way to determine if it matches is to run it. Since that is, in fact, a halting algorithm which correctly decides the problem, ACFG is decidable. The formalism does not give bonus points for figuring it out by inspection.
|
# ? Nov 1, 2010 00:02 |
|
I'd like to learn how to write programs like Amplitube that models guitar effects and amplifiers. Does anyone know of any good resources/books on where to begin?
|
# ? Nov 1, 2010 02:36 |
|
Does anyone have any suggestions for ways/methods of automating numbering in sequence? I'm fairly new to coding so I'm a bit lost as to how to proceed. Basically, I have a large document of several thousand lines in XML that have <l n="x"> in front of each. Each x needs to be changed to the next number in sequence, so <l n="1">, <l n="2"> on the next line, etc etc all the way through. What's the simplest/fastest way of doing this?
|
# ? Nov 1, 2010 04:05 |
|
Thrombosis posted:Does anyone have any suggestions for ways/methods of automating numbering in sequence? I'm fairly new to coding so I'm a bit lost as to how to proceed. Basically, I have a large document of several thousand lines in XML that have <l n="x"> in front of each. Each x needs to be changed to the next number in sequence, so <l n="1">, <l n="2"> on the next line, etc etc all the way through. code:
|
# ? Nov 1, 2010 04:23 |
|
Jonnty posted:Anyone know of a program I can use to see if a certain string could be generated by a given context-free grammar? I don't need to parse anything, I just need to know whether it matches or not. Well you need to build a recognizer, which normally involves writing a parser, but sometimes you can skip the construction of the parse trees, but in a sense, you're still having to parse the string, even if you're not producing a parse tree, you still need to keep track of (some) resolutions. Dealing with *any* context-free grammar will require generalized parsing. GLR (edit: I was being confused about sub optimal behavious on nullable rules, but yeah GLR is actually pretty good but most of them are parser-generators) Anyway, i'd recommend earley parsing for a number of reasons: It works on all context free grammars in cubic time, but works in linear time for many simpler grammars. And if you're that way inclined there are ways to make it linear time for a crazy amount of grammars (lr-regular) (see the marpa parser...). Earley parsing doesn't *necessarily* require any preprocessing or grammar re-writing, so many implementations are parsing libraries rather than parser-generators. It doesn't build any parse trees until it has read in the entire file, so you should be able to eliminate this step if you need to. There should be an Earley Parser written in your language of choice, although I would be wary as many implementations are buggy (as the original paper has a few flaws) (If you want to write it yourself (for some reason) go and get 'parsing techniques 2nd ed', or use this version of the parser: Graham, S. L., Harrison, M. A., and Ruzzo, W. L. An improved context-free recognizer. ACM Trans. Prog. Lang. Syst., 2(3):415–462, July 1980) ToxicFrog posted:I don't know of any program specifically for this purpose, but you should be able to whack the CFG into any parser generator or parser combinator of your choice, then feed the string to it and see if it accepts. Except most parsers/combinators do not support arbitrary context-free grammars, without some heavy re-writing. tef fucked around with this message at 06:24 on Nov 1, 2010 |
# ? Nov 1, 2010 05:49 |
|
So, I'm writing quicksort in assembly and I have my partitioning done. My problem comes in actually performing the recursive calls. http://www.pastebin.ca/1978570 Looking specifically at 54-64. As far as I can tell, the rest of the code is correct. Anybody want to explain to me how to make this recurse correctly ? FamDav fucked around with this message at 11:22 on Nov 1, 2010 |
# ? Nov 1, 2010 10:54 |
|
Your prologue/epilogue assume that the caller pops the arguments, but your calls assume the callee pops the arguments.
|
# ? Nov 1, 2010 21:24 |
|
This will probably be an answer I should have figured out, but Google used to parse literal strings, and now it just guesses what you meant. I want to search for things like "ADD.B" or "(car (cdr" and it never works anymore. I couldn't find anything in the Google documentation, and I figure this thread would be full of people trying to search Google for function references. It used to handle logic too, now I can't seem to search for -- say -- "Barney" NOT "Dinosaur" either.
|
# ? Nov 2, 2010 02:04 |
|
After I run some git commands, I can't get back to my prompt. I've tried Ctrl+C+C, but that won't do it. What's the command in git (Windows Git Bash)?
|
# ? Nov 2, 2010 16:04 |
|
vote_no posted:This will probably be an answer I should have figured out, but Google used to parse literal strings, and now it just guesses what you meant. I want to search for things like "ADD.B" or "(car (cdr" and it never works anymore. I couldn't find anything in the Google documentation, and I figure this thread would be full of people trying to search Google for function references. It used to handle logic too, now I can't seem to search for -- say -- "Barney" NOT "Dinosaur" either. For NOT you can use -, as in "Barney" -Dinosaur For the exact strings, it looks like it tends to ignore special characters, which is annoying.
|
# ? Nov 2, 2010 16:14 |
|
I have a question about XML validation. I'm playing with Schemas with some success, but I'm wondering--do people actually use them? In this case I'm working in C# and finding the output to be a little vague. For example, I have noted that one of the elements needs to occur at most once. If it shows up twice, the error I get is pretty much "I wasn't expecting this element that has a perfectly legal name. I was expecting something else." Is there anything more specific it could do about it? Otherwise I expect users to submit crap XML, get a vague error, and come running to me. I guess at least now I'll now it's an XML problem rather than having my code make bad assumptions and try to run with it. It did also reduce what would be 5 pages of code for checking stuff into a one page XML file. Assuming Schemas are worth using, I have a question about denoting groups. I know about xs:sequence and xs:choice, but I wonder if there's something that marks a group of stuff that can come in any order. A sequence requires elements to appear in the given order, and a choice seems to mean only 1 of the many is available. I have some elements that conceptually have no real reason to be one before the other, so I wanted to keep it that way in the validator.
|
# ? Nov 2, 2010 16:48 |
|
ufarn posted:After I run some git commands, I can't get back to my prompt. What commands? Are you sure you aren't in an editor that it's waiting for you to exit or something? Assuming you're not... If you're in the msys shell, ctrl-C is interrupt and ctrl-D is EOF. If neither of those work ctrl-Z should background the current process and give you the shell back. If nothing produces any output it's possible you've stopped the terminal itself by pressing ctrl-S at some point - try ctrl-Q to start it again. If you're in windows cmd.exe and are just using git from there, ctrl-C is still interrupt and ctrl-Z <enter> is EOF and I have no suggestions beyond that.
|
# ? Nov 2, 2010 17:06 |
|
HappyHippo posted:For NOT you can use -, as in "Barney" -Dinosaur It's actually especially annoying, since it ignores nearly all punctuation and symbols. So searching for "test@thing.com" seems to be the same as "test thing com". The problem is that many of these symbols used to be/are quite contextually useful for reducing search confusion. Wish there was a string literal style search command, though I don't even know if they store/process non-alpha characters any more.
|
# ? Nov 2, 2010 19:32 |
|
This is sometimes useful for codingy search queries http://www.google.com/codesearch
|
# ? Nov 2, 2010 20:23 |
|
I've been interested in learning to code for a fair while now, but it's only recently that I've gotten off of my rear end and tried something out. Currently, that means loving around and making .bat files, which I understand is something a mentally challenged 6 year old could do. I've made the requisite helloworld.bat, but something I tried today struck me as interesting. I copied a basic Conditional Shutdown code, which I kind of understand, but I have a few questions as to how things generally work. BEFORE code:
code:
code:
Second, I want to learn some ways to make this thing more assholeish. Nothing approaching a virus or worm, so no deleting any files. Just more of an annoyance. Third, I know that what I'm doing now is about as basic as you can get. What language should I learn first, and what are the key concepts that I should understand before I dive headlong into this? TL;DR Some idiot is screwing around with .bat files and wants to know more
|
# ? Nov 3, 2010 03:35 |
|
|
# ? May 22, 2024 22:14 |
|
Eox posted:
shutdown is just a dos command like "dir" or "copy awesomefile toawesomeplace". Type it on the commandline. code:
When you get to the shutdown line, the %sec% and %msg% parts recall those parts from memory. Eox posted:Third, I know that what I'm doing now is about as basic as you can get. What language should I learn first, and what are the key concepts that I should understand before I dive headlong into this? Python is a good choice. There's a megathread for it, and lots of good beginner-quality tutorials.
|
# ? Nov 3, 2010 03:48 |