Jump to content

Wikipedia:Reference desk/Archives/Computing/2011 January 25

From Wikipedia, the free encyclopedia
Computing desk
< January 24 << Dec | January | Feb >> January 26 >
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.


January 25

[edit]

Apple compatible

[edit]

Why are there IBM compatibles, but no Apple compatible computers (aside computers made by apple itself)? ScienceApe (talk) 02:13, 25 January 2011 (UTC)[reply]

See Mac clone. Dismas|(talk) 02:32, 25 January 2011 (UTC)[reply]
These day, basically all personal computers have the same i386-based architecture, so in some sense, they're all Apple compatible. There are technical issues, but they are relatively minor; see OSx86. The main obstacle is legal: Apple forbids the use of OS X on machines not sold by them. Paul (Stansifer) 04:05, 25 January 2011 (UTC)[reply]
In short, legal reasons. Apple adopted, in the nascent days, a proprietary architecture model, where IBM adopted an open architecture model. As a result IX86 clones abound but apple is the one and only arbiter of appleness. It would be possible to emulate Apple architecture on any X86 if only apple legally allowed it. The fundamental disagreement is one of format, IBM X86 and it's latter-day successors prefer open architecture, Apple prefers to chain users to their system. As a result X86 emulators abound but Apple emulators are nonexistant, thanks primarily to the fact that almost all software companies of note develop for X86 natively. 65.29.47.55 (talk) 08:33, 25 January 2011 (UTC)[reply]
I feel the need to pick at the original question and the answers. "Apple compatible computers" is an imprecise term, because Apple has created several lines of computers. The original poster is asking about modern Apple Macintosh compatible computers. If we reach back to the early days of Apple, there were several Apple II compatible computers, like the Franklin ACE; and in the early PowerPC days there were licensed Mac clones, as described above. That aside, 65 is correct; Steve Jobs has always hated the idea of having uncontrolled 3rd party hardware vendors creating hardware that runs his OS, and Apple has therefore adopted every legal stratagem possible to prevent this (at least, while Jobs has been at the helm). Comet Tuttle (talk) 18:53, 25 January 2011 (UTC)[reply]

Few more questions. Why did IBM not do the same thing? Weren't they hurt by all of the other companies making their stuff? I mean IBM doesn't even make computers anymore. Why was it possible for a 3rd party company like microsoft to make an operating system for IBM computers but it wasn't possible for a 3rd party to make it for Apple computers? Didn't IBM not like Microsoft making an OS for their computers? ScienceApe (talk) 22:29, 25 January 2011 (UTC)[reply]

IBM thought they had. IBM licenced DOS (which was really a CP/M clone) from Microsoft - the IBM PC DOS explains that IBM actively wanted MS to keep copyright (for complicated IBM reasons) - but it didn't occur to IBM that a true clone could be made. They relied on the IBM BIOS copyright from keeping out clones - but Phoenix reverse-engineered the BIOS, which enabled Compaq (and then others) to produce legal IBM compatibles. And Microsoft were very happy to sell those guys MS-DOS. In retrospect IBM's decisions weren't ideal, but IBM still made big bags of money off PCs for a decade or more, so don't cry for them. -- Finlay McWalterTalk 23:11, 25 January 2011 (UTC)[reply]

Finding weev at bop.gov

[edit]

Hi!

http://arstechnica.com/apple/news/2011/01/goatse-security-trolls-were-after-max-lols-in-att-ipad-hack.ars says that weev is now in federal custody

But he hasn't appeared yet on the Federal Bureau of Prisons locator at http://www.bop.gov/iloc2/LocateInmate.jsp , and I know that so far he has no bail

I tried several variations of his name, and I can't find him on the BOP site

What variations of his name do you think will bring up his records on the BOP site?

WhisperToMe (talk) 05:48, 25 January 2011 (UTC)[reply]

As far as I know, "in custody" does not mean that he has been consigned to the prison system. That won't happen until he has been tried, found guilty, and sentenced. He is most likely in a holding cell somewhere, possibly a sheriff's office local to where he was arrested. --LarryMac | Talk 19:34, 25 January 2011 (UTC)[reply]
In the United States, when a suspect is arrested for a federal offense, whether they were investigated by the FBI or any other federal agency, the arresting officer is usually a United States Marshal, who may choose to work in conjunction with other Federal and local law enforcement agencies. The suspect is almost always placed in the custody of a local (usually a county-level) law enforcement agency that has a previous agreement to hold Federal inmates for a period of time. You can search the county corrections facilities for records of special federal inmates. In the first hours of processing, a suspect will be held by a United States Marshal officer, and within a few hours, transferred to a county sheriff or other local law enforcement or corrections officer operating as a Federal deputy. Because Federal legal procedures are significantly different than local processes, the inmate may be transferred to any jurisdiction in the United States, as circumstances require. Within a certain period of time that can range from a few hours to several days, a Federal judge will initiate a legal process called an "initial hearing." Bail may or may not be granted. (That means the suspect may be permitted to go home, for a length of time decided by a judge, but will be re-arrested later, when the court is ready to proceed). Finally, the suspect is brought back to Federal custody, and the court process begins; during this period of time, the inmate will remain in custody of a Federal officer and/or local deputies. After the suspect is arraigned and sentenced (if convicted), (which can be many years later), they will be immediately transferred to Federal incarceration, managed by the Federal Bureau of Prisons. The handy "Know Your Rights" card from the ACLU is actually stunningly deficient regarding the processes that will take place if you are arrested by Federal law enforcement agents. But you can read all about it on the Marshal Service website: Defendants in Custody and Prisoner Management. "The Marshals Service assumes custody of individuals arrested by all federal agencies and is responsible for the housing and transportation of prisoners from the time they are brought into federal custody until they are either acquitted or incarcerated." So if you are looking for a recently-arrested Federal suspect, you need to contact the Marshals Service, and they will be required by law to disclose which jurisdiction the suspect is being held. That does not mean that they must tell you where he is - only under what jurisdiction he is in custody, if he is actually being held. Contact an attorney if you need help locating a suspect or inmate, because the legal process is complicated; the suspect must be protected by law enforcement agents, and this means that they will not just tell "anybody who asks" where he is. Nimur (talk) 19:59, 25 January 2011 (UTC)[reply]

What font?

[edit]

What is this font academic papers tend to use quite a bit? http://arxiv.org/pdf/1101.4241 --128.54.224.231 (talk) 07:05, 25 January 2011 (UTC)[reply]

for reasons of formatting most academic papers in my experience use a monotype font most computers are likely to have. Monotype is important because it preserves spacing, especially in situations where precise spacing is important like legal documents. Courier New seems to be quite popular. 65.29.47.55 (talk) 08:36, 25 January 2011 (UTC)[reply]
Computer Modern. Titoxd(?!? - cool stuff) 08:42, 25 January 2011 (UTC)[reply]
The font used at the OP's link is cetainly not Courier New which is a typerwriter-like monospaced font. It is approximately like Caslon and in MS Word the nearest I can find is Brookman Old Style. I think it is more common in older textbooks than modern articles. Cuddlyable3 (talk) 09:20, 25 January 2011 (UTC)[reply]
Good heavens, don't you folk recognise Knuth's Computer Modern when you see it? It was once almost universally used in academic typesetting because it's the default font in TeX. Marnanel (talk) 12:42, 25 January 2011 (UTC)[reply]
Exactly. Documents that look like this have been prepared in some form of TeX (usually LaTeX). --Mr.98 (talk) 13:10, 25 January 2011 (UTC)[reply]
Actually Titoxd did Nil Einne (talk) 22:02, 25 January 2011 (UTC)[reply]

How to download and join together text from webpages?

[edit]

I would like to download all the Exhibitor links from this page http://www.icetotallygaming.com/exhibitors/list , and then join all the details together into one long text document. What would be the easiest way to do it please, rather than doing it manually? I use WinXP, and Firefox, also IE. Thanks. 92.15.2.19 (talk) 12:14, 25 January 2011 (UTC)[reply]

I don't think there's an easy way to do this. You could try using wget to download all the links to one output file with something like
-r -I */list -np -O output.html "http://www.icetotallygaming.com/exhibitors/list/"
however this would include everything on each page (banners, adverts, etc) and result in a very large single html file (my test was around 20mb). From there you might be able to use grep (a windows version available here) or something like that to extract the text you want based on set parameters and build a single text file with just the information you want, but this goes beyond my experience so I don't know how to do that or even if it would work. 82.44.55.25 (talk) 19:07, 25 January 2011 (UTC)[reply]

Thanks. Is there any way to save the html only, not anything else? Saving it all to one file is not essential, as I expect there is software available that caqn join files up. Incidently, where would the output be saved please? (So often a mystery with "nerdy" programs). 92.15.10.209 (talk) 14:29, 26 January 2011 (UTC)[reply]

I had some free time yesterday so I took a run at this. The script is below. The output is here. You'll have to download the output.html file to your local machine and open it with your browser. --Sean 13:45, 27 January 2011 (UTC)[reply]
#!/usr/bin/perl -w

use strict;
use Data::Dumper;
use HTML::TreeBuilder::XPath;
use LWP::Simple;
use URI::Escape;

sub grab
{
    my $url = shift;
    my $fname = uri_escape $url;
    return $fname if -f $fname;
    my $rc = getstore $url, $fname;
    unless (is_success($rc))
    {
        unlink $fname;
        die "$url: $rc";
    }
    return $fname;
}

binmode(STDOUT, ":utf8");

my $base = 'http://www.icetotallygaming.com';
my $list_fname = grab "$base/exhibitors/list";
my $list_doc = HTML::TreeBuilder::XPath->new_from_file($list_fname);

my %saw_css;
my @sheets;
my @rows;
my $xpath = q(//*[contains(concat(' ', @class, ' '), ' view-exhibitors ')]//a);
foreach my $link ($list_doc->findnodes($xpath))
{
    my $href = $link->attr('href');
    next unless $href =~ m,^/exhibitors/list/,;
    my $url = "$base/$href";
    my $fname = grab $url;
    open(my $fh, "<:encoding(UTF-8)", $fname) or die "$fname: $!";
    my $doc = HTML::TreeBuilder::XPath->new_from_file($fh);
    my $blurb = $doc->findnodes_as_string("//*[\@id='content-main']");
    push @rows, "<tr><td>FROM: <a href='$url'>$url</a><br>$blurb</td></tr>\n"; 

    my @css_links = $doc->findnodes("//link");
    foreach my $css_link (@css_links)
    {
        next unless $css_link->attr('type') eq 'text/css';
        my $css_href = $css_link->attr('href');
        $css_href = "$base$css_href" unless $css_href =~ /^https?:/;
        next if $saw_css{$css_href}++;
        push @sheets, qq(<link href="$css_href" media="all" rel="stylesheet" type="text/css">\n);
    }
}

print <<EOF;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   @sheets
 </head>
 <body>
  <table border=1>
   @rows
  </table>
 </body>
</html>
EOF

Thank you very much! 92.15.12.148 (talk) 17:48, 27 January 2011 (UTC)[reply]

LibreOffice or OpenOffice Writer file formats

[edit]

I'm having trouble answering this question because I'm not sure of the terminology in the articles and websites I've looked at.

Can LibreOffice or OpenOffice read and write the file format used in the current format of MS Word?

ike9898 (talk) 14:34, 25 January 2011 (UTC)[reply]

OpenOffice can read/write both the older and current version of MS Word documents. There is issues with image placement and indexes, but the main text opens/saves well. -- kainaw 15:22, 25 January 2011 (UTC)[reply]
Any idea if this is the same for LibreOffice? ike9898 (talk) 15:53, 25 January 2011 (UTC)[reply]
Yes. -- kainaw 16:43, 25 January 2011 (UTC)[reply]
Actually, from my experience, the compatibility is quite high between Word and OOo. I wonder how it's going to be with LibreOffice, will it also be as compatible? --Ouro (blah blah) 07:07, 27 January 2011 (UTC)[reply]
I'm not sure if they've even changed that part of the code, from the few documents I have seen so far LibreOffice seems to be identical in the rendering of Office documents (.doc). I have not tried any .docx but I don't think it would be different. LibreOffice is basically OpenOffice repackaged, down to "sun" appearing in the object names in the API -- Q Chris (talk) 07:30, 27 January 2011 (UTC)[reply]
In fact, I have successfully used OOo to recover a corrupted .doc file which would not open correctly in Word itself. And since LibreOffice is a fork of OOo, I would think only changes in the code are improvements.

Searching huge number of files, don't want to hang server (grep?)

[edit]

Hi all,

I am searching for a specific string that could be in any file in a large Linux server. I have access to the server but don't own it, so I don't want to do anything that might slow it down, like some badly formed regex that loops through all the files for ever or something dumb like that. I don't need it to be fast, but I would like to get results as soon as they come in, if possible (i.e. if it finds a result immediately, but still has an hour of searching to do, I don't want it to wait an hour before telling me).

What would be the best way to do this, assuming that server has a standard set of search tools?

The only way I know is to do a recursive grep from the root directory:

grep -r "my text" *

Will that slow anything down if it has to search a huge number of files? Will it return results as they come?

Thanks! 63.138.152.196 (talk) 17:15, 25 January 2011 (UTC)[reply]

You can wrap your grep command (or any other program) inside a shell script. Then, tell Linux to run the script with nice - the nice level sets a "priority" for your script, allowing it to slow down if other programs or users want CPU or disk access. Here's an example. Depending on your Linux/Unix, you may need to set ionice (file and disk access priority) separately from CPU nice - this is a place where your man page on your specific machine will be more helpful than a web search. (man ionice).
The purpose of this exercise is that your script will use 100% of the CPU and disk access speeds, as long as nobody else is using them; but if any other process or user has work to do, your process will gracefully slow down - so you won't "hog the machine" even if your job takes hours. Nimur (talk) 17:23, 25 January 2011 (UTC)[reply]
Be careful with grep -r; the version I have follows symlinks and thus can easily get into a loop. Use find / -xdev -print0 | xargs -0 grep -F string. The -xdev causes find(1) to search only one filesystem (the root), so it avoids things like /dev and /proc that are often special filesystems that don't contain real files. (If your server has multiple interesting filesystems (check with mount), you can name the mount point for each on the command: / /home /tmp or so.) The -print0/-0 allows any file names whatsoever to be used. The -F makes grep(1) search for fixed strings rather than regular expressions. This command or yours will produce results as soon as it finds them (at least if the output is to a [pseudo]terminal, and probably otherwise anyway). --Tardis (talk) 19:48, 25 January 2011 (UTC)[reply]

Coding puzzle

[edit]

I'm trying in Basic to compare A$(z) with B$(X,Y). If A$() and B$() are identical, then I want a result of 1. So if both strings are "qwerty" or if both are "" then the answer should be 1.

An extra requirement is that if B$() is a substring of A$() then it is only matched if the substring starts from the beginning of the other string. If A$()="QWERTYUIOP" and B$()="QWERTY" then the result should be 1, but zero where A$()="ZQWERTYUIOP" for example.

It took me a long time debugging until I found out that INSTR(1,A$(),B$()) gives a result of 1 where A$()="QWERTYUIOP" but B$() is just "". Not what I would call a match. (Note that INSTR() gives a result of 0 when used to compare "" with "").

Can anyone suggest a convenient way to achieve the above please? There is a wide range for Z and X but only 0 to 3 for Y. Thanks 92.15.22.33 (talk) 18:33, 25 January 2011 (UTC)[reply]

Look into using LEFT$() which should be available in your version of BASIC. Comet Tuttle (talk) 18:46, 25 January 2011 (UTC)[reply]
I was just looking that up, myself. LEFT$(N) isn't equivalent to Python's "startswith", it just returns the first N characters of the string. Some kind of loop with LEFT$ might work, but the first thing it would do is compare the first zero characters of A$ to the first zero characters of B$, and get a match. 81.131.30.212 (talk) 19:01, 25 January 2011 (UTC)[reply]
There's a bit of a logical ambiguity here, because "QWERTYUIOP" really does begin with "". If you want "" to match "" and "QW" to match "QWERTYUIOP", then "" also matches "QWERTYUIOP", unless you specifically rule it out. 81.131.30.212 (talk) 19:01, 25 January 2011 (UTC)[reply]
In most programming languages (including most implementations of BASIC), the empty string is a distinct entity from a null String. (In C we would represent an empty string as a valid pointer to an array whose first element is '\0'; while a null string would be an (invalid) pointer to a null address). Most BASIC implementations use the same concept, even if the implementation of pointers is opaque to the programmer. Nimur (talk) 19:17, 25 January 2011 (UTC)[reply]
I didn't know BASIC could have null pointers. Is it possible to set a string to NULL, then? "S$ = 0" gives "Type mismatch". DIM A(0) produces a single-element array, not a zero-element one. 81.131.30.212 (talk) 19:33, 25 January 2011 (UTC)[reply]
Just to quibble, what you are calling "the null string" is not a string of any kind. In languages with more watertight type systems, in order to talk about something that might be a string, or it might be nothing, you need to give it the type Maybe String or String + Nothing or something along those lines. All strings begin with the empty string. Paul (Stansifer) 20:26, 25 January 2011 (UTC)[reply]
Yes, the concept of a "null string" is pretty weird, and not found in most languages. The dialects of BASIC that have them are really a Java-like languages with slightly different syntax, and don't have a whole lot in common with traditional BASIC. C++ doesn't have null std::strings. C doesn't have strings at all, but does have "null pointers", which are also a weird concept. Special null values in statically typed languages are just a hack to get around the lack of convenient typesafe unions in those languages. -- BenRG (talk) 20:52, 25 January 2011 (UTC)[reply]
Digression: programmers use null for the Maybe semantics, but that's generally not what it's put in the language for. In Java, I believe it was considered necessary so that there was something to implicitly initialize references to, because Java guarantees that it will never examine uninitialized memory. The alternative would be that the programmer would need to provide a default value when they allocated a new array, which would be pretty icky. Truly type-safe languages typically avoid the mess by providing higher-level primitive functions so the programmer doesn't have to muck around with allocation. Paul (Stansifer) 22:20, 25 January 2011 (UTC)[reply]
How about a subroutine like this:
IF A$ = "" AND B$ = "" THEN RESULT = 1 : RETURN
IF A$ = "" OR B$ = "" THEN RESULT = 0 : RETURN
IF LEN(B$) > LEN(A$) THEN RESULT = 0 : RETURN
IF LEFT$(A$, LEN(B$)) = B$ THEN RESULT = 1 : RETURN
RESULT = 0 : RETURN
The 5 lines deal with the following 5 cases:
  1. both strings empty
  2. one string empty
  3. test string bigger than target string
  4. target string begins with test string (edited to remove silliness)
  5. target string doesn't begin with test string. 81.131.46.74 (talk) 19:51, 25 January 2011 (UTC)[reply]
Simpler version:
L = LEN(B$): IF L = 0 THEN L = 1
IF LEFT$(A$, L) = B$ THEN RESULT = 1 ELSE RESULT = 0
this works because LEFT$(A$, 1) is "" when A$ is "". 81.131.14.206 (talk) 02:29, 26 January 2011 (UTC)[reply]

Thanks, will try out the simpler version and make use of it. 92.15.28.68 (talk) 11:59, 26 January 2011 (UTC)[reply]