Wikipedia:Reference desk/Archives/Computing/2015 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]PDFs in browsing history
[edit]Why does visiting a PDF file in Internet Explorer add 2 to the "Times visited" value in the properties window? All other pages add 1. GeoffreyT2000 (talk) 00:56, 11 October 2015 (UTC)
Elementary bash script help needed
[edit]I don't do bash programming, but need a script now, so I'm trying. However, I have been unable to make a simple yes/no query work. I'd be grateful if someone could show me the proper way to do this. I'm skipping irrelevant code.
#!/bin/bash
#(Omitting various safety checks that work).
echo
echo Removing specified thumbnails!
ls /var/www/foto/thumbs/$1
echo
echo "ARE YOU SURE YOU WANT TO DELETE ALL THESE FILES?"
read REPLY
echo $REPLY # edited after posting. The dollar sign was there in the code, to make sure the variable contained the user input.
# This test does not work.
if ($REPLY=="Yes")||($REPLY=="yes")||($REPLY=="YES")
then
echo "You are mad!"
else
echo "Please answer yes or no!"
fi
I've tried various combinations of brackets, double brackets, parentheses, double parentheses and backquotes without success. Thanks, -NorwegianBlue talk 12:56, 11 October 2015 (UTC)
- Try:
if [[ $REPLY = "Yes" || $REPLY = "yes" || $REPLY = "YES" ]]; then
- Thanks for your quick reply, which solved the problem! --NorwegianBlue talk 14:00, 11 October 2015 (UTC)
- I usually do this sort of test with
case
inside a loop:
- I usually do this sort of test with
while true
do
echo -n "ARE YOU SURE? "
read REPLY
case "$REPLY" in
Y|y|Yes|YES|yes) echo "YOU ARE MAD! Deleting all files..."
# code to "delete all files" goes here
break;;
N|n|No|NO|no) echo "Phew, that's better."
break;;
*) echo "Please answer yes or no (or Y or N)";;
esac
done
- Or you might find it clearer this way, with a second test of
$REPLY
outside the loop:
- Or you might find it clearer this way, with a second test of
while true
do
echo -n "ARE YOU SURE? "
read REPLY
case "$REPLY" in
[YyNn]|Yes|YES|yes|No|NO|no) break;;
*) echo "Please answer yes or no (or Y or N)";;
esac
done
case "$REPLY" in
[Yy]*) # code to "delete all files" here;;
esac
- --174.88.134.156 (talk) 19:11, 11 October 2015 (UTC), edited 21:25, 11 October 2015 (UTC)
- I don't code bash either but I would suggest the following tweak:
- --174.88.134.156 (talk) 19:11, 11 October 2015 (UTC), edited 21:25, 11 October 2015 (UTC)
while true
do
echo -n "ARE YOU SURE? "
read REPLY
REPLY = ${REPLY,,}
case "$REPLY" in
y|yes) echo "YOU ARE MAD! Deleting all files..."
# code to "delete all files" goes here
break;;
n|no) echo "Phew, that's better."
break;;
*) echo "Please answer yes or no (or Y or N)";;
esac
done
- Canonicalising the case simplifies the detection, and also allows the relatively likely "YEs". I would even go so far as to set the variable to a completely canonical value:
while true
do
echo -n "ARE YOU SURE? "
read REPLY
REPLY = ${REPLY,,}
case "$REPLY" in
y|yes) echo "YOU ARE MAD! Deleting all files..."
REPLY = "y"
break;;
n|no) echo "Phew, that's better."
REPLY = "n"
break;;
*) echo "Please answer yes or no (or Y or N)";;
esac
done
- and then test after the loop. Any subsequent test of REPLY need only consider "y" and/or "n".
- Please forgive any bash solecisms.
- All the best: Rich Farmbrough, 17:39, 13 October 2015 (UTC).
Why are some file names invalid?
[edit]Why aren't * . " / \ [ ] : ; | = , allowed in file names? I get that some characters are needed for delimiting file and directory names. But why the laundry list of not allowed characters?--Llaanngg (talk) 13:34, 11 October 2015 (UTC)
- They are invalid for certain operating systems only. For example, Unix is all fine and dandy with each of those characters, except /, because it uses / as the directory separator. JIP | Talk 13:59, 11 October 2015 (UTC)
- OK, thanks for the note. Why are some file names invalid for certain operating systems?--Llaanngg (talk) 14:15, 11 October 2015 (UTC)
- When Microsoft developed its file system, these reserved characters were forbidden from file names (among many other file name restrictions). The objective of these limitations is to simplify the job of programmers and script-authors who would have to deal with those file names. Each of these characters already has a special use in the programmatic interface to the file system. Allowing these characters in file names would require complicated escape sequences in programs that worked with those files.
- The goal of early PC file-systems was simplicity (for programmers); user-experience sometimes suffered so that programmer-experience would be better.
- Here is An Inside Look at MS-DOS - The design decisions behind the popular operating system (1983); there is a lot more history on our articles on MS-DOS, FAT-16, and so on. Modern Windows systems use newer conventions for file and directory names, but some of the limitations, features, and caveats have a historical justification rooted in much older software.
- Nimur (talk) 15:25, 11 October 2015 (UTC)
- It's not just about programmers. Files with names such as "C:\" and "*.txt" are very confusing to users as well. Looie496 (talk) 15:40, 11 October 2015 (UTC)
- OK, thanks for the note. Why are some file names invalid for certain operating systems?--Llaanngg (talk) 14:15, 11 October 2015 (UTC)
- This gets into one of the basic differences between Windows and Linux. In many cases, Windows forbids you from choosing filenames that would confuse the reader. Linux typically allows you to shoot yourself in the foot if you really want to, and merely recommends against choosing filenames that would confuse the reader.
- Here are some webpages that discuss filename limits: 8.3 filename#Directory table, Illegal Characters on Various Operating Systems, Microsoft: Naming Files, Paths, and Namespaces, What characters are allowed in a filename
- There are some interesting examples of unexpected behavior on the above pages .
- Example 1:
- Create a file named com1 on Mac OS 9
- Move the file to a Windows machine
- Under Windows 2000 viewing the folder which contains the file via Explorer will result in Explorer crashing
- Under Windows 2003 the file name cannot be changed because the file will require inherent access permissions
- Example 2:
- Create a file named .text on Windows
- Move the file to a Mac OS X machine
- The file will not be visible via the Finder
- (File and folder names beginning with a dot mean the file or folder is hidden)
- Example 3:
- Create two files named FOO.TXT and foo.txt on Linux
- Move both files to a DOS machine, overwriting any existing files
- Only one file will be on the DOS machine with the contents of whichever file got moved last.
- (DOS filenames are case-insensitive)
- If we can find references, examples like the above but including newer operating systems would be a nice addition to one of our pages on filenames. --Guy Macon (talk) 19:23, 11 October 2015 (UTC)
- You have to be careful to disentangle some of these examples, because many are limitations of the file system rather than limitations of the operating system. One can, for example, use NTFS file systems on Linux, and ext3 file systems on OS X, and so on. HFS+ can be configured case-sensitive or case-insensitive. Other examples are subjective, but may be called "correct behavior." On many platforms, dot files are "expected" to behave as "invisible" files by default; and so on. An under-informed user may be susceptible to cross-platform user error even if the system behavior is correct. Lastly, we need to distinguish two categories: (1) characters that are formally forbidden in filenames due to technical specification; and (2) characters that are allowed, but should reasonably be avoided in the spirit of the robustness principle. If a file system permits a confusing file-name, but we know that many programs will behave poorly when handling that filename, we should avoid using those characters. If the default system software or user-interface is configured to enforce such guidelines, but a power-user can work around them, how should we describe whether the system "supports" a particular filename? Nimur (talk) 00:59, 12 October 2015 (UTC)
- Windows inherited this from DOS. DOS commands used * for a wild card, slash to indicate a subfolder, and period to indicate the current directory, for example, so obviously these should not be used in file names to avoid ambiguity. And others such as colon and equals were used in DOS commands, so not allowed in file names. Bubba73 You talkin' to me? 00:00, 12 October 2015 (UTC)
- If we can find references, examples like the above but including newer operating systems would be a nice addition to one of our pages on filenames. --Guy Macon (talk) 19:23, 11 October 2015 (UTC)
- DOS (like VMS) used slash for a command option; that's why, when it grew tree directories, backslash became its folder delimiter. —Tamfang (talk) 00:48, 12 October 2015 (UTC)
- Something bugs me about the fundamental unstated premise of this question. It seems to me that the OP is looking at the whole thing backwards. The question shouldn't be "why are some characters invalid in file names"? I think the more pertinent question would be "what makes file names valid" to begin with. It's like the OP is assuming there is this set of things called "characters", of which "file names" are a subset. But in reality there is no such thing as "characters" at a fundamental level, it's something which is also arbitrarily created and expressed with Character encoding. Vespine (talk) 03:34, 12 October 2015 (UTC)
- That's a red herring. I certainly implied that some sets of characters are valid file names, and some sets are not valid. Asking which is which does not lead in a different route. And the non-existence of characters at a fundamental level can be extended to the file names, files, file system, and even bytes. These are all convenient abstractions of an ordered set of bits. --Llaanngg (talk) 17:01, 12 October 2015 (UTC)
- Of the characters you listed, only * " / \ : | are invalid in Windows. [ ] ; = , . are valid. < > are invalid though you didn't list them. Technically this is a limitation of Win32, not the underlying operating system (NT). Cygwin programs can make file names with any character except / \ and NUL. -- BenRG (talk) 18:35, 12 October 2015 (UTC)
- If you get into reading and writing directly from the disk, you can put funny characters in your filenames. There is no guarantee that programs, including systems utilities, will be able to deal with them any more. All the best: Rich Farmbrough, 17:42, 13 October 2015 (UTC).
Calculate complexity of a text (for reading or learning)
[edit]Can we somehow compute objectively how difficult is a text for a student or reader? I ask this given a circumstance where the reader has an educational purpose, not just to get some short information about a concrete issue. Besides the obvious things like text length, use of rare words, how can we assess the difficulty of a text (using an algorithm, not human feedback)? I also don't mean the layout, font size, but actually difficulty processing the content. --Jubilujj 2015 (talk) 18:58, 11 October 2015 (UTC)
- See Readability and the various metrics linked from that article. Tevildo (talk) 19:42, 11 October 2015 (UTC)
- Microsoft Word (any version in the last 15 years or so) will give you some readability statistics if you run a grammar check. I suspect most other word processors have similar capabilities.-gadfium 21:11, 11 October 2015 (UTC)
- For Word 2007, you need to turn this option on in the options dialog.-gadfium 21:16, 11 October 2015 (UTC)
@Gadfium:replier misunderstand question, OP question fall in ai natural language domain, require strong aiMahfuzur rahman shourov (talk) 16:02, 15 October 2015 (UTC)
Why don't Apple laptops have ferrite beads?
[edit]Every laptop seems to have one (ferrite bead), except Apple laptops. Why?--Scicurious (talk) 22:42, 11 October 2015 (UTC)
- Apple has created a walled garden. From the plug onwards, only apple chargers, leads, etc can connect. Therefore, apple simply design the equipment so that no external chokes on the leads are required. That is also partly why apple hardware cost more, The build quality is higher than low budget hardware.--Aspro (talk) 22:57, 11 October 2015 (UTC)
- Consider that a genuine charger for the IBM laptop I have at work costs about AU$30 while an apple "magsafe" adapter costs AU$120 (US$79), even the 45W one. My wife has a macbook and the cord near the laptop started to break from flexion, of course there's no way to just replace the cable so $120 to replace the whole thing!! I use an iPhone and I generally like apple but it's times like this that makes me curse them. .Vespine (talk) 03:17, 12 October 2015 (UTC)
- A Lenovo adapter for $20 US is almost certainly counterfeit (unless it's used or very old or the seller is desperate to be rid of it). If it says IBM on it, it's either counterfeit or very old. See here for more information. -- BenRG (talk) 18:05, 12 October 2015 (UTC)
- I present adapters for my IBM x240, Here's one for US$30. ok it's not US$20, but it's not US$79. Vespine (talk) 23:27, 12 October 2015 (UTC)
- Consider that a genuine charger for the IBM laptop I have at work costs about AU$30 while an apple "magsafe" adapter costs AU$120 (US$79), even the 45W one. My wife has a macbook and the cord near the laptop started to break from flexion, of course there's no way to just replace the cable so $120 to replace the whole thing!! I use an iPhone and I generally like apple but it's times like this that makes me curse them. .Vespine (talk) 03:17, 12 October 2015 (UTC)
- It can be that the cable is not emitting too much RF, so no ferrite was needed. However, it could also be that the ferrite is in the laptop. I'd dare to speculate that it's technically simpler to have a ferrite bead on the cable, but design-wise more appealing to exclude it to have a more sleek design.--Llaanngg (talk) 17:06, 12 October 2015 (UTC)
- Every manufacturer is required his products ti be compliant to the regulations of electromagnetic interferences. In USA the FCC, in Europe it is part of the CE mark. Connecting a cable to the computer it can be an antenna emitting electromagnetic interferences. --Hans Haase (有问题吗) 20:23, 12 October 2015 (UTC)
- Dear Hans Haase: what has this to do with anything? The question is not about why chargers have a ferrite bead, but why Apple's don't have one.--Jubilujj 2015 (talk) 21:18, 12 October 2015 (UTC)
- Apple still is subject to the same rules, so some people might be interested in how Apple's chargers meet them without a ferrite bead. I honestly don't know, as I'm not an electronics expert. --71.119.131.184 (talk) 21:53, 12 October 2015 (UTC)
- And that was the OP's question, which somehow implies that Apple too, has to comply with electromagnetic interferences.Jubilujj 2015 (talk) 21:55, 12 October 2015 (UTC)
I am an electronics expert, and have designed a large number of consumer devices with ferrite beads. Here are the things we think about when deciding if and where to add ferrite beads:
First, the end result must be that when the product undergoes FCC testing with all cables plugged in (cables make great antennas) the product puts out less radio frequency interference than the current maximum allowed. Screw that up and you can't sell product until you fix it,
A secondary consideration that the FCC doesn't care about but the design engineer does is that those same cables don't pick up enough radio frequency interference to make the product stop working. It has to work even if a cell phone, walky talky, microwave oven, wifi hotspot, etc. is right next to it. Fortunately, the same techniques that stop you from radiating too much radio frequency interference also tend to stop stop you from recieving too much radio frequency interference.
A third consideration is whether you have control of the device on both ends of the cable, like Apple does, or whether your device can be plugged in to a bunch of different product by different manufacturers, as is the case with most monitors and some external power supplies. In the latter case you often want to put the ferrite bead on the end of your cable rather than count on whatever random device you are plugged into having a good filter inside.
Finally, there is a practical consideration; the folks who do the FCC testing are on your side and want your product to pass if they can do it without cheating. To help you they have a large collection of clamp-on ferrite beads and will try them on various cables to see if it helps. Sometimes the easy route is to simply note the size and location of the bead they used to make it pass and design the same bead into the cable. --Guy Macon (talk) 23:42, 12 October 2015 (UTC)
- Notebook power supplies sometimes use coaxial cables on the low voltage output. Depending what computer is connected it may cause interferences. Some computers use a jack connected with simple two wires to the mainboard connector in a plastic case. This solution does not hurt the print solder mount when forcing the connected plug. But in a plastic case it is an antenna. A search for macbook bcp shows apple uses a direct connection to the multi layer mainboard, using the layers as shields and installed input lowpass filters. Force to the connector is limitted by its magnetic connector. This magent is just a machanical. It is nothng to do with interferences. Apple is known for designing the computer and its components as a complete solution. PC compatible notebooks sometimes use already existing power supplies and mainboards from other manufacturers, used in several other modells of notebooks. To make this components fullfill the regulations, sometimes such filter components like ferrite beads become neccessary. --Hans Haase (有问题吗) 20:33, 14 October 2015 (UTC)