Wikipedia:Reference desk/Archives/Computing/2008 October 11

Computing desk
< October 10 << Sep | October | Nov >> October 12 >
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.


October 11

edit

Web Programming Question

edit

I want to construct a website with an interface that randomly presents users with one of a finite set of variables -- such as an image and accompanying text or audio, or a randomly generated web-page -- and requests user input -- such as a series of radio buttons next to accompanying text. So ideally it would work something like this: A user would hit a button or a link, be taken to a web-page generated with a randomly selected picture and accompanying audio, and then have the user fill out a form with radio buttons or something similar. Oh, and most importantly, I then need to collect the data from the forms and the information about the randomly generated page, store it in someplace, and allow me to perform meaningful operations with it (such as computing averages, etc.).

My question is: what programming language does this series of tasks sound most appropriate for? I'm used to programming (C++, Python) but have very limited experience with web-programming, so I don't really know where to begin. Further, do I need access and knowledge to/of the server on which the application would be stored in order to program the necessary CGI to perform the kinds of operations I mentioned before, or can I somehow just have it all written to a .data file stored elsewhere on the site? Deshi no Shi (talk) 00:50, 11 October 2008 (UTC)[reply]

For something like that, I'd normally toss something together in PHP - database access is fairly trivial that way, especially if you're using something like MySQL, and PHP uses a C-type syntax, which should help given your C++ background. Plus you just toss the PHP code into a plain text file for parsing by the web server, so if the server supports it you won't need any access beyond the norm. If you go with a CGI Python would be easy (although I'd use Perl as a matter of habit). Typical server configs place CGIs in a separate executable folder, so you'll need access and permissions. - Bilby (talk) 00:59, 11 October 2008 (UTC)[reply]
Would be so easy to do in PHP. Do it PHP. If you know C++ and Python you'll find PHP to be a walk in the park. Just look online for a quicky tutorial on using form data (e.g.) and databases (e.g.) with PHP and you'll be able to figure out the rest just fine. PHP is just a matter of knowing how to work with the web—the syntax is easy and there are functions pre-built for just about everything.
As for the server stuff... if you do it in PHP, you don't really have to know much about the server at all, esp. if you are just doing the sort of thing you describe. Some areas of functions (e.g. image manipulation) can be heavily affected by the version of PHP installed and what options it was compiled with. If you are using a real MySQL database you will have to get things set up on the server correctly with that (I recommend using a tool like phpMyAdmin for that). If you are just writing to a plaintext file then no, you don't need anything special.
Note that the easiest way to develop in PHP is to install a local Apache server (if you don't have one already) and install PHP with that and do it on your local computer, and then transfer that to the server. Sometimes there are little bugs or differences incurred when doing this, based on differences in OSes or installations, but they are rarely things that can't be worked around pretty easily. --98.217.8.46 (talk) 01:39, 11 October 2008 (UTC)[reply]

Mouse problems.

edit

I have seemed to run in to a small problem with my logitech mouse. The problem is that i have reached the far left end of my mouse, but the curser is on the far right side of my screen, i can still move is up and down, but i am unable to move it further to the left without going off my mouse pad, what should i do? —Preceding unsigned comment added by 67.164.220.177 (talk) 06:40, 11 October 2008 (UTC)[reply]

Lift the mouse up (with your hand, against gravity) and place it at the centre of your mouse pad again. 59.95.101.123 (talk) 12:10, 11 October 2008 (UTC)[reply]
Alternatively, purchase a larger mouse pad :) --Cookatoo.ergo.ZooM (talk) 21:13, 11 October 2008 (UTC)[reply]
Thank you very much for your help, I have a budget of $880, where would i be able to find a mouse pad that will work with a Macintouch Computer for under $800? —Preceding unsigned comment added by E smith2000 (talkcontribs) 05:51, 12 October 2008 (UTC)[reply]
Huh? --98.217.8.46 (talk) 13:23, 12 October 2008 (UTC)[reply]


I can create a large mouse pad for you at a bargin price of $879.00 203.202.144.223 (talk) 22:27, 12 October 2008 (UTC)[reply]

Markup language for desktop frontend ?

edit

Will ever HTML, or any other template based / markup languages be used, to design desktop frontend (of course, in combination with some scripting language, and style sheets) ? With xml and xsl, I don't think this is impossible. In this case we need only a rendering engine and a scripting engine on the top of kernel. This could possibly replace other traditional desktop frontends like, xwindows, gnome, or KDE. I am not sure, just asking... --V4vijayakumar (talk) 07:22, 11 October 2008 (UTC)[reply]

Depends on what you meant by that, Glade Interface Designer outputs a xml file that's used with bindings but is itself language independent. --antilivedT | C | G 07:37, 11 October 2008 (UTC)[reply]
Wouldn't that be a bit slow, especially with using scripting languages? Of course, there's already XUL which uses JavaScript, but that isn't used for non-web-applications (much). --wj32 t/c 09:14, 11 October 2008 (UTC)[reply]
NeWS (one of the early windowing systems for Solaris) used PostScript for all of it's rendering and user interactions. When a normal application program (written in C, perhaps) wanted a GUI widget (like a button or a menu), it would send the PostScript source code to the windowing system that would run hundreds of these little postscript programs in parallel. The postscript would draw the widget - monitor interaction with it and send data back to the application as needed. It was a pretty elegant concept and even on mid-1980's hardware, it was pretty usable. However, it fizzled and never became really popular. SteveBaker (talk) 03:07, 12 October 2008 (UTC)[reply]
NeWS hm.. interesting. I am sure something like this will come back. :) --V4vijayakumar (talk) 08:11, 12 October 2008 (UTC)[reply]
I've heard that OS X uses PDF in its display layer, though individual applications don't have to send it PDF source to work. 81.187.153.189 (talk) 09:25, 12 October 2008 (UTC)[reply]
It's not the same thing though - Postscript is an actual programming language. You execute the program in order to make the graphics. The cool thing about NeWS was that if (for example) you wanted a widget with a weird set of radio buttons where any two out of three could be pressed down at any time - or a widget that let you enter numbers in base 12 or something crazy like that - or a button that turns pink when you click on it - then you could send a little Postscript program to the window manager that would draw the widget - monitor mouse clicks and keyboard input directed at it and handle all of those little annoying error checking things...so the real C-language application would only ever see "clean" data coming from the GUI in a format that it could determine. This is nice for a system like NeWS (the 'N' stands for "Network") because a program running somewhere remotely can send a short Postscript program to your local computer that's drawing the desktop - and low level GUI stuff is handled on the client machine with only final results being sent back to the application. Because Postscript is portable - and the interface between application and window manager is just ASCII source code - the machine architecture of the windowing client and the host could be completely different. SteveBaker (talk) 19:10, 12 October 2008 (UTC)[reply]
Alternatively to everyone just telling you names of Interface Markup Languages, read the article User interface markup language and find out for yourself. Note that you could have easily find that article yourself. You'll also see that XAML can define language logic as well as interface, plus it can be scripted/hard coded as well. - Jimmi Hugh (talk) 11:08, 12 October 2008 (UTC)[reply]

Linux kernel

edit

I know that optimizing the kernel for a machine will give faster boot-up, but will it make other userspace application more responsive too? Will Firefox launch faster when I click its icon, or is it just the boot time that depends on kernel optimization?
The Firewall (talk) 10:27, 11 October 2008 (UTC)[reply]

Yes, but usually not by much (single-digit %); mainly because the kernel will use less memory, freeing some more for the applications, and because you can optimize the kernel for your particular CPU instead of a generic i386. MaxVT (talk) 19:24, 11 October 2008 (UTC)[reply]
Ok, but, how much memory can it use/free? In modern systems; with > 1 Gb or RAM, what good would it do if the kernel uses 1 Mb or 800 Kb? Any measured performance optimization on this? Renich (talk) 23:13, 14 October 2008 (UTC)[reply]
It really depends a lot on the application. A program that (say) calculates the first million digits of PI will probably use almost no kernel time - it'll get interrupted by the kernel once in a while - but that's going to be a tiny fraction of the total runtime. In that situation, the performance of the kernel is almost irrelevant. But pick a program that's doing LOTS of kernel-related activity (allocating memory, doing I/O, switching back and forth between lots of tasks) - and it's time could be dramatically affected by the performance of the kernel. The only reason booting up is so sensitive to kernel performance is because most of the programs that are invoked (and there are LOTS of them) are doing exactly those kinds of things that lean heavily on the kernel's performance. FIrefox ought to launch noticably quicker if the kernel gets a lot faster. SteveBaker (talk) 02:55, 12 October 2008 (UTC)[reply]

Strange symbols on webpages

edit

I've often noticed strange symbols appearing on webpages. In all of them, a valid character is replaced by a seemingly unrelated group of characters. For example, see this page where in the search result, ‘ gets replaced by ’. Could someone tell me why this happens? --Seraphiel (talk) 13:24, 11 October 2008 (UTC)[reply]

I can confirm that I have also seen this phenomenon, but I do not know what causes it. - SigmaEpsilonΣΕ 16:09, 11 October 2008 (UTC)[reply]
I think this is usually caused by software getting the character encoding wrong - if you visit the original article in Firefox and go to View > Character Encoding > Western (ISO-8859-1) you'll see the weirdness in the headline there too. It seems to work fine in UTF-8, and I'm not sure why the Google News spider isn't using that. — Matt Eason (Talk &#149; Contribs) 16:39, 11 October 2008 (UTC)[reply]
The Google News spider is probably at fault. The original article is served using the utf-8 encoding both from web server and in the document, and the characters used are encoded properly. Some script on Google's side bungles them, probably assuming ISO-8859-1 encoding or incorrectly handling UTF-8 characters. MaxVT (talk) 19:36, 11 October 2008 (UTC)[reply]
Read the article on Mojibake for more information. While the problem explained in this article occurs when trying to view content in other languages, the underlying cause of the problem is the same. Hope that gives you at least some insight. --Renwique (talk) 17:06, 13 October 2008 (UTC)[reply]

JAVA PROGRAM(Test1 of Computer Science)

edit

Qsn1. Write down a java program that produces the following pattern,given any value of n. n=1;

*  

n=2;

 *
* *
 *

n=3;

  *
 * *
* * *                      [15]marks
 * *
  * 

n=4;

   *
  * *
 * * *
* * * *
 * * *
  * *
   * 
//The input should be from the keyboard Tsotetsirapman (talk) 14:33, 11 October 2008 (UTC)[reply]
Read the top of the page. No homework questions. And really, this is pretty straightforward. Just look up how to for loops. --98.217.8.46 (talk) 14:37, 11 October 2008 (UTC)[reply]
Looks like you want a counter, say i, which increases until n, at which point it decreases until 0. Then, for each i, you want to print out i amount of stars (with the correct spacing as well). Should be pretty easy. Here's a big clue: the code looks something like this in C:
int up = 1;
int i;
int n = 4;

for (i = 1; !((!up) && (!i)); (i == n) ? (up = 0) : (up = up), up ? i++ : i--)
{
    // print stars here
}
--wj32 t/c 23:54, 11 October 2008 (UTC)[reply]
Here's another clue: for each i, the amount of space characters before the first star is n - i. I hope you were able to figure that out by yourself!--wj32 t/c 23:46, 11 October 2008 (UTC)[reply]
If it were me, I would probably use recursion... perhaps it may be a bit over complicated, but I've always found writing recursive functions to be much more interesting than for loops.
   void printStars(int n)
   {
       if(n==0)
           return;
       for(int temp=0; temp < n; temp++)
       {
       cout << " *";
       }
       cout << endl;
       printStars(n-1);
   }

Obviously that's not complete, but that's the basis of what I would do... :) DaRkAgE7[Talk] 04:21, 13 October 2008 (UTC)[reply]

MHTML

edit

This [1] says you can save a "whole Web site" as MHTML. How is this done? I've only ever got it to save one page at a time. —Preceding unsigned comment added by 66.63.184.3 (talk) 17:53, 11 October 2008 (UTC)[reply]

I think [2] meant "page", not "site". --grawity 18:07, 11 October 2008 (UTC)[reply]

Auto-Refresh?

edit

Is there a way to make Firefox automatically reload a page after a specified amount of time? I'm playing Forumwarz and there's a page that displays crucial information, but I need to to be always up-to-date. Instead of pressing F5 and alt+tab all the time, is there a simpler way?. 58.161.97.173 (talk) 22:05, 11 October 2008 (UTC)[reply]

There is a "Reload every" plugin for Firefox - [3] -- Finlay McWalter | Talk 22:23, 11 October 2008 (UTC)[reply]
Oh, thank you very much 58.161.97.173 (talk) 23:00, 11 October 2008 (UTC)[reply]