Wikipedia:Reference desk/Archives/Computing/2009 April 21
Computing desk | ||
---|---|---|
< April 20 | << Mar | April | May >> | April 22 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
April 21
editProblem with Java applet
editI'm programming a java applet for a computer science class. The applet is basically a simplified version of a minesweeper game. The professor has removed several sections of code and commented the area with "//YOUR CODE HERE".... I have provided code which i think completes the requirements, but when i compile the code and run the container HTML, it has a few strange bugs.
Basically it says i've won as soon as i click any square. I've looked over the code many times and still can not find the problem. Additionally, Netbeans 6.5.1 shows no errors.
Can anyone enlighten me as to what the heck is wrong? Thanks! :)
137.81.112.205 (talk) 01:08, 21 April 2009 (UTC)
Additionally, i've looked at the method "allSafeSquaresAreExposed", since if there is a problem here, it would tell me ive won... but there seems to be no fault in this method.
137.81.112.205 (talk) 09:41, 21 April 2009 (UTC)
- Well, first let's figure out if the bug is in the "allSafeSquaresAreExposed" method. Remove your code and hard-code the method to always return a false. Does this stop the Java applet from ending immediately and saying you've won ? If so, this is where the problem is manifested. Note that this isn't necessarily where the problem originates, however. StuRat (talk) 18:15, 23 April 2009 (UTC)
- Here's the method in question:
public boolean allSafeSquaresAreExposed() { //YOUR CODE GOES HERE
for (int i=0;i<numSquares;i++) { for (int j=0;j<numSquares;j++) { if (hasMine[i][j] == false && isExposed[i][j] == false) { return false; }//end if }//end for j }//end for i return true;
//end of YOUR CODE GOES HERE }
- Looking at your code, I don't recognize the "i<numSquares" and "j<numSquares" syntax (but then again, I don't know Java). What does that do differently than just putting "numSquares" in both positions ? I'd also expect the number of squares in the i and j directions to be different, and thus have different variables, but apparently your program is only designed to handle square grids. StuRat (talk) 18:15, 23 April 2009 (UTC)
- [to StuRat] In C and derived languages, the syntax for a for loop is
for(init;test;step) body
. It just means "Execute init, which may declare a variable, then evaluate test some number of times. Each time it turns out true, execute body and then step. When it's false, stop.". The most common kind of for loop is over a fixed range (usually, in 0-based languages, 0 up to but not including n), so you writefor(int i=0;i<n;++i) ...
which evaluates its body with i=0, then 1, ... and stops (before executing the body again) when it becomes n. (++i
— or, in isolation,i++
— is equivalent toi=i+1
.) --Tardis (talk) 23:02, 24 April 2009 (UTC)
- [to StuRat] In C and derived languages, the syntax for a for loop is
Java Cipher
editI would like to make a new Java cipher that can be loaded with Cipher.getInstance("MyNewCipher"). I've looked at a lot of code examples and they all have something in common that doesn't make sense to me. See this example. If I copy that as is and attempt to compile it, I get an error because Cipher is not imported, but the class extends Cipher. If I import Cipher, I get an error because there is no constructor and Cipher does not have a null constructor. How is it that apparently everyone else in the world can extend Cipher without importing it and then magically get a null constructor out of it? -- kainaw™ 01:52, 21 April 2009 (UTC)
- The Cipher with the no-args constructor is com.sun.portal.kssl.Cipher which is not the same as javax.crypto.Cipher. Perhaps Bouncycastle source code has more relevant examples. I'm not sure but you may need to sign you cipher jar for it to work; see [1] and google. 88.112.62.225 (talk) 04:12, 21 April 2009 (UTC)
- I'll check bouncycastle. There's a lot of code there. I was hoping this would be as easy as adding a MessageDigest service. -- kainaw™ 20:43, 21 April 2009 (UTC)
Printing seamless tiles
editIs there a simple tool (Windows or Linux) that can print a page full of seamlessly tiled, err, seamless tiles (like the ones you can use as a tiled desktop background)? I tried searching on Google, but I can't for the life of me figure out how to search for that...tiled printing, which I assumed to be the term for that, is actually the name for rasterbation which is the opposite of what I want to do, and all other combinations of search terms I can think of give me tutorials on how to create seamless tiles (which I already know) and repositories of printable seamless textures (which is useful, but I still don't know how to print them). Thanks in advance, Ferkelparade π 02:38, 21 April 2009 (UTC)
- That sounds like a feature you might find in a word processor. For example, I have OpenOffice 2.3 Writer on my computer. I was able to go to Format, Page, Background, choose an image and set it to tile. --Bavi H (talk) 03:53, 21 April 2009 (UTC)
- ImageMagick can do everything. For this, try:
composite -tile tiled_image.jpg -size 1200x1600 xc:none tiled_output.pdf
- That will give you a 1200x1600 tiled image that you can print. You can twiddle the dimensions to suit your paper size. --Sean 12:49, 21 April 2009 (UTC)
- Thanks for both your suggestions. I've meanwhile figured out that there's a way to do that in Scribus but it's not that comfortable, so I wil definitely give ImageMagick a try. -- Ferkelparade π 19:17, 21 April 2009 (UTC)
- It's easy to do in GIMP too (that's a free paint program). Load up your image, right-click on it and select: "Filters/Map/Tile..." then enter the size you'd like the result to be (either as a percentage or in pixels) and hit "OK" then right-click again and do "File/SaveAs...". SteveBaker (talk) 20:26, 21 April 2009 (UTC)
Less number of Seeds
editDoes having less number of seeds during downloading a movie through a torrent affect the quality of film at the end?Most of films like Ali,Cinderella man etc...have come out awful after download.They had less number of seeds initially.In all these films for every few minute a scene get stuck for four to five seconds and jumps to the scene which is at the end of four seconds.It happens too frequently through out the film.How should I select good torrents? —Preceding unsigned comment added by 121.246.174.130 (talk) 05:00, 21 April 2009 (UTC)
- You are paying for the films you download, I hope? --Andreas Rejbrand (talk) 07:47, 21 April 2009 (UTC)
- No, a low number of seeds will only affect the download speed, or if there is not a distributed copy of the file among the seeds you will not be able to complete the download. The problem you describe, of the playback skipping throughout the film, is caused by an incomplete download. Where the film jumps it means you are missing small "chunks" of the download. You must go back to your torrent program and complete the download to view the film properly. 8I.24.07.715 talk 08:30, 21 April 2009 (UTC)
- While you shouldn't download illegally, this is still a very valid question. What the above poster said is right; if you get the file downloaded to 100%, it doesn't matter if there are 1000 seeds or 1, because you won't get it to 100% unless the CRCs match (although there are ways to trick the CRC to match, but that's a different story). Another problem could be that you are getting a poorly encoded file, or a very well encoded file that your computer isn't good enough to handle. My desktop can't handle 720p h.264 too well, for example. --Wirbelwindヴィルヴェルヴィント (talk) 15:32, 21 April 2009 (UTC)
- BitTorrent doesn't use CRCs, it uses SHA-1. CRCs can be spoofed easily but there's no known way to do that with SHA-1. -- BenRG (talk) 16:37, 21 April 2009 (UTC)
- Oops, my bad. I was mistaken because for some reason, I recall organizations trying to create false pieces, and CRC wasn't too hard to spoof. --Wirbelwindヴィルヴェルヴィント (talk) 19:32, 21 April 2009 (UTC)
- As far as I know there are organizations out there right now injecting fake data into torrents of Hollywood movies. The fake data can't end up in a completed download, but it can make downloading a lot less efficient, especially since the .torrent file only stores hashes of chunks of 256K to several megabytes while files are usually transferred in chunks of 16K. When a 1-megabyte chunk fails the hash check, the client can't immediately tell which peer is responsible since it might have received parts of it from several different peers. Also, in the worst case the whole megabyte has to be downloaded again just because of 16K of bad data. -- BenRG (talk) 01:15, 22 April 2009 (UTC)
- It's called Torrent Poisoning —Preceding unsigned comment added by 82.44.54.169 (talk) 07:40, 22 April 2009 (UTC)
- As far as I know there are organizations out there right now injecting fake data into torrents of Hollywood movies. The fake data can't end up in a completed download, but it can make downloading a lot less efficient, especially since the .torrent file only stores hashes of chunks of 256K to several megabytes while files are usually transferred in chunks of 16K. When a 1-megabyte chunk fails the hash check, the client can't immediately tell which peer is responsible since it might have received parts of it from several different peers. Also, in the worst case the whole megabyte has to be downloaded again just because of 16K of bad data. -- BenRG (talk) 01:15, 22 April 2009 (UTC)
- Oops, my bad. I was mistaken because for some reason, I recall organizations trying to create false pieces, and CRC wasn't too hard to spoof. --Wirbelwindヴィルヴェルヴィント (talk) 19:32, 21 April 2009 (UTC)
- BitTorrent doesn't use CRCs, it uses SHA-1. CRCs can be spoofed easily but there's no known way to do that with SHA-1. -- BenRG (talk) 16:37, 21 April 2009 (UTC)
- While you shouldn't download illegally, this is still a very valid question. What the above poster said is right; if you get the file downloaded to 100%, it doesn't matter if there are 1000 seeds or 1, because you won't get it to 100% unless the CRCs match (although there are ways to trick the CRC to match, but that's a different story). Another problem could be that you are getting a poorly encoded file, or a very well encoded file that your computer isn't good enough to handle. My desktop can't handle 720p h.264 too well, for example. --Wirbelwindヴィルヴェルヴィント (talk) 15:32, 21 April 2009 (UTC)
row separator in MS Excel?
editJust like you have separators in menus to club related items together, is there anything like row separator in Excel? I do not want to use text or background/fill colors, and I do not want to leave empty row of small height. Any ideas please? I am using Excel 2003. manya (talk) 06:35, 21 April 2009 (UTC)
- Would making some of the gridlines/borders bold also be out of the question? Zain Ebrahim (talk) 07:15, 21 April 2009 (UTC)
I got something close to what I am looking for by removing all cell borders and then applying only bottom line border to the last row in each 'set of rows'. But when I print it, it does not look good because of missing borders of all cells :( Still looking for better solution. manya (talk) 07:16, 21 April 2009 (UTC)
- Why don't you use standard borders and make the bottom line borders thicker? Zain Ebrahim (talk) 07:18, 21 April 2009 (UTC)
Thanks Zain. That works well for me. - manya (talk) 07:25, 21 April 2009 (UTC)
1. How can you make a Google search case sensitive?
2. How can you make it so you get a result with your phrase at the end of the sentence, not any part of the sentence? For example, a sentence that ends with "but dos isn't"? 58.165.23.195 (talk) 07:11, 21 April 2009 (UTC)
- 1. You can't. Also see an old post.
- 2. If Google supported the period character, it would have worked, but Google ignores most special characters excluding +#$_-
- Jay (talk) 08:28, 21 April 2009 (UTC)
- 1) I've often wished Google could do case-sensitive searches. A search for "NeXT" gets over 3 billion hits, for example. (At least the first one is our article on NeXT.) StuRat (talk) 17:55, 23 April 2009 (UTC)
Switch
editWhat happened to when we could just turn off a computer by pressing the On/Off switch? Why do we now have to hold the switch for 5 seconds to turn the computer off? After all, you may need to turn a computer off like that if you are forced to. 58.165.23.195 (talk) 09:08, 21 April 2009 (UTC)
- I've always thought the reason was to prevent you from accidentally turning off the computer and losing unsaved work. That's probably why the reset button is so tiny. Zain Ebrahim (talk) 09:12, 21 April 2009 (UTC)
- Yeah, that seems pretty obvious to me. GARDEN 09:24, 21 April 2009 (UTC)
- You can still turn it off using a single press on the power button. Just set the option in the Power control panel (for Windows). F (talk) 10:14, 21 April 2009 (UTC)
- Suddenly turning off the power can cause problems and in some cases seriously damage your computer. The delay is presumably so you can be certain you want to turn the computer off with none of the pre-preparation a compauter normally goes through. Vimescarrot (talk) 10:48, 21 April 2009 (UTC)
- Agree 100% with above. Even if it doesn't damage the hard drive, your computer uses cache memory and that data will be lost when the power is pulled, which alone is enough to lose or corrupt files. Also, harddrives could have the heads parked wrong or something and cause some sort of failures, although I'm not sure what comes into play if you use solid state hard drives. I've seen power outages cause all sort of havoc, even with surge protectors and APCs (well, 1 APC, but still, the possibility is there). --Wirbelwindヴィルヴェルヴィント (talk) 15:24, 21 April 2009 (UTC)
- Suddenly turning off the power can cause problems and in some cases seriously damage your computer. The delay is presumably so you can be certain you want to turn the computer off with none of the pre-preparation a compauter normally goes through. Vimescarrot (talk) 10:48, 21 April 2009 (UTC)
- In most systems, pressing the power button once will trigger the shutdown command. You can press the button and walk away. The computer will (eventually) shut down. Of course, it may get hung waiting for you to verify that you don't want to save changes to some files you have open. -- kainaw™ 15:48, 21 April 2009 (UTC)
- And holding it down forces a shutdown by the hardware, not by the OS (or something like that). 24.6.46.177 (talk) 01:18, 22 April 2009 (UTC)
- I mean, if you really can't wait a few seconds to turn off your computer when it isn't responding (which shouldn't happen that often anyway), you can still always just pull the plug from the outlet, flip the switch on the power supply on the back of your computer (if you have one), or flip the switch on your power strip, and it would be the same. --76.167.241.45 (talk) 16:22, 22 April 2009 (UTC)
Seeds
editWhile a torrent is downloading under the seeds column wi find 2 numbers one not in bracket and other one enclosed in bracket.Same with peers column.What do they mean? —Preceding unsigned comment added by 121.246.174.130 (talk) 12:50, 21 April 2009 (UTC)
- I believe the open number is seeds you are connected to and the number in the brackets is seeds connected to the torrent. I assume you are using utorrent? Livewireo (talk) 13:10, 21 April 2009 (UTC)
- That should be correct, in general. To be more specific, the larger number should be the pool, cause some software might have different notations. And uTorrent uses parantheses. I think Azureus uses brackets but it's been a long time since I've used it. --Wirbelwindヴィルヴェルヴィント (talk) 15:18, 21 April 2009 (UTC)
Resin and Mysql
editHi I am having a problem trying to display an image using resin and mysql. I have the code as such
'http://localhost:8080/Project2/images/acerpal.jpeg'
When I try to display the image all I get on my display page is the above text any ideas thanks. BigDuncTalk 14:46, 21 April 2009 (UTC)
- Please don't post multiple copies of the same question =3 --Wirbelwindヴィルヴェルヴィント (talk) 15:14, 21 April 2009 (UTC)
- I didn't I was getting an error when I tried to post and wasn't aware that I had posted and only came here to re post from my home PC. BigDuncTalk 16:53, 21 April 2009 (UTC)
- Silly question, but when you type that URL into your address bar, does the picture show up? x42bn6 Talk Mess 00:41, 22 April 2009 (UTC)
- It does yes. BigDuncTalk 11:12, 22 April 2009 (UTC)
- Silly question, but when you type that URL into your address bar, does the picture show up? x42bn6 Talk Mess 00:41, 22 April 2009 (UTC)
- I didn't I was getting an error when I tried to post and wasn't aware that I had posted and only came here to re post from my home PC. BigDuncTalk 16:53, 21 April 2009 (UTC)
Berne convention and the Internet
editHello. I have three questions about the Berne Convention as it applies to the Internet. I hope this is the appropriate desk for these. ^^
1) I've heard that anything you write in a blog is automatically subject to the Berne Convention. Is this true? Would this apply to anything written in web pages in general? (Also, what would happen if the web page disappeared? Would the rights hold?)
2) If I upload a file to a file hosting service, would it apply to the Berne Convention as well? Would the file type make any difference?
3) Are there any other ways to apply a document to the Berne Convention besides these (if at all)?
Thanks in advance, Kreachure (talk) 21:14, 21 April 2009 (UTC)
- 1. Depends on what country you are in. If you are in a Berne country, then yes, it automatically goes under Berne, because you are a citizen of said country and Berne is automatic.
- 2. Uploading is not a creative act. Berne comes into effect whenever you create something new. Did you create the thing that you are uploading? Then Berne still applies. File type doesn't matter. Note that you can lose your Berne-given copyright ability if you, say, agree to transfer the copyright (which some file uploading services and etc. make you do, so they don't have to worry about being accused of copyright infringement).
- 3. I think you're kind of confused on what's being covered by Berne. Not "documents"—think instead, "expressions." If that expression is in the form of a document, so be it. If it is in the form of a speech, no different. How about a song? No difference. A building? No difference. A Microsoft Word file? No difference. What matters is the jurisdiction in which it is created (under Berne or not). At least, that's my understanding of it. --98.217.14.211 (talk) 22:42, 21 April 2009 (UTC)
Thanks for your reply. Being in a jurisdiction not covered by the Berne Convention seems very unlikely, so yeah, my questions were assuming you're inside the Berne Convention coverage. I have another question from what you said though, related to proving that it's you who created something first: Is blogging, making a web page, and uploading safe ways to prove that it was indeed you who created whatever it is you created first, so that the Berne Convention applies automatically to you as soon as you 'publish' (or upload, etc.) them (and no one else can claim that it was them who created it instead)? Might there be safer ways on the Internet to prove it? I came up with file hosting because I presumed that there's some timestamping involved in the process (which would prove that it was you who created the thing first), but maybe there are safer services to 'secure' your rights through the Berne Convention? (Or, maybe there's simply no need to worry about timestamps and such in the first place?) Kreachure (talk) 23:22, 21 April 2009 (UTC)
- See poor man's copyright. The best way is to avoid the internet altogether if you are really worried about such things. Personally if I were doing a poor man's copyright I would do it with hashes and services (like Usenet) which distribute said data widely (making it increasingly unlikely that I was in collusion with any given site or company). --98.217.14.211 (talk) 00:13, 22 April 2009 (UTC)
- You may also want to read through World Intellectual Property Organization Copyright Treaty — Ched : ? 02:37, 22 April 2009 (UTC)