Wikipedia:Reference desk/Archives/Computing/2009 December 8

= December 8 =

Check this code
Not homework, just asking for some suggestions in this test case.

-- penubag  (talk) 00:40, 8 December 2009 (UTC)


 * I can't help you directly, but I can tell you that any code-related questions posted to Stackoverflow.com get answered in less than 10 minutes on average, and sometimes in under a minute. Much, much more handy than using the Wikipedia Computing RefDesk (not meant as a slight to the fine folks here at all!) 218.25.32.210 (talk) 01:05, 8 December 2009 (UTC)


 * Well, if you expect it to print "1hi" - then it's working! If you expected "2hi" then you have a bug.  The problem is that 'add' is being passed a copy of the structure - is incrementing that copy - then throwing it away.  So it's a copy of newname.x that is incremented - not the 'original' that you're printing out.  If you need to fix that - then you need to pass the address of the structure rather than the structure itself.

int add(struct name *newname) {   newname->x = newname->x+1; return newname->x; }


 * (and you'd call it with "add(&newname);")


 * Most C programmers would probably have saved a line of code and written your version of "add" like this:

int add(struct name newname) {   return ++newname.x;  }


 * SteveBaker (talk) 04:29, 8 December 2009 (UTC)


 * Another option, only requiring the addition of a single character, is to make the add function pass-by-reference instead of pass-by-value. Change it to  .  Then, the struct passed in won't be copied. --  k a i n a w &trade; 05:14, 8 December 2009 (UTC)
 * I think it's C, not C++. -- BenRG (talk) 07:12, 8 December 2009 (UTC)


 * I copied/pasted into an editor and I can see it now. The highlighting here makes #include statements very light green on a white background, so I can't actually read it.  I can only see that it is an #include or a #define.  I have to move it to an editor to get rid of the colors to make it visible - or work on figuring out what CSS I need to beat up to get rid of those colors in code. --  k a i n a w &trade; 13:34, 8 December 2009 (UTC)
 * (The clue that made me think it was old-school C was saying "struct name" rather than just "name" in the parameter declaration for the 'add' function - nobody in their right mind does that in C++!) SteveBaker (talk) 19:26, 8 December 2009 (UTC)


 * You obviously don't teach C++ classes. It is rather amazing what students put in so-called C++ code.  Ever seen a class defined inside a struct inside main?  What is amazing is that some students actually get this stuff to compile without errors or warnings.  I, then, have to pick through the code to try and figure out what they are doing and explain why it doesn't work. --  k a i n a w &trade; 21:32, 8 December 2009 (UTC)


 * No - I certainly don't teach C++ classes! The trouble with C++ is that there are an awful lot of odd things that you are allowed to do (declaring classes inside other classes and classes inside functions being some of the milder ones) that you really shouldn't do.  The difficulty is to convey to students that doing those things will make you very unpopular with co-workers in the future!  When we recruit new programmers - one of the interview questions we ask is "How familiar are you with C++ - on a scale of one to ten?" - nearly everyone answers 7 or 8.  That's a good answer because people who are 9's or 10's are really dangerous in a team environment!  They write code that mere mortal 7's and 8's can't understand - and that's dumb because there is almost never any real advantage in performance in the incomprehensible stuff they produce.  Keep it simple! SteveBaker (talk) 03:14, 9 December 2009 (UTC)


 * The way I word it is like: You can put functions inside your structs, but that isn't what a struct is for. So, if you do, the other programmers will laugh at you - hopefully just behind your back. That isn't what they usually remember most.  I think the phrase I use that they all remember most is "Nobody can play with your privates except your friends." --  k a i n a w &trade; 06:59, 9 December 2009 (UTC)

Issue with website: JavaScript/OS detection needed?
So I made this script to pop open a new window with a fixed size in JavaScript. It works fine except I'm finding that in Windows XP it's not opening the window "wide enough". It was tested on a Vista PC which the size is appropriate for. I have one of two options in my mind.

1) Find out why on these particular XP machines it's not opening as wide, so all the content can be seen.

2) Put in some OS detection, and if the user has Windows XP, open the window wider.

For #2, I have this: JavaScript OS Detection

Can someone tell me why Windows XP opens the window differently? or help me modify the JavaScript I linked so that it detects specifically Windows XP?

Thanks!

137.81.112.176 (talk) 06:14, 8 December 2009 (UTC)

If it helps, this is the kind of code I am using:

137.81.112.176 (talk) 06:46, 8 December 2009 (UTC)

I don't think it has anything to do with the operating system -- just the browser. Windows Vista comes with Internet Explorer 7 and Windows XP comes with Internet Explorer 6. My XP computer has Internet Explorer 8 installed and when it tries to open a window 200 pixels wide, it enlarges the window automatically to 250 px. I tested the same code in an XP virtual machine with IE 6 and it opens with a width of 200 px. So, the XP machine is performing the operation correctly. It is the Vista machine that is performing it incorrectly. So, I would not try to detect the operating system -- just the browser. Firefox 3.5 also opens the window with the correct width. You can measure the width of a window using the free Screen Calipers tool. If 200 px is too narrow, then increase the width.

--Drknkn (talk) 07:56, 8 December 2009 (UTC)


 * The size difference is probably because the specified "width" parameter represents the renderable area, but does not include window decorations like borders and toolbars. Between Windows 2000, Windows XP's Luna (theme), and Windows Vista's Aero, the exterior border style and size have significantly changed.  Is this the root cause of the different apparent window sizes?  Nimur (talk) 08:03, 8 December 2009 (UTC)
 * It's a browser issue, not an OS issue.--Drknkn (talk) 08:12, 8 December 2009 (UTC)

Nimur:

I don't think so. Looking at a screenshot from a friend of the window opened in windows XP, there is no major difference in width of the "decorations" of the borders etc. However, I was reading something about the java window.open method, and it says that varying versions of IE in different operating systems have different required minimum widths and heights. Maybe this causes the difference, but im not sure... as I am more a "see and mimic" JavaScript user, I don't understand the more complicated issues such as this.

Regardless of the cause, perhaps the code provided by Drknkn will help.

If it makes any difference, I will note that on my Vista, I have the old classic look set up (not aero), and it came like this out of the box I believe. However the XP screenshots I have show XP with their standard giant blue titlebars and the red X's and whatnot. However, as I already stated, I can see how this would affect the height, but not the width.

Drknkn:

If this is browser related, please clarify what the issue is? and should i have the script look for the "funny acting browser" instead (likely the xp related versions of IE)?

To all:

Any further thoughts? Thanks!!

137.81.112.176 (talk) 08:22, 8 December 2009 (UTC)


 * Yes. I changed the code above to look for the browser instead of the OS. Try it now.--Drknkn (talk) 08:23, 8 December 2009 (UTC)

If its of help i found that XP seems to open the window 50 pixels "too thin". Drknkn, question. I use IE7 here on vista, so should the exclusion really be for my browser? Im just curious and again i state that i dont know a ton about this issue, but it would seem to me that XP would use an earlier version than i have? it displays fine in my browser. Do we need a browser/OS combo? Sorry if my knowledge is limited! :)

137.81.112.176 (talk) 08:30, 8 December 2009 (UTC)


 * You're fine. :) I also added some comments above the code. It looks like Internet Explorer 6 (the version that comes with Windows XP) opens a narrower window than IE 7 or 8. Thus, if you're using IE 6, and the window is sized to 200 px, you will see a 200 px window. If you're using IE 7 or 8, you will see a 250 px window. So, the code above compensates by opening a narrower window if it detects IE 7 or 8. If it detects any other browser (e.g., IE 6, Firefox, etc.) it opens a wider window. To find out which version of IE you're using, press ALT + H and select "About Internet Explorer."--Drknkn (talk) 08:45, 8 December 2009 (UTC)

I think i am beginning to understand the situation. There are a couple pages where i have this code implimented (different pages/widths), so i will have a look at this on an XP pc and try implementing your code. Hopefully ill get back soon to mark this as resolved if it works out. Hopefully i can continue with you if it doesnt work Drknkn? Thanks alot for your patience and skillful explaination of the problem! :)

137.81.112.176 (talk) 08:54, 8 December 2009 (UTC)


 * Not a problem. Sounds great! Keep me posted.--Drknkn (talk) 09:02, 8 December 2009 (UTC)

Thanks to all that posted to help on this problem. I am happy to let you know that i found a laptop with IE6 which had the issue. I used the code supplied by Drknkn and it solved the issue completely! Thanks a ton!

137.81.112.176 (talk) 09:34, 8 December 2009 (UTC)
 * For this kind of testing, you can get free Virtual PC images of various versions of IE here. --Sean 13:59, 8 December 2009 (UTC)

IRC save
Is there a way I can log or save the chat in an IRC channel for the times I'm offline? For example, I need to reinstall my operating system but I don't want to miss any of the conversation in an IRC channel. How could I do this? —Preceding unsigned comment added by 82.44.55.75 (talk) 11:58, 8 December 2009 (UTC)
 * With the clients I use such as mIRC I cant copy and paste so I dont think so.Accdude92 (talk to me!) (sign) 14:30, 8 December 2009 (UTC)
 * mIRC does allow you to copy and paste - you need to hold down the mouse button to keep the selection highlighted as you hit the CTRL-C combination. Nimur (talk) 17:36, 8 December 2009 (UTC)
 * Its possible in a variety of ways. You could load an irc client onto a server and use a shell account and have that connect to irc 24/7, you can then tunnel in yourself to control the client or read the logs. You could also use a BNC or put an eggdrop bot onto a server and have it log 24/7. Nanonic (talk) 14:38, 8 December 2009 (UTC)
 * Yes, the normal approach to logging an IRC channel is to set up a bot, e.g. an Eggdrop. If you don't operate the channel, you may want to get permission to log it; different communities are more sensitive to these sorts of things.  Nimur (talk) 17:38, 8 December 2009 (UTC)


 * Hmmm! I actually have a bot hosted 24/7 that i could use to help this person log their room, but is it possible to exchange information safely here, and within standards? Sorry if this post is too far off topic, but im just trying to help! :)137.81.112.176 (talk) 19:08, 8 December 2009 (UTC)

Cookies
How did they come up with that name? Its not like their similar to real cookies!Accdude92 (talk to me!) (sign) 14:24, 8 December 2009 (UTC)


 * Magic cookie says "The name "cookie" comes from a comparison to an unopened fortune cookie, because of the hidden information inside" (although I'd prefer a more reliable source than the one it cites for that fact). -- Finlay McWalter • Talk 14:27, 8 December 2009 (UTC)
 * I would have thought that a webpage takes a bite out of a cookie on your hard drive and leaves a bit of its saliva (think DNA) behind, but then again, I've had too much wine tonight...Sandman30s (talk) 19:12, 8 December 2009 (UTC)


 * I'm not sure I buy the fortune cookie explanation - although it is one that you hear a lot. The Jargon File (which is an ancient and revered source for software slang) says that some of the very early hackers were obsessed with watching the Andy Williams show and liked the "Cookie Bear" sketch.  A guy in a bear suit tried all sorts of tricks to get a cookie out of Williams. The sketches would always end with Williams shrieking: ‘No cookies! Not now, not ever...NEVER!!!’ And the bear would fall down.  So "getting a cookie" became a kind of meme for getting something back from a piece of software that you had to pursuade to give it to you.  So, for example if you open a file in C/C++, the 'fopen' routine gives you back a "cookie" only if you give it a proper filename and a legal read/write mode flag and the file has the right permissions and the drive is mounted, etc - otherwise you don't get a cookie, you get nothing - and (if you aren't very careful) your program crashes, just like the bear falling down.  Other kinds of cookie-dispensers might make it very hard indeed for you to get your cookie - requiring you to go to the same lengths as the guy in the bear suit.  A cookie in the context of the 'fopen' function is a pointer to a 'FILE' structure that you really don't do anything with - except to give it back to the I/O library.  This connotation - of a small chunk of data that you have to hold on to - but can gain no useful information from looking inside - gradually became the more common meaning for the word.  That's pretty much the definition of an internet "cookie".  "Magic cookie" likely comes from the idea that anything that you can't readily understand must be "Magic".  So the cookie that Wikipedia gives you to let you access the site without having to keep logging in every time is "magic" because nobody really ever looks inside to see what it actually says.  SteveBaker (talk) 19:22, 8 December 2009 (UTC)
 * I don't see that etymology in the Jargon File's entries for "cookie" or "magic cookie"—there is an entry for "cookie bear" but it seems to be unrelated. And that etymology seem implausible because the defining feature of a magic cookie is that it's opaque, not that it's hard to get. A token is hard to get. -- BenRG (talk) 21:00, 8 December 2009 (UTC)
 * The term (like so many that we use) has slowly mutated over the intervening 30 or so years. I've been using computers for almost 40 years - and I've seen the meaning gradually drift. The Cookie Bear entry in the Jargon file explains the original association of cookies - it's a bit sketchy on the intervening stuff. SteveBaker (talk) 03:05, 9 December 2009 (UTC)
 * There's nothing in the Jargon File's definition of "cookie bear" or "cookie monster" to suggest that they are related to "cookie" in the browser cookie sense. The stated meanings are completely unrelated, and the cookie bear/monster entries don't link to [magic] cookie nor vice versa. Did you actually observe the origin of the modern term "cookie" in the cookie bear sketch, or did you guess a connection after reading about the cookie bear sketch in the Jargon File? If the latter, there's no reason to believe the connection is real. Word origin stories guessed in this way are often wrong. Wikipedia even has an article about it. -- BenRG (talk) 06:33, 9 December 2009 (UTC)


 * In my mind, i always imagined the server as an actual server, and with regards to cookies, this little conversation plays out my head:
 * Server: Greetings, and welcome to [random web site], what can I do for you?
 * Client: Hmm, let me see... Just give me index.html
 * Server: Certainly, sir
 * Server walks away and comes back
 * Server: Here is your index.html.
 * Client: Thanks!
 * Server: And would you like a little cookie with that?
 * Client: Don't mind if I do!
 * So, ok, it's not a perfect metaphor, but that's how I always imagined it. The main piece of content flying back and forth is the webpage itself, but on top of that there is a little something extra, a little cookie with your main meal. Belisarius (talk) 19:49, 8 December 2009 (UTC)


 * Similar to Stever Baker's note... My memory of "cookie" from the 70s was that it was the product of "cooking". Unlike the HTTP cookie which is used to store information, a cookie was something rather meaningless that you cooked up in your program to send to another program.  Then, when you asked for it back, you could verify that it was the one you sent.  At the time, "token" was already a very common term.  So, you couldn't say you were passing a token back and forth.  Also, a token had a meaning understood by everyone.  A cookie only had meaning to the original sender.  The current meaning of HTTP cookie - which is basically a content-based variable - has almost nothing to do with the old "magic cookies".  Now, I wonder if anyone uses magic cookies anymore.  It seems to me that it would be a rather dead practice by now since public-key encryption lets you know you got your original message back and it was sent/returned by the correct recipient. --  k a i n a w &trade; 06:30, 9 December 2009 (UTC)
 * To avoid ambiguity, Kerberos (protocol) calls this a "ticket" and it has a specific meaning within that protocol. Other software terms I've heard include "token", "key," or some context-specific data structure name.  "Cookie" has become so widely used in reference to its web server use that it's probably invalid to use in a more generic sense nowadays.  Nimur (talk) 14:39, 9 December 2009 (UTC)


 * There was a difference between a cookie and a ticket. The use of a cookie - back in prehistoric times - was that A would send a cookie to B.  B could look at it, but it was just nonsense.  Later, if A wanted to make sure B had come earlier, A would ask for the cookie back.  This is, obviously, a pathetic form of control.  Nothing keeps B from handing back an old cookie or handing back C's cookie.  A ticket is encoded with information for two or more computers.  In the most convoluted sense, B wants to talk to C, but C is controlled by A.  So, B talks to A and gets a ticket.  B can't read the ticket, but A and C can.  So, B gives the ticket to C and C reads it, accepting B.  You can see the difference is that the cookie is written/read by one computer and a ticket is written/read by multiple computers.  Of course, that difference means nothing now. --  k a i n a w &trade; 15:30, 9 December 2009 (UTC)

PHP IP logger
I have the following script which logs IP addresses, but it will repeat the same IP address over and over. How can I make it check to see if the IP address is already listed, and not make a new entry if it is? $logfile= 'log.html'; $IP = $_SERVER['REMOTE_ADDR']; $logdetails= .$_SERVER['REMOTE_ADDR'].; $fp = fopen($logfile, "a"); fwrite($fp, $logdetails); fwrite($fp, " "); fclose($fp);

I don't know coding, but you need to put something in their that stops the cycle.Accdude92 (talk to me!) (sign) 15:03, 8 December 2009 (UTC)


 * Easiest (but not necessarily the best or the fastest) way would be to load the entire log file into an array with file, then use array_search to see if the IP already exists, and if so, not record anything, and if not, write to the file.
 * If you are interested in PHP-based browsing statistics, I might also point you in the direction of BBClone, which is pretty easy to use. --Mr.98 (talk) 17:46, 8 December 2009 (UTC)
 * Thank you, but I have absolutely no grasp of arrays or PHP beyond the very most basic level. I have no idea how to write an array. Could you explain how to make one? Thank you :) —Preceding unsigned comment added by 82.44.55.75 (talk) 18:22, 8 December 2009 (UTC)


 * The official PHP.net array documentation is the place to start. If you really have no direction at all, the Getting Started Tutorial will point you along the right path.  Be aware that storing huge volumes of data in memory (i.e. storing your entire log in a PHP array) is likely to function only for very small websites.  If you get large volumes of traffic, you may need a more advanced system, like a relational database or even a simple flat file log.  These are scalability and performance issues, though - for "testing purposes" of a prototype logging tool, an array will work.  Nimur (talk) 18:37, 8 December 2009 (UTC)


 * Here is what I meant before. As Nimur points out, it is really pretty inadequate unless you are just playing around, because as the data set grows, it will take more and more effort to check it for existing data. (A clever and abstract programming problem for you, if you are learning, would be to try and figure out ways you could avoid that problem—it is not inherent to the problem of growing data, just the method of looking it up.) If you want something more serious, I would recommend using existing logging software (like BBClone), rather than trying to do it yourself from scratch... (or looking into how to write to a database).


 * I had to rewrite the other code slightly, adding a newline after each IP (that's the \n), as otherwise it won't get split into separate likes by file. I have not tested the above code. --Mr.98 (talk) 19:45, 8 December 2009 (UTC)


 * That code didn't seem to work, but thank you for trying. With some more googling and trial and error, I managed to hack together a script from several different scripts I found and it seems to be working. Again, thank you for the help

Are 30 frames per second of interlaced fields and "60i" the same thing?
From 24p: "At standard analog NTSC video rates (30/1.001 frames per second) a full "interlaced" frame, unlike a progressive frame, is nearly 1/30th of a second and is composed of two separate "fields," each field nearly 1/60 second."

I have an older Sony Handycam which I'm pretty sure is NTSC, as I've read that that's standard in North America, but I can't find documentation that comes out and says what the frame rate is for my model. The above referenced article has information about converting 60i to 24p using VirtualDub, which I'm interested in trying to give my video a film-like aesthetic. 20.137.18.50 (talk) 15:16, 8 December 2009 (UTC)


 * I don't think "60i" is a term anyone uses commonly used term, because it isn't the name of a video format (including the mention specification of screen resolution, for example). If your older Handycam was sold in North America, then it's surely an NTSC handicam, yes; for all the discussion of frames and fields and the frame rate, see the "Technical Details" section of NTSC if you haven't read it already.  Comet Tuttle (talk) 17:37, 8 December 2009 (UTC)


 * By the way, the video format names that you typically read about, like 720p and 1080i, are named for the number of vertical scan lines and then an "i" for "interlaced" and a "p" for "progressive". Hence my disappointment that "24p" is being used as a name of a video format; "24p" refers to 24 full frames per second, progressive; but calling it "480p/24fps" or something would be much easier to read.  "24p" itself doesn't tell me enough about the format - is this 1080?  720?  480p?  Mr. Name Maker Upper Guy was sloppy when he came up with "24p".  Comet Tuttle (talk) 20:25, 8 December 2009 (UTC)
 * In the context of the question does the resolution really matter one bit? While it is naive to reduce the terminology so far that a video format is simply the FPS rate and the scan mode, if you are having a discussion about converting between 60 frame/sec interlaced video and 24 frame/sec noninterlaced video, who cares if it's 480 lines or 10,000 lines?  Anyway, about the question at hand, the issue of utmost importance is using a good deinterlacer since the reverse pulldown (pull up?) only stands a chance at improving the "aesthetic" of your film if you can avoid interlacing artifacts.  What your NTSC handycam has recorded are 60 fields a second, each field being on opposite scan lines from the one before it, and hence each field being only half the number of scan lines as the total screen.  It's a nightmare if your video has any great deal of motion, the interlacing is very hard to reconcile.  Also remember that storage and display systems that natively support 24p aren't all too common, so you may want to consider stopping when you get to 30 frame/sec deinterlaced video. --66.195.232.121 (talk) 20:40, 8 December 2009 (UTC)

Free tool to convert HTML forms to database queries?
I have html forms with 20 or more fields in each pages and I gotta design database for that so that people can store information using it. Got to use plain PHP and MySQL for that. It would be nice if there is a free tool that generates creates tables based on these forms. The tables and datatypes need not be perfect as there is room for improvement and i can later manually tweak it. It is just for quick and dirty work.If the tool generates update and select queries, that would be a plus too. May be iam expecting too much... please tell me, such a tool or script is available anywhere? —Preceding unsigned comment added by 131.220.95.28 (talk) 17:26, 8 December 2009 (UTC)


 * I don't know about a one-stop-shop that can do what you want (only because it sounds rather vague, yet very specific to your project), but there are plenty of free PHP MySQL classes that make life a lot easier in taking POST data and putting it into an appropriate table. (I will, because you don't seem to be planning to make this too open, forgo emphasizing how dangerous this kind of thing can be for your database, if not done very carefully.) --Mr.98 (talk) 17:43, 8 December 2009 (UTC)

Mac programs on Windows
Will Mac programs work on a Windows OS?Accdude92 (talk to me!) (sign) 17:56, 8 December 2009 (UTC)


 * Short answer: No.
 * Long answer: see Hackintosh. Which is not the same thing as a "Windows OS", really, but is really a question of "Can you install a Mac OS on non-Mac hardware?"
 * Sideways answer: Some programs that are on a Mac also exist in Windows forms. But programs compiled for the Mac will not work in Windows. --Mr.98 (talk) 18:01, 8 December 2009 (UTC)


 * (ec) No. The Mac has a range of proprietary APIs that are unique to it. Someone could implement them on Windows (contingent on patents) but no-one has. There is some software that can be compiled on Windows, Mac, and Linux, but that's a source level (rather than binary level) compatibility. -- Finlay McWalter • Talk 18:05, 8 December 2009 (UTC)


 * Having spent some time during the last year to make one of my research tools "cross-platform" to work on Mac, Windows, and Linux, I have to say that in my opinion, the Mac OS device driver model, programming style, and general contract between applications and operating systems is very different (despite claims that it is "Unix-like.") Though the APIs are different between Windows and Linux, there's usually a suitable equivalent replacement for every particular feature.  Trying to port code between Windows and Linux is often a matter of swapping out those GUI APIs and tweaking slight file-system details.  But trying to port to Mac OSX (from an originally "for Linux" code) was extraordinarily painful because of the fundamentally different way that OSX treats applications, shared libraries, and access to device drivers.  Take a look at "frameworks" - they're sort of a wacky combination of shared library, kernel module, device driver, and application.  For users, they are "great", "transparent," and nobody even knows they exist.  Installation procedures typically involve "Double click the Framework Icon."  When I saw this for the first time as a developer, and realized that I had to port code into a Mac Framework, I realized that this is absolutely not a Unix or a Linux (no matter what people claim about a "BSD kernel") - and it's certainly no Windows.  Moving the reverse direction, I think that the first question a Mac developer would have on seeing the Windows API might be, "where's Xcode"?  The challenges of porting source in this direction (from Mac to Windows) are huge - both technically and culturally, for the developer, who will need to learn entirely new programming paradigms.  Nimur (talk) 18:22, 8 December 2009 (UTC)
 * That very much depends. If you stick to POSIX or even supported UNIX calls, or if you are willing to use X11 instead of Aqua/CoreWhatever, most programs port from Linux and MacOS-X without any trouble. I've moved my theorem prover from Solaris to Linux to MacOS-X with minimal pain, and that little pain coming from non-compliant code in the first place. --Stephan Schulz (talk) 19:27, 8 December 2009 (UTC)
 * New code can be standards-compliant, but inherited code is whatever it is... anyway, the main trouble I had was with a hardware peripheral (an accelerator), so it's almost expected to be non-standard code. Nimur (talk) 19:46, 8 December 2009 (UTC)

Help with an SQL Query
It has been a while since I queried a database and that's why i am having some trouble. So help will be appreciated!

Suppose I have the following table, which has a list of people with the sports they play. Let's call the table 'Sports', e.g:

I wish to write a query that tells who are the people who play 'Soccer', 'Basketball', and 'Hockey' in the same time. For the above example,the query result should look like this:

As you can see, Bob and Mary show up in the results because they play the 3 sports simultaneously, while John doesn't because he only plays 2 sports out of the required 3. So how would the SQL query look like?

Thanks! Hia10 (talk) 19:09, 8 December 2009 (UTC)

--Drknkn (talk) 19:36, 8 December 2009 (UTC)

Thanks a lot! Nested queries are always tricky. Just one small clarification: What is PLAYER_T?

Hia10 (talk) 19:40, 8 December 2009 (UTC)


 * Whoops. That's short for "Player Table." Just replace all those with "Sports."--Drknkn (talk) 19:45, 8 December 2009 (UTC)

There is also a bit of a problem with your table design. It appears that the columns UniqueId and Name hold the same data - UniqueId being the Name encoded. I expected UniqueId to be a number which would serve as a primary key for the table, and be unique for each row, leaving Name as the thing unique for each person. If, on the other hand, UniqueId is intended to be the reliable identifier for the person, so you could have two different people named "bob" and tell them apart, I would expect this table to not hold Name, but only UniqueId and sport, and another table to exist to show which numbers map to which names. --203.202.43.54 (talk) 07:02, 10 December 2009 (UTC)

Reinstalling trial version
If you install one trial version in a separate partition and format this partition (including the OS), can you install it again and again? Or can the installation save a kind of cookie somewhere outside the partition?--Quest09 (talk) 20:49, 8 December 2009 (UTC)
 * Yes. Even trial software you have to register lets you do that (provided you use a different e-mail address each time). I use VMWare Workstation to install the software inside virtual machines, so I don't have to reboot into a new partition.--Drknkn (talk) 20:53, 8 December 2009 (UTC)
 * There's no way for the trial software to save information outside of the partition, other than, say, information on a web server (you could, for example, force a phone home, and check the IP address, or something like that). --Mr.98 (talk) 21:02, 8 December 2009 (UTC)
 * Short answer: Maybe. Long answer: Depending on the method used to secure the trial software (or lack of one), you could install it on any number of machines, or only one.  Some trial software phones to a server, some software puts a file or key on your computer, and some software just lets you use the trial as much as you want.  Without knowing the specifics of the software, this question can't be definitively answered.  In my experience though, most trial software can be installed on as many machines as you want (or as many partitions as you want). Caltsar (talk) 21:11, 8 December 2009 (UTC)

Travel + laptop purchase
Where can you buy a cheap laptop? I mean one of mainstream manufacturers - IBM, ASUS, Sony, Toshiba. I know that it is economically not worth it. However, if you want to travel anyway, you could travel to a place where you can buy a cheap laptop. if you are flexible, you'll also find a cheap flight. So, what is the place with the cheapest laptops? -81.47.159.223 (talk) 21:02, 8 December 2009 (UTC)


 * Are you limiting this to a specific country or are you willing to go to a curb-side cart in Thailand to buy a Soney or I8M laptop? -- k a i n a w &trade; 21:36, 8 December 2009 (UTC)


 * You don't say where you are traveling from, which is very important in answering this question because of the changes in the values in world currencies compared to each other. For example, the Xbox 360 has maintained its price in the European Union countries despite the slide in the value of the dollar over the last couple of years; so if you lived in the EU, the answer would be "America" and if you lived in America, the answer would either be "down the street" or "whichever American state is closest to you that does not charge sales tax &mdash; perhaps Oregon".  A Toshiba laptop from a Taiwanese street vendor may be cheap to a German but expensive to an American because of the currency exchange rate.  Because of this, to hazard a guess across the entire industry of laptops, if you are an American, I think the answer for you is "in America".  Comet Tuttle (talk) 21:48, 8 December 2009 (UTC)


 * You also want to be cautious about buying something like a laptop. There are simple things like the power adapter might not work with your electricity at home, the keyboard may not be in layout you are familiar with, the version of Windows/Mac OS installed  might be in a foreign language, etc.  A potentially major problem though is the scope of the warranty - many laptop manufacturers do not have a world wide warranty - if you buy cheap in Taiwan you might not get any warranty cover if you take it home to Europe.  After all Taiwanese purchaser might reasonably be expected to return it to the Taiwan service centre and deal only with that service centre (in Chinese!)  Astronaut (talk) 07:16, 9 December 2009 (UTC)
 * One other thing is you might get stung paying import duty if you bring it home. Astronaut (talk) 07:19, 9 December 2009 (UTC)


 * I believe it's safe to presume that the OP is in Málaga, Spain. --203.202.43.54 (talk) 07:09, 10 December 2009 (UTC)

Identifying or opening a mysterious file
I have a file, ebook.rar, that 7-zip cannot open. According to what I read on the .rar article, this might be because the format is older than what 7Zip can cope with. I have checked the file with the DROID file checker and it says it is a rar file - perhaps it is merely checking the file extension. I have tried to use trid, a freeware file identifer, but it just briefly opens a DOS box and then immediately closes it again. Anyone know what I should do next please? I scanned the file with MalwareBytes and nothing was found. 78.149.206.42 (talk) 21:43, 8 December 2009 (UTC)


 * Download and install WinRAR, which is the originator of the .rar file format. Comet Tuttle (talk) 21:49, 8 December 2009 (UTC)


 * You can also get the command line unrar for Windows which doesn't have a time bomb. From a DOS window: "unrar l ebook.rar" to list files, "unrar x ebook.rar" to extract, just "unrar" for help. 88.112.56.9 (talk) 21:54, 8 December 2009 (UTC)

Winrar is "trial" software. I did instal it, it said "The archive is either in unknown format or damaged." I think unrar would give similar results. I suspect the file extension is wrong. Can anyone tell me how to use trid? Thanks 78.149.206.42 (talk) 22:02, 8 December 2009 (UTC)


 * The TrID article points to a GUI version here &mdash; that's probably easier to use than the command line version? Comet Tuttle (talk) 22:32, 8 December 2009 (UTC)


 * I've just pulled a (valid) rar file into a text editor. The first 3 bytes in the file were "Rar".  Seeing that in your file would eliminate questions about the format of the file.  Astronaut (talk) 07:21, 9 December 2009 (UTC)

I could not get the trid gui version to work - I think it needs some data file to be loaded. When I tried to open the mystery file with Notepad or Ted then nothing seemed to happen, nothing was loaded. I've just opened the file with HxD hex editor, and it consists entirely of lower-case letters only, plus a few 3s or 4s. The file starts "sdkfaasdfhiasdfu....." and ends "......erglqergäöergmopeirgnerg". Just glancing at the beginning of it I noticed that this sequence: "uiq34nrfjklqwenflqwiufhqwelfjknqsdflkashdnfjkasndfuqefhlk1j3efn" is repeated near the start of the file. I have not looked closely at the remainder of the file. A quick look through some of it just shows more of the same. I guess that it is unlikely to be a compressed file, as I think such a file would not restrict itself to the alphabet. I wonder if its something that's been encoded to send as an email? 84.13.190.195 (talk) 12:11, 9 December 2009 (UTC)

Tinting icons in XP Explorer
In Windows XP, is there a way to tint the icons of the files in one of my folders in Explorer? I want to mark the files in some way, without renaming them, in order to keep track of which ones I'm finished with. I'm thinking of the old "Label" menu item from the Mac's System 7. Comet Tuttle (talk) 22:10, 8 December 2009 (UTC)


 * You can hide them. Right-click a file, select Properties and then check the Hidden checkbox. In the default setting, hidden files are hidden (no surprise!), but if you open Folder Options (on the Tools menu bar in an explorer window), you can change that. Then hidden files are just shown a bit shaded, and hence you can see the difference between two types of files in a folder: those that are hidden, and those that are not. --Andreas Rejbrand (talk) 22:26, 8 December 2009 (UTC)
 * (Or maybe it is actually an advantage that files that already have been processed are invisible. Then you know when you are done, when all files are processed: then no files are visible any more! --Andreas Rejbrand (talk) 22:28, 8 December 2009 (UTC))
 * Not an awful idea, I think I'll try it next time. Thanks; I never considered that!  Comet Tuttle (talk) 22:33, 8 December 2009 (UTC)
 * How about adding a folder image? This may only work if you view the icons in "thumbnail view" mode, as opposed to "list view" or "detailed view," but it allows for arbitrary customizability.  I find hidden files are irritating.  Alternatively, how about creating a subfolder, "./done/", mirroring the root directory's structure, but only including files when they are done?  Nimur (talk) 14:45, 9 December 2009 (UTC)


 * Thanks for the two suggestions &mdash; folder images only work on folders, it looks like, unfortunately; I want to mark the individual files. Another possibility might be for me to add a "Description" or one of those other metadata fields accessible through "Properties", if I can get the folder's Details view to show an extra field.  Comet Tuttle (talk) 22:58, 9 December 2009 (UTC)

Writing with Java in a privileged directory
Hello! When I distribute my java programs as .jars, I tell people to make a new directory in the Windows Program Files and put the file there. I recently found out that one of my programs, despite already being in the Program Files directory, can't load a log file stored in the same directory and resave it because the access is denied. Is there any way to give the program this ability and still keep it in the program files directory (without have to do run it as an admin every time)? Thank you!--el Aprel (facta-facienda) 23:46, 8 December 2009 (UTC)
 * You want your program to be able to modify files in Program Files (which is global, not user-specific) without elevated privileges? Wouldn't that imply that any normal user of the computer could replace the installed applications, tampering with their use by all other users, and possibly compromising the administrative account?  A program's presence in a directory does not confer it any status or access rights there.  Why not have the log file be per-user and put it in AppData (or whatever it's called these days)?  That way if more than one user runs it at the same time, there's no collision.  --Tardis (talk) 13:49, 9 December 2009 (UTC)
 * Thank you! I had a misunderstanding of how the Program Files directory worked. I figured that the programs would save some kind of log file or default-settings file in the same directory and be able to open and change it. It did not realize that all programs have a separate file outside the PF directory to save all their alterable files.--el Aprel (facta-facienda) 22:46, 9 December 2009 (UTC)
 * Glad to help. It should be said that what you first wanted is not impossible: you could create a non-privileged account that owned the program and its directory, and have the program run setuid (I believe Windows has an equivalent).  But you'd need a good reason to go to that much trouble if having it be per-user is sufficient.  --Tardis (talk) 22:59, 10 December 2009 (UTC)