Wikipedia:Reference desk/Archives/Computing/2007 May 16

Computing desk
< May 16 << Apr | May | Jun >> May 17 >
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.


May 16 edit

saving web-pages in one file edit

How can I save web-pages in one clickable file? (I mean, when I save a web-page it is actually the page and an extra folder). I want to have both together.217.95.65.120 00:00, 16 May 2007 (UTC)[reply]

Pics are going to be in separate files in a folder, called from the main HTML file, that's just the way HTML works. The only way to save a web page as one file would be to take a snapshot of it and save it as a pic. That would be easy if it's on one screen, not so easy if it scrolls off the bottom of the screen. Once saved as a single pic, though, you can't modify it very easily. StuRat 00:25, 16 May 2007 (UTC)[reply]
There is a format called "MHTML" (Mime HTML) that is intended for saving web pages as single files. Internet Explorer can save in it. [Do "Save As ..." and then set the "Save As Type:" to "Web Archive, single file (*.mht)".] According to the MHTML article, current versions of Opera and Safari can also save the files, but Firefox cannot. --Tugbug 01:19, 16 May 2007 (UTC)[reply]
There was a plugin for FF 1.5 that let me save in MTHML, but it doesnt work in FF 2 anymore :( Shinhan 07:32, 16 May 2007 (UTC)[reply]
You could save it as a PDF with supported links, on a PC you'll need a plug-in, but on Mac just print as PDF -- no plug-in required! --Cody.Pope 10:02, 16 May 2007 (UTC)[reply]
I could be wrong but I'm pretty sure the links just become blue, not actual clickable links, if you do the Print > PDF on a Mac. --24.147.86.187 12:26, 16 May 2007 (UTC)[reply]

Need help with useing the same internet connection on two computers without another routher edit

i have a router that uses cables to connect to one of my computers. (that pc has 2 internet cards). i have the other internet card (the one not being connected to the internet) connected directly to my other computer. i was wondering if there is any for both of them to be able to go onto the internet. NOTE-- the pc connected directly to the router can go onto the internet. BOTH computers have windows XP —The preceding unsigned comment was added by 71.175.15.245 (talk) 00:05, 16 May 2007 (UTC).[reply]

You might be able to use a switch or hub (or even passive hub/splitter), but the problem is that many ISP's only give you one IP address, and you'll need two for those computers to operate over the same connection. Cheap RJ-45 jack splitters are in the ~$10 neighborhood (or less) at Radio Shack, etc., so you might want to go and get one and see try it out to see if the second machine will automatically acquire an IP address.
Alternatively, if you don't access via networked wall jack, but rather say DSL or a cable modem, you might be able to do a similar thing, depending on the cable or DSL modem. Without knowing specifically what you have, I can't really answer the question down this direction. –Pakman044 00:19, 16 May 2007 (UTC)[reply]

i dont think it is a problem with the ip because my laptop (wierlessly) and my other computer use the router. for what internet i have it is verizion fios (very fast fiberoptic internet) i think the cables that i use to connect the computers is a cat5.

If you have a router, is it not a simple matter to just connect the laptop to the router? Splintercellguy 02:06, 16 May 2007 (UTC)[reply]
If one computer has 2 network cards, one plugged into the internet and the other into another computer you can get internet on both XP computers by running "internet connection sharing wizard" on both computers. Vespine 04:50, 16 May 2007 (UTC)[reply]
I do this on my PC by bridging the two connections - under Network Connections, select both and right-click - Bridge connections. I'm sure a Google will give you plenty of guidance also. --Worm 15:38, 16 May 2007 (UTC)[reply]

Autorunning batch files? edit

I'm trying to make it as simple as possible for my parents to use their digital camera. Is there some way I can create a batch file -- one that's automatically run whenever the SD card is inserted -- that'll cut and paste all files on the SD card (except the .BAT file obviously) to a specified directory on the hard drive, then show a large "OK, all done" message? Down M. 04:40, 16 May 2007 (UTC)[reply]

Presumably it would be executed by an autorun.inf file on the sd card. Maybe try something like
cp E:/* C:/pics/
? --frotht 05:25, 16 May 2007 (UTC)[reply]
How about using something like Picasa and automatically run it every time camera is connected? That would be much easier to sort and manage than just oopying them to a directory. --antilivedT | C | G 08:29, 16 May 2007 (UTC)[reply]
Autorun.inf isn't a shell script, and Windows doesn't support "cp", it's called "copy". —The preceding unsigned comment was added by 149.135.125.155 (talk) 09:35, 16 May 2007 (UTC).[reply]
Well who said it was a shell script? And nice catch with the "copy"- I haven't used dos in ages --frotht 13:53, 16 May 2007 (UTC)[reply]

I wrote a similar copy program, but had it run when a suitably labeled icon on the desktop was clicked. StuRat 00:18, 17 May 2007 (UTC)[reply]

String in C edit

Hello all. I just got a question from a friend of mine about strings on C. Can I, somehow, declare an object as a string, like,

String ABC;

like that? And if the answer is no, is there any easier way than using arrays of characters? Thanks in advance —The preceding unsigned comment was added by Imoeng (talkcontribs) 08:50, 16 May 2007 (UTC).[reply]

No, on both counts. If you want a lightweight OO overlay on top of C, go Objective-C. If you want something more complex, go C++. —The preceding unsigned comment was added by 149.135.125.155 (talk) 09:34, 16 May 2007 (UTC).[reply]
The only way I know of creating stings in C is with an array of characters, try C++ it has all sorts of stuff that makes creating and manipulating strings easy. --Lwarf 10:21, 16 May 2007 (UTC)[reply]
Sure; you can create any kind of new data type you want, and then define operations on it. It's not anywhere near as convenient as with a language with built-in OO support (or even with a decent standard library), but can definitely be done (example below). It's what other languages are doing under the covers with their powerful encapsulation mechanisms. --TotoBaggins 17:09, 16 May 2007 (UTC)[reply]
// string_lib.h
typedef struct
{
    char *char_buf;
    int  char_buf_size;
} String;

String* string_new(char *initial_str);
void string_append(String *str, String *pendant);
void string_destroy(String *str);

// main.c
int main()
{
    String *s1 = string_new("hello");
    String *s2 = string_new(" world");
    string_append(s1, s2);
    puts(s1->char_buf); // prints "hello world"
    return 0;
}

Here's what the program would look like in FORTRAN, a language with proper string handling built in:

PROGRAM HELLO_WORLD
CHARACTER*80 S1,S2
S1 = "hello"
S2 = " world"
S1 = s1(:5) // S2
PRINT *,S1
END

StuRat 00:12, 17 May 2007 (UTC)[reply]

This doesn't mean that you can universally get away with never having to deal with character arrays in C. It only masks the "discomfort" in all the code someone personally writes and nothing else.

Countdown... edit

Hello, Someone emailed and asked me to find an online (free) countdown to add to their blog. They want it to be something that they can change (like, set it to end at 11:15 today, then change it to a different time a different day). Is there such a component? Thanks!! --Zach 13:17, 16 May 2007 (UTC)[reply]

Typing javascript countdown timer in to Google should keep you busy for a while. - X201 13:23, 16 May 2007 (UTC)[reply]
I dont think the java ones are working... lemme try flash... --Zach 13:53, 16 May 2007 (UTC)[reply]
Note that Java and Javascript are two different things. Javascript should work if you're using a mainstream browser, but Java may need extra things installed. JoshHolloway 15:48, 16 May 2007 (UTC)[reply]

Halo 3 Beta edit

I had signed up for the Halo 3 Beta at halo3.com, and I got an email 9 hours ago from Bungie with a download code, saying am welcomed to the Bungie Friends & Family Halo 3 Beta. However, I did not play on Xbox Live for 3 hours nor buy the game Crackdown like the Rule of Three requests. Can I still download and play the Halo 3 Beta? Based on the Wikipedia article, I'd say there was more than one beta program, so things are looking up. [Mac Δαvιs] ❖ 16:43, 16 May 2007 (UTC)[reply]

From what I hear (and this is an opinion and I am probably not accurate), you can only sign up if you're in the US and if you're in the UK or whatnot then you can use the Crackdown CD. JoshHolloway 19:07, 16 May 2007 (UTC)[reply]
Why don't you try it and tell us? -- Phoeba WrightOBJECTION! 22:23, 16 May 2007 (UTC)[reply]
My friend and I agreed that we would use his box. In the afternoon I should be there to enter the passcode. [Mac Davis] (unloggedin)

Precision in printf edit

I want to print a floating point number with the printf function in C (actually in Octave, but it works the same as in C). When printing the variable x, I could write printf("%e", x), which would round the number off and give me 5.861571e+07 as output. However, rounding is not acceptable – I need to output all information that is stored in x. How do I do that? Do I really have to manually specify a precision that I know will capture all of x, i.e., write printf("%.40e", x) and get 5.8615710000003218650817871093750000000000e+07? Can't I get it do determine automatically how many digits are needed? Thanks. —Bromskloss 17:55, 16 May 2007 (UTC)[reply]

printf has no idea how many digits are necessary to accurately represent the number you believe to be represented by the float or double x - so it just prints how many you tell it. It's entirely false to believe a) that it will store all the digits you want, and b) that digits following what you'd consider to be the last one will be zeros - floating point is all about approximations. If rounding really isn't acceptable then you shouldn't be using floats and doubles at all, but an arbitrary-precision arithmetic library instead. -- Finlay McWalter | Talk 18:19, 16 May 2007 (UTC)[reply]
Looking at Octave's page, I'll guess that it already has an arbitrary-precision library. Is x really a float, or is it really a bignum? If it's a float, the above applies, but if it's a bignum then the comparison with C is misleading, and the question really is how does Octave's printf behave. -- Finlay McWalter | Talk 18:27, 16 May 2007 (UTC)[reply]
It is a float (64 bit), and I am fully aware of that it has a finite precision. I just don't want the use of printf to reduce that precision further. —Bromskloss 18:57, 16 May 2007 (UTC)[reply]
Could you explain why you need all the information? If you just want to store the information, you can store the 64 bit directly without considering its meaning as a float, like 0xAFB2312422FB1228.
I will import the output into another program. —Bromskloss 22:06, 16 May 2007 (UTC)[reply]
[edit conflict] What you should know about this is given at Apple's floating-point guide, with some of it (and a lot of other useful information) given at Sun's more mathematically-oriented site. The skinny is that (at least for numbers that are not near the edges of the representation's range) every decimal number with at most 6 significant digits "survives" being represented as a float and then reformatted to 6 significant digits (as by "%.6g"). However, given a float, one must (in the worst case) write down 9 significant digits in order for reading the output as a float to yield the original value. These numbers for double are 15 and 17 (which happen to differ by only 2 instead of 3). So the question of "How many digits does this floating-point type have?" is somewhat ill-posed; put simply, you must supply (as input or as output!) the larger number to specify a value but must expect only the smaller number back if you have a "correct" decimal answer in mind. These smaller numbers are available with GCC as pre#defined macros __FLT_DIG__, __DBL_DIG__, and __LDBL_DIG__.
This is of course complicated by the notion of the "exact value" of a floating-point number, which, instead of being the shortest decimal string that would round back to it, is the actual value represented by the bit pattern. Since   has n digits after the radix point in decimal, and doubles have 53 bits of mantissa (including a hidden bit), the exact decimal representation can be quite long. For instance, the smallest double greater than 1 is  =1.0000000000000002220446049250313080847263336181640625. However, following the "17" rule, it is sufficient (if it is understood that we are discussing only doubles) to give this number as the somewhat-more-manageable 1.0000000000000002, which will round to that double value if re-read. Which of these two values you consider to contain "all information" is something of a judgment call: the second number is clearly different from the first and from the double it represents, but it does uniquely represent that value in the (IEEE 754 64-bit) machine numbers. So the short answer is that "%.16e" or "%.52e" will do what you want, depending on what you want. [edit conflict: apparently you'll be happy with correct re-reading, which is the smaller precision] (The precision for %e does not include the first digit, which is never 0 (except for 0.0e+00, of course); for %g use precisions one greater.) Does that help? --Tardis 22:30, 16 May 2007 (UTC)[reply]

If you want to transfer binary floating-point data exactly, without a pair of binary/decimal conversions and all the attendant complications and "gotchas", C99 has a new format: %a, which gives you binary floating-point, not decimal floating-point. Here, and as long as you use enough digits, the result really will be exact. Figuring out the right number of digits will still be somewhat tricky and machine-dependent, but more straightforward than the decimal case.

The downsides are that %a is not available under all C libraries, and its output is (obviously) not so human-readable. I have no idea whether Octave supports it. —Steve Summit (talk) 01:19, 18 May 2007 (UTC)[reply]

Name for RAM overload? edit

Is there a particular name for an error in which a computer tries to transfer too much information from its hard drive to RAM? (Perhaps in some sort of failure or error relating to direct memory access?). Does this ever happen? If so, what is the result? Thanks. --Brasswatchman 22:40, 16 May 2007 (UTC)[reply]

Your question can be interpreted a number of different ways. The error could be a buffer overflow, a low-memory situation resulting in thrashing, a DMA error, and so on. What is the context of your query? --TotoBaggins 22:54, 16 May 2007 (UTC)[reply]
Err, the context is my own curiosity? :) I honestly don't have a hardware error of any sort (though my laptop has been hitting the virtual memory pretty hard recently). I'm just trying to educate myself about hardware. Thanks. --Brasswatchman 22:24, 17 May 2007 (UTC)[reply]
Think about what happens in a modern OS. Note that you're not really copying stuff straight to physical RAM, you'd most likely be doing it in a virtual memory layer. VM fakes that every program has 4G of RAM, and because not every program uses 4G of RAM, it only copies what bits each program needs into physical RAM. When all your physical RAM is unavailable, it transfers some of those bits from your physical RAM onto your hard disk (which is several orders of magnitude slower than physical RAM).
Now back to your question. If you transfer a heap of stuff into virtual memory and your physical RAM is exhausted, you'll begin to start swapping (transferring stuff from RAM to your hard disk). If your swap (the bit of your hard disk reserved for transferring bits from RAM to the hard disk) is exhausted, nasty things will happen, such as your OS grinding to a complete halt.
I see. And how does the swap become exhausted? Can that particular path actually burn itself out? (And is what you're describing the same as what Toto Baggins calls thrashing?) --Brasswatchman 22:24, 17 May 2007 (UTC)[reply]
Windows calls it "paging" and it's just a large file in system32 or thereabouts. The kernel or filesystem restricts its size to whatever you set it to, and if it exceeds that size and no optimizations are possible, then it's full and that's that- the OS will not allocate any more memory and will return nulls for any program that wants a free address --frotht 00:09, 18 May 2007 (UTC)[reply]
I know this is irrelevant but I believe (no warranties) that the hardware does not 'burtn out when you run out of swap (aka virtual memory) . A nice protection from this happening is very simple actually. Get more RAM on your system that the OS Distributor recommends. and get a swap file of fixed size that is about two to four times your RAM. --Kushal User_talk:Kushal_one 23:37, 17 May 2007 (UTC)
There's no fundamental answer to this- it's just however the OS chooses to handle it. I don't actually know how any of them work in this respect, but if I were making an OS I'd just refuse to allocate memory once paging is full and ensure a safe margin of error to keep the OS alive. Also programming language specs often have compilers keeping their kids safe by refusing to let them even ask the OS for too much memory, so they can die gracefully or hopefully decide to free up some memory or something first. You're not going to cause physical damage by running out of memory- it's just bits flipping in very low stability areas (absolutely nothing bad will happen to your rig if your swap partition/file is corrupted). I know that memory used to be a problem for me back in the win 98 days and the OS would die if you ran out of memory- but after a restart all is well. --frotht 00:04, 18 May 2007 (UTC)[reply]
What would this situation seem like to the user? Would the OS just freeze? --Brasswatchman 17:46, 21 May 2007 (UTC)[reply]
And by the way, are you specifically asking about DMA (you said from its hard drive to RAM) or could it be any insufficient-memory problem? --frotht 00:07, 18 May 2007 (UTC)[reply]
Sure, why not? I'm just curious about how primary and secondary memory interact. Does anything tend to go wrong with DMA on certain models? Have you heard of anything? --Brasswatchman 17:46, 21 May 2007 (UTC)[reply]
Just wanted to say thanks to everyone who contributed to this thread. I've learned a lot from your responses. Appreciate it.--Brasswatchman 17:46, 21 May 2007 (UTC)[reply]
Out of memory, often abbreviated to OOM, as in "the linux OOM killer picks a process to kill when memory is exhausted." -- Diletante

==Move system folder on Windows XP== edit

Dear fellow Wikipedian: I am here today with a most singular question. Is it possible to MOVE a huge system folder (namely, C:/Documents and Settings/) to another partition on the same hard disk drive (namely, D:/) without much fuss? Can this move operation be transparent to the end user (so that [s]he does not have to know what I have done)?

The C partition has 11.17 GB capacity (7% free). The D partition has 12.89 GB Capacity (15% free [1]). The F drive has 13.22 GB capacity (15% free). Thank you for your kind co-operation. Yours sincerely, User:Kushal_one --Kushal User_talk:Kushal_one 22:43, 16 May 2007 (UTC)[reply]


[1] I can have this partition formatted, scanned, and defragmented before the move operation. Some details [2] on the configuration: (mostly useless) Processor: Intel (R) Pentium (R) 4 CPU 1.50 GHz L2 Cache: 256 KB Memory: 128 MB Monitor: Default Monitor Video Card: Intel (R) 82845G/GL/GE/PE/GV Graphics Controller Mode: 1024*768 with 16 bit color depth Input: Mouse: Standard Serial Mouse Keyboard: Standard 102/102-Key PS2 Keyboard Windows: Windows XP - Professional (5.1.2600) Service Pack 2 Installed: 12/18/2005 4:10:08 PM (Local time)

[2] Please remove personally identifiable information from this configuration description, if any. Thank you. User:Kushal_one PS: You can e-mail me if you like. Just click here and write away!.


Can we assume you tried to do a drag and drop of the folder to the new partition ? If so, what error did you get ? StuRat 23:59, 16 May 2007 (UTC)[reply]

I have not done anything yet. The computer might catch a cold or freeze altogether or something! I want the new location to be functional like the old onewith all applicaqtions apps and what not running smoothly and well and accessing their profile and application data folders as usual. Is it at all possoible? --Kushal User_talk:Kushal_one 23:37, 17 May 2007 (UTC) PS: I think I should add that the hard disk is an FAT 32 partitioned one.

Thank you Stuart for responding so swiftly.

From memory it is one of the options in TweakUI, otherwise you would have to manually mess with the registry.Vespine 00:26, 18 May 2007 (UTC)[reply]

Will it work? I mean ... will it work seamlessly? such redirecting Mozilla thunderbird to the new application data folder and so on .? has anyone tried it? User:Kushal_one (logged off at a public cyber caf`e) Offline

Wire gauge with 24v edit

I had a job interview a few months back (didn't get the job). One of the questions they asked me has been bugging me. IIRC, they asked me what gauge wire (AWG) is needed to wire a 24v circuit. I think this is one of those trick questions where you don't have enough information and the answer is "depends on the environmental conditions and amperage". However, I am coming here to see if anyone can help me figure this one out. Thanks. -Andrew c 23:20, 16 May 2007 (UTC)[reply]

Yeah, the voltage isn't really a big issue until you start to approach electric fields that could cause dielectric breakdown in the insulator (even small wires are frequently rated for 300-600 V). You'd generally choose wire gauge based on the current you expect it to be carrying since larger wires with lower resistance are needed for larger currents to prevent undue ohmic heating. For future reference, you might want to pose questions like this on the science reference desk. -- mattb 23:35, 16 May 2007 (UTC)[reply]
As you expect, the voltage has little relationship with the wire gauge, unless one is considering VHF and higher frequencies where skin effect becomes significant. The voltage has more to do with the insulator properties. Did the question address overall power transfer? For example, if a 24 VDC circuit is transferring 1200 watts, what gauge wire is appropriate? 1200 W / 24 V = 50 amps, so standard practice would call for 6 (or preferably bigger) gauge wire. —EncMstr 23:37, 16 May 2007 (UTC)[reply]
Thanks for your help. I was torn over where to ask this question (here of the science desk). -Andrew c 01:54, 17 May 2007 (UTC)[reply]
Besides the ampacity (current rating), you'll also need to consider the IR voltage drop. For low-voltage circuits, that often is the "ruling" consideration rather than ampacity, and you often end up using a much larger conductor than the minimum needed just to carry the current without damaging the insulation. You might enjoy our American wire gauge article.
Atlant 11:34, 17 May 2007 (UTC)[reply]