Wikipedia:Reference desk/Archives/Computing/2011 September 19

Computing desk
< September 18 << Aug | September | Oct >> September 20 >
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.


September 19

edit

Why HTML content and CSS presentation rather than XML content and XSLT+HTML+CSS presentation?

edit

The universal theme of web design is the eternal struggle to make a page look right using CSS without sacrificing the semantic meaning of the HTML describing its content. Frequently, we could make a certain section display exactly the way we want it to, if only we could use tables without committing a sin against the heavens good design principles.

A solution seems evident: send your content as arbitrary XML of your design, and transform it into whatever crazy thousand-nested-divs-with-inline-CSS you need to make the page look right using client-side XSLT, imbuing the rendered HTML with no semantic meaning whatsoever. (And XSLT is Turing complete, so you have way more flexibility than with just CSS selectors.) Yet, hardly anyone actually does this (in the real world, as opposed to W3C wonderland). Is there a reason for this? « Aaron Rotenberg « Talk « 03:17, 19 September 2011 (UTC)[reply]

In my experience, comparatively few people are familiar with XSLT - especially considering the minimal technical training for the generic "web designer" profession. Though XSLT is more powerful and flexible than HTML/CSS, it's also harder to use; there's less support in web browsers for it; and there are fewer good design tools.
I think XML / XSLT would be a huge step forward toward enabling semantic web; and it would make it much easier for individual users to customize their display and content-presentation preferences; but this doesn't seem to be the direction the actual internet mainstream is evolving towards. Nimur (talk) 05:57, 19 September 2011 (UTC)[reply]
I only used XSLT briefly, and I have a strongly negative visceral reaction to it. (The funny thing is that it's not all that dissimilar from the Scheme macro system, which I love. I think that XSLT's syntax simply prevents comprehension on my part.) In any event, the web developer is free to write a backend that stores XML (or whatever) and uses XSLT transformations (or whatever) to generate the HTML/XHTML that gets sent over the wire. It means that whatever gets sent over the wire is ugly, but browser developer tools need to operate on the thousand-nested-divs in order to correspond to reality anyways, so I don't think there's any great loss. Paul (Stansifer) 16:11, 19 September 2011 (UTC)[reply]

In any case, you have it wrong about CSS. There isn’t an eternal struggle to make a page look right using CSS, there’re just people wanting what they can’t easily have from what doesn’t really support it… and you’ll run into this with any language and any implementation. ¦ Reisio (talk) 20:26, 20 September 2011 (UTC)[reply]

Advice on Upgrading PC for Gaming

edit

Hi,

Here is my current setup:

CPU: AMD Athlon 7750 Dual-core 2.7 GHz

RAM: 3 GB PC2-8500
Video card: ASUS EAH4670 (512 MB VRAM, 750 MHz, 128-bit memory interface, 320 stream processors)

Motherboard: ASUS M4A78 Plus

I'm considering getting a new ASUS EAH6850 (with 1 GB VRAM, 790 MHz, 256-bit memory interface, and 900 stream processors). Would that, by itself, improve my gaming performance? Or, would I need a new CPU, too, before I notice a difference? I just got a couple new 1680x1050 monitors and I'd like to play games at full resolution on one of them. I'm going to be getting Battlefield 3 and Call of Duty: Modern Warfare 3 when they come out. I had to play Grand Theft Auto IV on medium quality at 1024x768 to prevent stuttering. If I re-installed Grand Theft Auto IV, would the new card help with that? Would the CPU prevent the GPU from operating at peak capacity?

Thanks,

Best Dog Ever (talk) 04:25, 19 September 2011 (UTC)[reply]

why do domain registry fees differ so widely?

edit

I've looked at NetRegistry and Melbourne IT for Australian domain name registry (.com.au), and the prices differ markedly, yet I can't figure out what one is offering that the other isn't. In what ways do services generally differ? I'm not asking people to tell me what I get with the specific providers mentioned (if you know anyway, please go ahead), but rather, the sorts of things I should look out for, so I know how to make an intelligent comparison. Thanks in advance, It's been emotional (talk) 06:18, 19 September 2011 (UTC)[reply]

Just a matter of how much of a sucker they think you are, or a calculated risk that the higher price will serve them better than a lower price and a potentially higher volume of sales. A $10 domain name is about a 99.9% overcharge, more than $10 is even more. What you should look out for (more than a ridiculous price) is a nasty TOS, or history of shadiness. ¦ Reisio (talk) 20:29, 20 September 2011 (UTC)[reply]
Some registrars provide additional services, like some anonymity (although not enough to avoid being sued). Also check how much they charge for the second year on. Some providers are cheap just the first year. Quest09 (talk) 09:26, 22 September 2011 (UTC)[reply]

Variable number of nested loops

edit

For example:

for a=1 to n
   for b=1 to n
      for c=1 to n
         (do whatever)
      next c
   next b
next a

is some BASIC with three nested loops. The pattern could be extended explicitly to any number of them, but is there a construct in basic BASIC to permit the number of such loops to be variable in the program, i.e. dependent on something and not fixed at the time it was written?←86.155.185.195 (talk) 13:54, 19 September 2011 (UTC)[reply]

Yes. See Recursion_(computer_science). Basically you make functions that can call themselves. A common function of this sort is one that looks through a directory tree for a file. The first instance of the function looks for the file its current directory, and if it doesn't find it, it looks to see if it has other directories in its directory. If so, it calls another instance of the same function (itself) on each of those directories. Done correctly, it can run arbitrary number of loops as it searches through every directory for the file. --Mr.98 (talk) 14:21, 19 September 2011 (UTC)[reply]
My recollection is that "basic" BASIC does not allow recursion. You can however, at the very least, put your loops inside "if-then" statements or skip over them using conditional GOTO's. Looie496 (talk) 14:50, 19 September 2011 (UTC)[reply]
You can do it, but it isn't easy, and it's pretty ugly. See e.g. this article. Either way, though, recursion is the answer to the question. Implementation is a separate issue. Googling "BASIC recursion" or "BASIC recursive" comes up with a lot of different implementations. --Mr.98 (talk) 14:54, 19 September 2011 (UTC)[reply]
If you don't have access to recursion, you rewrite the algorithm to use an explicit stack. In general, the stack keeps track of partially-completed work. This is, of course, a case where Greenspun's tenth rule looms ahead. Paul (Stansifer) 16:00, 19 September 2011 (UTC)[reply]
This specific case can be done with an array and a while loop. The number of for loops is the number of elements in the array. While all of the elements are <n, keep doing the function. At the end of each iteration, add 1 to the last element of the array. If it equals n, reset it to 1 and add one to the previous element, etc... You'd obviously do that in a for loop. -- kainaw 16:44, 19 September 2011 (UTC)[reply]
I've added an implementation of that far below.. In the absense of recursion the idea above of using a stack is better than using an array (since not all basics allow the size of the array to be determined compile time) - however not all basics let you play with a stack either...Imgaril (talk) 18:40, 19 September 2011 (UTC)[reply]
In cases where recursion isn't allowed, I've sometimes resorted to multiple copies of the same program, each of which calls the next in the series:
PROG1:
for a=1 to n
  if (...) then 
    call PROG2 ()
  else 
    (...)
  endif
next a
PROG2:
for a=1 to n
  if (...) then 
    call PROG3 ()
  else 
    (...)
  endif
next a
Of course, this only provides for as many levels of "recursion" as there are programs, but recursion is always limited in some way, anyway (CPU time and memory, if nothing else). StuRat (talk) 16:56, 19 September 2011 (UTC)[reply]
I've had this problem - a solution for almost all programming languages (even those without recursion) is to use a loop over arrays eg if you want 10 loops create an array n[10] . You need an index variable "i" so that you can tell which loop you are in. It is necessary to replace those "for nexts" with "if-thens" or "repeat-until"
I'll also add two more array variables "min[size]" and "max[size]" which you should be able to guess what they are for, and I'm assuming you've preloaded them with the bounds you want
for a=1 to size: n[a]=min[a]:next a  size is the number of for next loops, initiate the start values for the loops
n(i)=n(i)-1 because of the way I wrote this start the first loop with value minus 1
label loop2             this is a GOTO point
i=1
   
label loop1             another GOTO point
 n(i)=n(i)+1                    increment the for-next loop variable
   if (n(i)>max(i)) then       check for end of for-next loop
     n(i)=min(i)               if end of loop found reset previous loop variable
     i=i+1                      increment loop index
       if (i>size) then end     this bit checks for the end of all the loops
         else
           goto loop1           this is the equivalent of the NEXT bit
         endif
     else 
       do some stuff HERE - YOUR MAIN LOOP CALCULATIONS HERE
       goto loop2              this is the equivalent of a NEXT instruction after the a previous NEXT has finished
     endif
This works (checked) -you should be able to replace the GOTOs with "repeat untils" or similar. This method is good for simple compilers since it readily converts to machine code. However a recursive method (recursion) is easier to write and maintain - it well work spending the time and effort learning how to do recursion (and how to write this program recursively) - bugs are easier to find, though a compiler may have a harder time of it making it into fast code. If you need an example of this written as a recursive program now is the time to ask..
I've never seen this impemented as a keyword in basic - but it may exist (possibly in other more modern languages)
The suggestion of using the stack (Stack (data structure)) to store the values of the for next variables is a good one - and well worth learning - it has advantages over having to pre-define an array to store the "for-next" loop values (especially when your basic doesn't allow you to redefine array size on the fly) - however I don't think many basics will support stacks. Imgaril (talk) 18:27, 19 September 2011 (UTC)[reply]

Thanks to all.←86.155.185.195 (talk) 21:52, 20 September 2011 (UTC)[reply]

Letterboxing at Lower Resolutions (Win7)

edit
  Resolved

Just the last two days, my Win7 laptop has been letterboxing fullscreen applications when they play at lower resolutions than my native one (1366x768) - i.e. the application plays in the middle of the screen and I get black regions on either side. I have no idea why this has suddenly started happening, and I would like to change it back so that these lower-rez applications are scaled up to play fullscreen without letterboxing, like they did up until just a few days ago. Does anyone know what I should do? --KägeTorä - (影虎) (TALK) 13:56, 19 September 2011 (UTC)[reply]

Letterboxing would show mattes above and below; your issue is pillarboxing. 1366x768 is 16:9 ratio so it appears that your applications are using a different aspect. ---— Gadget850 (Ed) talk 14:51, 19 September 2011 (UTC)[reply]
Pillarboxing, ok, cheers. And, yes, I know what the problem is. I am looking for a way to solve it. :) --KägeTorä - (影虎) (TALK) 14:53, 19 September 2011 (UTC)[reply]
I would guess that either your software has had an update or the video is now provided in a different format than previously. What software are you using to play the videos ? Most software would have settings for display preferences. However, if yours doesn't or you can't find it, another option is to lower the screen resolution on the laptop to more closely match the video. You may still have small black bars, but hopefully it will be improved somewhat. And, as a bonus, not having to scale up the video may make it look better and play with less lag. StuRat (talk) 16:46, 19 September 2011 (UTC)[reply]
Well, when I said 'fullscreen applications' I meant programs like games and game editors and whatnot. Anyway, the problem seems to have been fixed as I rolled back my NVidia driver. No idea why the problem started in the first place, though, as my driver wasn't updated over the weekend.

Google query

edit

Is there a thesaurus prefix function for Google that works along the same lines as "define:"? Thanks much in advance! ScarianCall me Pat! 14:46, 19 September 2011 (UTC)[reply]

Not really. Google does have synonym capability. Place a ~ in front of a word and Google will use all synonyms of the work in the query. However, it gives precedence to the word you typed. You can stop that by using - to remove that word. So, searching for "~short -short" turns up listings featuring small, brief, etc... -- kainaw 14:54, 19 September 2011 (UTC)[reply]

video editing

edit

A little while ago I asked about simple free downloadable video editors, intending to make a few simple changes to certain films before uploading them to youtube. I was refered to Avidemux, which seemed to work well, however, I have since discovered that anything edited in that program will no longer play in any other program, and though it uploads to youtube quite well, for some reason the sound always disappears somewhere, and all the films are now in silent, though they play with sound in the editor still. So, is there anything I can do to fix any of this? Also, is there any way of arranging for a particular film to run backwards in this program, or would I be better off downloading something else instead? Finally, can I upload the unedited version into the place of the one on youtube now, or would I have to delete that and start again to get any sound?

148.197.81.179 (talk) 17:52, 19 September 2011 (UTC)[reply]

Hmm, that's odd. Try changing the encoding options; on the left side under video change it from "copy" to "MPEG-4 XVID" and Audio to "MP3 lame". Avidemux does not append a file extension when saving video, so be sure to specify one in the save window dialog, .avi should do. You can set video to encode in reverse by going Video -> Filters -> Transform -> Reverse, however this only reverses the video, not the audio. I do not know of a way to reverse audio in this program, but you could use Audacity to do this. Extract the audio in Avidemux by going Audio -> Save, import it into Audacity, reverse it, and then save it. Then in Avidemux go Audio -> Main track and under "Audio source" select "external mp3/wav", click open and select the file you saved with Audacity. There are probably much easier ways to do this with professional programs such as Adobe Premiere or Sony Vegas, but these are not free AvrillirvA (talk) 15:46, 20 September 2011 (UTC)[reply]

OK, so that went well. I changed the video and audio settings and saved it as a .avi, with no effect, it still behaves exactly the same way when I try to open it elsewhere. I managed to reverse the video, and download Audacity, reverse the sound in there and put it back into the video file, but when I saved the result, loading it again, there was no sound in Avidemux either, I had to import the sound file and apply it again, every time I saved it and opened it again. So, one out of three has worked, not bad for my usual luck with computers. 148.197.81.179 (talk) 18:22, 21 September 2011 (UTC)[reply]

computing: python

edit

How do I come out with an algorithm to check if a number is a square number, prime number and a Fibonacci number using python? — Preceding unsigned comment added by 155.69.2.13 (talk) 18:03, 19 September 2011 (UTC)[reply]

  Please do your own homework.
Welcome to Wikipedia. Your question appears to be a homework question. I apologize if this is a misinterpretation, but it is our aim here not to do people's homework for them, but to merely aid them in doing it themselves. Letting someone else do your homework does not help you learn nearly as much as doing it yourself. Please attempt to solve the problem or answer the question yourself first. If you need help with a specific part of your homework, feel free to tell us where you are stuck and ask for help. If you need help grasping the concept of a problem, by all means let us know.
Start by reading the definition of prime number, square number, and the fibonacci sequence. There are lots of algorithms that can implement sequence-generation; and you can just use a straightforward brute-force check: create a list of all prime numbers (square numbers, fibonacci sequence members, etc), that are smaller than or equal to your input number. Then, if you find a match... your number is a prime (or square, or a member of the fibonacci sequence). Nimur (talk) 18:31, 19 September 2011 (UTC)[reply]
Checking if "a number is a square number, prime number and a Fibonacci number" is easy - this code will do it:
return False
There are no numbers that are square and prime. (One is not considered prime.) Mitch Ames (talk) 10:16, 20 September 2011 (UTC)[reply]
Aaaahrgh! I was thinking about something like this with Fib and Prime....trees, forests, and blinded by the light... ;-) --Stephan Schulz (talk) 11:04, 20 September 2011 (UTC)[reply]
Primality test may help. --Colapeninsula (talk) 12:56, 20 September 2011 (UTC)[reply]

Google Chrome as a CPU hog

edit

I recently went to release 10.0.648.205 of Google Chrome. Sometimes it works fine but sometimes opening a 2nd or 3rd tab and starting another page will push the CPU use up to 100%. This stalls the entire system for an extended period, sometimes to the point where I cannot close the new tab.

In the past the same pages, Gmail for example, did not stall the system. I'm blaming the problem on the new version of Chrome but I can't prove it is the problem.

In the problem periods, Windows Task Manager shows six and sometimes more processes called "chrome.exe" running, with very large CPU numbers

Have other people run into this sort of behaviour? Is there diagnostic software that can help understand what is happening? Or is it better just to uninstall Chrome? Thanks, Wanderer57 (talk) 21:21, 19 September 2011 (UTC)[reply]

Firstly I'm at version 14.0.835.163 m - so what OS/CPU are you using.?
In chrome >> spanner >> tools >> task manager you can see the CPU and memory of each tab .. but I guess this will only tell you what you already know - that the new tabs are cpu heavy..
Generally no though.. Definately not with gmail. Could you link to a page that has the effect. (Sometimes there is a cpu spike on page opening - as expected as the computer does the new javascript / flash stuff - but in practically all examples I don't anything get like a freeze.. (Atom CPU 1.6GHz) Imgaril (talk) 22:01, 19 September 2011 (UTC)[reply]
oh As I understand it you should have on instance of chrome.exe per tab - so if you've got 6 with 3 tabs sounds like something is wrong.Imgaril (talk) 20:01, 20 September 2011 (UTC)[reply]