Wikipedia:Reference desk/Archives/Computing/2010 November 6

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Computing desk
< November 5 << Oct | November | Dec >> November 7 >
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.

November 6[edit]

Batch file to control network settings[edit]

My friends and I often get together and play games via LAN, but to do so, we always have to change our network settings considerably. First, we disable Windows Firewall. Then, we open 'Network Connections' and disable 'Wireless Internet Connection'. I don't see how those two steps are necessary, but some of our games seem to take issue if we don't do them. :\ Then we right-click on 'Local Area Connection', select 'Properties', then 'Internet Protocol (TCP/IP)', then 'Properties', select 'Use the following IP address', and type one in. I think that's called setting up a static IP? Anyway, then we go back to 'Network Connections' and do the same for '1394 Connection 13'. Is there were a way to create a batch file that would automate this? And hopefully one that would reverse it too. KyuubiSeal (talk) 01:12, 6 November 2010 (UTC)

The netsh command is used to manipulate most of the Windows IP stack parameters from the command line. here is an example. (talk) 01:54, 6 November 2010 (UTC)
It sets the 'Local Area Connection' correctly, but nothing else. At least that's a third done though. KyuubiSeal (talk) 03:31, 6 November 2010 (UTC)
netsh interface set interface "Local Area Connection" DISABLE
netsh interface set interface "Local Area Connection" ENABLE (talk) 03:39, 6 November 2010 (UTC)
I can get it to set the static IPs correctly, but I can't disable Windows Firewall and the wireless network. When I try swapping in 'Wireless Network' for 'Local Area Connection' in the above lines, it gives me this error:

One or more essential parameters not specified The syntax supplied for this command is not valid. Check help for the correct syntax. Usage set interface [name = ] IfName [ [admin = ] ENABLED|DISABLED [connect = ] CONNECTED|DISCONNECTED [newname = ] NewName ] Sets interface parameters. IfName - the name of the interface admin - whether the interface should be enabled (non-LAN only). connect - whether to connect the interface (non-LAN only). newname - new name for the interface (LAN only). Notes: - At least one option other than the name must be specified. - If connect = CONNECTED is specified, then the interface is automatically enabled even if the admin = DISABLED option is specified. —Preceding unsigned comment added by KyuubiSeal (talkcontribs) 00:07, 7 November 2010 (UTC)

Is there a way to get a "wikitable sortable" table to correctly sort by "year"?[edit]

I am specifically working with the table at The 100 Best Books of All Time, the entries of which have been altered and provided below as an example:

Title Author Year Country
Dts Example No one 2000 BC Nowhere
Things Fall Apart Achebe, ChinuaChinua Achebe 1958 Nigeria
Epic of Gilgamesh Anonymous 18th or 17th century BC Mesopotamia
Book of Job Anonymous ? Israel
Mahabharata Anonymous 4th century BC – 4th century AD India
Dtsh Example No one Late 2nd century BC Nowhere
Dts Example No one 3000 BC Nowhere
One Thousand and One Nights Anonymous 9th century Arabia, Persia, India
The Decameron Boccaccio, GiovanniGiovanni Boccaccio 1349–1353 Italy
Don Quixote Cervantes, Miguel deMiguel de Cervantes 1605–1615 Spain
Ramayana Valmiki 3rd century BC – 3rd century AD}} India
Aeneid Virgil 29 – 19 BC Italy
Leaves of Grass Whitman, WaltWalt Whitman 1855 USA

See what happens when you sort by the "Year" column.
I started with template:Sort (eg. "{{sort|850|9th century}}" which should sort by "850" and display "9th century", right...?).
Template:Dts seems to work well enough, but does not permit an "alternate text".
Template:Dtsh-with-text-following-it just doesn't seem to work.
Is there some way to deal with this -- ie., to get that "Year" column with entries of the kind shown above to sort correctly -- that I am just not seeing? WikiDao(talk) 01:45, 6 November 2010 (UTC)

I would have thought {{ntsh}} would work, but for some reason it doesn't like those -ve values:
Title Author Year Country
Dts Example No one -2000 Nowhere
Things Fall Apart Achebe, ChinuaChinua Achebe 1958 Nigeria
Epic of Gilgamesh Anonymous 18th or 17th century BC Mesopotamia
Book of Job Anonymous ? Israel
Mahabharata Anonymous 4th century BC – 4th century AD India
Dtsh Example No one Late 2nd century BC Nowhere
Dts Example No one -3000 Nowhere
One Thousand and One Nights Anonymous 9th century Arabia, Persia, India
The Decameron Boccaccio, GiovanniGiovanni Boccaccio 1349–1353 Italy
Don Quixote Cervantes, Miguel deMiguel de Cervantes 1605–1615 Spain
Ramayana Valmiki 3rd century BC – 3rd century AD India
Aeneid Virgil 29 – 19 BC Italy
Leaves of Grass Whitman, WaltWalt Whitman 1855 USA (talk) 03:30, 6 November 2010 (UTC)
Yes I had tried {{ntsh}} too, forgot to mention that. WikiDao(talk) 12:36, 6 November 2010 (UTC)
Ah, which {{Nts}} explains. You could hack it by having a search index that you manually order (e.g. {{subst:User:Jimp/sandbox|3}}-417BC). (talk) 03:35, 6 November 2010 (UTC)
Yes I tried that as mentioned in question. WikiDao(talk) 12:36, 6 November 2010 (UTC)
Have you read Help:Sorting? ---— Gadget850 (Ed) talk 03:39, 6 November 2010 (UTC)
Yes, the problem is that the information there doesn't seem to help with my specific set of difficulties. {{nts}} says "Negative numbers do not sort correctly with this template" but doesn't really say why, or how to get them to do so instead.
I have also tried using just html, for example: "<span style="display:none" class="sortkey">-1750</span> 18th or 17th century BC". Haven't got that sort of thing to work yet either; still working on that.
The primary problem seems to be with sorting "negative" or "BCE" dates along with "positive" or "CE" dates in the same column. Because none of what I would have thought to be the applicable templates seem to treat negative numbers numerically. WikiDao(talk) 12:36, 6 November 2010 (UTC)

Windows 7 file permissions[edit]

I have recently installed Win 7 Professional 64-bit. Upon trying to copy over my personal Apache setup, I was stumped by my inability to save a configuration file change. At first I thought the file(s) might be locked, but this issue is system-wide: I simply can't modify a file outside of my User directory. I've reviewed the web and can see that many users have had similar issues, but can't find anything that fully addresses this.

My account is an administrator and if I review the "effective permissions" for a particular file, it says that I have full control of the file. Yet I can't save a modification to it. The only broad solution to date is to completely turn off User Account Control. Here are two additional clues: explicitly making my account name the "owner" by itself does not change anything, but if I then add my account to the main Permissions area, then I can edit the file. Granting "full control" to the Users group also fixes the problem, but this is not an appropriate solution.

This situation is, to put it mildly, absurd. Is there actually a robust solution to this, one that does not require messing with permissions to accomplish simple tasks? I thought Win7 was supposed to be a panacea from Vista, and I encounter an even stranger problem right from the start, setting me back hours. I've about had it with MSFT.

Thanks, Riggr Mortis (talk) 06:40, 6 November 2010 (UTC)

I don't understand. Preventing modification of files outside the user directory is kind of the point of UAC, and you seem to want to keep UAC turned on, but you say the behavior you observe is absurd. What behavior do you want? You can right-click a program and select "run as administrator" to run it without UAC restrictions.
The "improvement" in Windows 7 was that Microsoft exempted its bundled software, such as Explorer, from UAC at the default notification level. That makes UAC nearly useless, since some of the exempt programs can be coerced into executing arbitrary code, but people think it's better because they see fewer annoying prompts. -- BenRG (talk) 08:26, 6 November 2010 (UTC)
Actually I'm more mystified then that. AFAIK, programs running without UAC can modify most files outside the user directory. The root, program files directory, Windows directory and other system directories are protected against modification for obvious reasons. If you are trying to save a config file to a program directory, while that's usually considered a bad idea in most OSes nowadays AFAIK (even if it was common in some Windows in the past) except for portable apps (which shouldn't be in the program files directory) you can do so by putting that program outside the program files directory. Nil Einne (talk) 10:33, 6 November 2010 (UTC)

Regarding config files, of course... but Apache defaults to \Program Files\ for its entire install, and since I do one thing with Apache I'm not getting fancy.

What behavior do I want? Well, my account is marked Administrator, and I would expect that fact to be sufficient to edit a bloody text file anywhere on the drive, all other things being equal. Are you suggesting it's not odd that the system tells me I have effective "full control" permissions over, say, "C:\Program Files (x86)\Apache\README.txt", yet I don't? Riggr Mortis (talk) 21:09, 6 November 2010 (UTC)

BenRG: it's not that I want to keep UAC on. I will probably end up leaving it off entirely. I did on Vista, but at the same time I don't remember UAC being that intrusive on Vista. If someone simply said "UAC and administrative permissions logically conflict on Win 7", well that would answer my question, I suppose. Riggr Mortis (talk) 21:20, 6 November 2010 (UTC)

The idea of UAC is that your user account has administrative privileges but most processes are started with only some of those privileges, so yes, this is expected behavior. It's somewhat more like the Java applet security model than the traditional Unix model. I don't know the details well enough to respond to Nil Einne above. -- BenRG (talk) 23:23, 6 November 2010 (UTC)
AFAIK Vista has the same behaviour. See [1] which mentions similar issues. However virtualisation is available on some versions as a stopgap measure, see [2]. User Account Control mentions this as well. Of course another option would be if Apache really wants to put the config files in program files directory would be for it to be better designed to utilise UAC and raise a prompt when it wants to modify the config. As BenRG has said, Windows's UAC is sort of a way of limiting privilages to apps even if you are technically running as administrator. Partially because very few people were actually using limited accounts as has been recommended for a long time, partially because many Windows programs are shoddily designed and do expect full administrator privilages and UAC was fairly effective in convincing developers to design their programs better I would say. If you genuinely want full adminstrative priviliges all the time and for all programs then turn it off. Of course this isn't recommended in any common OS I know of (and in fact some like Ubuntu actively try to stop people running as root/superuser all the time). Nil Einne (talk) 01:41, 7 November 2010 (UTC)



I have 700 html files, and I need to extract all urls from them which contain "/example123/". I'm on Windows 7. How could this be done, preferably with free software? (talk) 10:30, 6 November 2010 (UTC)

You can get grep for free for Windows and then grep for "http[^'\"]*/example123/[^'\"]*". The exact syntax of the grep may depend on the implementation of grep in Windows. -- kainaw 14:31, 6 November 2010 (UTC)
I found a windows gui version for it, which has worked quite well. Thanks (talk) 14:59, 6 November 2010 (UTC)
Grep is good. I also wrote a short vbscript for this in 07. Maybe it will be of use to somebody.Smallman12q (talk) 15:25, 6 November 2010 (UTC)
'Public Domain November 2010
'Version 1.1
'Written by Smallman12q in Visual Basic Script (VBS)

'Desc: This vbs script will find the urls in a html files and save them to a text file in the directory
'Usage: Simply drag-and-drop the html files onto the script.

'1.0 (April 2007)
'1.1 (Nov 2010) Change-Added support for multiple drag and drop

Dim urlarray(2000)'Change number to whatever will be the max number of urls you expect to find
Dim urlcounter

Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?"'Change the regex pattern here (this one does all websites)
objRegEx.IgnoreCase = True 'Change to false to not ignore case
objRegEx.Global = True

Dim targetdirectory 
targetdirectory = "C:\SomeExistingFolder\SomeFile.txt" 'Place the file path where to record 

Sub findit(item)
	'Make sure its an html/htm file
	If (Right(item, 5) = ".html") Or (Right(item, 4) = ".htm")  Then 
		Const ForReading = 1
		'Read file
		Set objFSO = CreateObject("Scripting.FileSystemObject")
		Set objFile = objFSO.OpenTextFile(item, ForReading)
		Do Until objFile.AtEndOfStream
		    strSearchString = objFile.ReadLine
		    Set colMatches = objRegEx.Execute(strSearchString)  
		    If colMatches.Count > 0 Then
		        For Each strMatch in colMatches 
		            urlarray(urlcounter) = strMatch.value
		            urlcounter = urlcounter + 1
		    End If
	End If
End Sub

'Check to make sure drag-and-drop
If( WScript.Arguments.Count < 1) Then
	MsgBox "You must drag and drop the file onto this."
	WScript.Quit 1 'There was an error
Else 'There are some arguments
	Set objArgs = WScript.Arguments
	For I = 0 To objArgs.Count - 1 'Check all the arguments
	'Write urlarray to file
	Const ForAppending = 8
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objTextFile = objFSO.OpenTextFile(targetdirectory, ForAppending, True)
	For count = 0 To urlcounter
	MsgBox("Found " & urlcounter & " urls.")
End If

WScript.Quit 0 'Exit okay


My graphics card; not good enough?[edit]

I have a ATI mobility radeon HD 4530 graphic card/processor.

I suspect it might not be enough for a program I will soon run on my computer.

The program's sytem rquirements: Minimum requirements: ATI Radeon 7200 Recommended requirements: ATI Radeon X1600

is my graphic card outdated, is it absolutely necessary that I upgrade or get a new graphic card altogether if I am to be able to run the program? Or is my current graphic card good enough to match the minimum requirements? I know it's more to it than only graphics card but it seems to me this is probably where my computer's weakness lies. It's a laptop, so maybe it's not so surprising if the graphic card isn't among the best.

Is it possible to upgrade or get new graphics cards like the ATI Radeon 7200 or ATI Radeon X1600 on the internet, or do I have to go to a software store?

Krikkert7 (talk) 12:02, 6 November 2010 (UTC)

It is not outdated, at least for these requirements. 7200 is very old (from year ~2001 or 2002) and x1600 is newer, but still older than 4530 (x1600 is from 2006). 4530 might be quite low end device, but it still should be comparable to x1600. -Yyy (talk) 12:28, 6 November 2010 (UTC)

hm.. that's good news I would say, but quite different than what I read earlier. But that's the good thing I guess about asking around, getting several opinions. Krikkert7 (talk) 13:00, 6 November 2010 (UTC)

is it possible to distribute a large database as many ways as you want?[edit]

or, in general, no? (talk) 13:25, 6 November 2010 (UTC)

You need to define "distribute". If you mean "send the data to another location", the answer is "yes". You can send it over the web. You can remote connect through an ODBC interface. You can SFTP CSV files. You can put it on a CD, duct-tape it to a monkey, and send him overseas on a freighter. If you intend "distribute" to mean "show the data to users", you are referring to what most people call a "view". You can set up as many views as you like. -- kainaw 14:29, 6 November 2010 (UTC)
If you mean, can you have the database exist in different chunks on different machines, you could, but it would present certain practical difficulties. --Mr.98 (talk) 14:46, 6 November 2010 (UTC)
I think the OP means federating the database - distributing its data across many servers. This is possible, but is a feature that is significantly easier on commercial database platforms (like IBM DB2), as compared to, say, MySQL. Here's a technical-series from IBM called Data Federation and Data Interoperability. Here, for comparison, is the same concept in MySQL. Oracle calls this "clustering" although it has fewer features and capabilities; they have a white paper comparing federation to clustered distribution: Database Architecture: Federated vs. Clustered. Nimur (talk) 15:02, 6 November 2010 (UTC)

Whole Disk Encryption[edit]

Does whole disk encryption cause extra stress on a hard drive, such as for re-reading the keys and so forth? I'm specifically thinking of an SSD drive, and whether whole disk encryption will shorten its useful life due to lots of extra read/writes. —Preceding unsigned comment added by (talk) 14:49, 6 November 2010 (UTC)

No, it doesn't cause any significant extra stress for the hard drive. The keys (or key files) are relatively small, ussually less than 1MB so there's no extra stress there (The keys are read once on boot and stored in ram). The only increase in read/write will come from the actual extra space the encrypted form takes...though this ussually isn't significant (depends on algorithm). The actual encryption may stress the CPU a bit though...unless the encryption is performed by a dedicated chip on the hard-drive. But overall, the answer is no...disk encryption doesn't stress/reduce the life of the hd.Smallman12q (talk) 17:07, 6 November 2010 (UTC)
When using popular full-disk encryption products like TrueCrypt and BitLocker, the encrypted data doesn't take up any more space. There are no extra disk accesses whatsoever except at boot time. Well, technically, since the encryption code takes up a small amount of RAM, there might be a little bit more virtual memory paging, but I doubt you'd notice the difference. -- BenRG (talk) 23:13, 6 November 2010 (UTC)

smallest, most compact and self-contained C++ compiler for Windows[edit]

so, my favorite editor is notepad2, which is TINY, and totally self-contained. Really just an .exe and maybe an .ini to go with it. I realize, due to at least standard libraries, that I do not have much of a hope of finding a similar Windows c++ compiler. Still, I dare hope.

what is the smallest, most compact and self-contained, C++ programming environment for Windows? We're talking something that you could run on a netbook and is not a messy, huge environment, but just a compact set of files. thank you! (talk) 17:56, 6 November 2010 (UTC)

Dev-C++ is pretty self-contained. It is a complete IDE, including a text-editor and build system; it uses MinGW (gcc) as its compiler. Alternately, you can download gcc, packaged for Windows as mingw ("Minimalistic GCC for Windows), if you only want a command-line compiler. Microsoft Visual Studio Express is pretty light-weight as well. Nimur (talk) 18:03, 6 November 2010 (UTC)
Microsoft's C++ compiler runs from the command line and is configured with environment variables, very much like gcc (though all of the command line switches have different names). I haven't compared their sizes, but I suppose they're similar if you only keep the headers and libraries that you plan to use. Microsoft's compiler is quite a bit faster than gcc, which might matter if you want to do a lot of big builds on battery power. It also optimizes somewhat better for x86. Other than that, you could go either way. -- BenRG (talk) 23:38, 6 November 2010 (UTC)

how does this work?[edit]

how does "westley" here work? (1988). I mean, could someone write a 300-word paragraph describing in excrutiating detail how the pseudocode would look if it were written in nearly formal English? I am just having too much trouble following it... What the program does: SPOILER: . it's supposed to calculate pi by looking at its own area. strikeout for spoiler. /SPOILER84.153.207.135 (talk) 18:22, 6 November 2010 (UTC)

Did you read the hint? It's important that you either make the adjustment in the hint, or use a really old compiler that does dumb preprocessing. I'll assume you're interested in the original version, with the dumb preprocessing.
The first line of F_OO is 4 instances of the "_" macro separated by 3 minuses. Here's how it looks after preprocessing:
It has become a sequence of 4 statements. The first one is different from the others, because it didn't have a minus before it. Each statement is a pair of clauses separated by "||", the short-circuit operator which evaluates the expression on the right only if the expression on the left was false. The result of the "||" operator is not used. So the statements are equivalent to
The double 0 isn't important, it's just a zero that helps put more "foo"-looking things in the code. -F<0 is true if F>0, which will never happen in this program because F starts at 0 and decreases from there. So in the first if statement, the condition is true and the --F-OO-- gets executed. --F-OO-- is equivalent to (--F)-(OO--) meaning F is decremented, and OO is decremented, and the old value of OO is subtracted from the new value of F, but that last part doesn't matter since the result of the subtraction is not used. From their initial values of 0, F and OO have both become -1.
In the second statement, --F<00 causes F to first be decremented again, then its new value (-2) is compared to 0. -2<0 is true so the --F-OO-- is not evaluated. The third and fourth statements act likewise, bringing F down to -4 while OO stays at -1.
The following lines are similar. For each line, the number of times F is decremented is the number of "_" expansions in the line, while OO is decremented only once per line. At the end, OO is the count of lines, corresponding to the diameter of the circle, and F is the total count of "_" expansions, corresponding to the area of the circle. They're both negative, but that's fixed in the printf statement. 4*area/diameter/diameter is printed. (talk) 21:48, 6 November 2010 (UTC)
There's an article at International_Obfuscated_C_Code_Contest#Examples...though its scant on details.Smallman12q (talk) 01:30, 7 November 2010 (UTC)


Approximately how much bandwidth is used when a program, such as a web browser or crawler, asks the remote server how new a file is? (talk) 21:22, 6 November 2010 (UTC)

OK so here's my browser asking Wikimedia about the file
My browser sends:
GET /skins-1.5/vector/images/arrow-down-icon.png?1 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;rv: Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
If-Modified-Since: Wed, 05 May 2010 19:06:38 GMT
If-None-Match: "bc-485dd86856b80"
Cache-Control: max-age=0
And the server replies the file was modified in May:
HTTP/1.1 304 Not Modified
Date: Sun, 07 Nov 2010 08:35:46 GMT
Via: 1.1 varnish
X-Varnish: 1179536182
Last-Modified: Wed, 05 May 2010 19:06:38 GMT
Cache-Control: max-age=2592000
Etag: "bc-485dd86856b80"
Expires: Tue, 23 Nov 2010 14:42:06 GMT
Connection: keep-alive
That's 830 bytes, but most of the stuff the browser sends are not necessary, so you can make it less than half a K. F (talk) 08:45, 7 November 2010 (UTC)
It's also gzip encoded (Look at the Accept-Encoding line), so it's smaller. However there is the TCP/IP overhead, which could easily make up for what the compression gains. Shadowjams (talk) 04:19, 8 November 2010 (UTC)