Jump to content

Wikipedia:Reference desk/Archives/Computing/2016 March 22

From Wikipedia, the free encyclopedia
Computing desk
< March 21 << Feb | March | Apr >> March 23 >
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.


March 22

[edit]

Files are copied at full speed, but disk activity percentage appears low.

[edit]

Does this have anything to do with write-caching as what my friend suggested? It just strikes me odd as the hard drive activity light blinks sporadically even with large files involved, yet the transfer rate isn't unusually low. SMART values seem alright too, and I haven't abused the drive in a way like filling it to the brim either. Blake Gripling (talk) 07:09, 22 March 2016 (UTC)[reply]

Memory is cheap. Drives have large amounts of memory now, so they can cache a hell of a lot of data before they have to write a block to the drive. Depending on your disk format method, it may be optimized to write extremely large blocks (ie: an entire track) in one pass. 199.15.144.250 (talk) 13:40, 22 March 2016 (UTC)[reply]

How to prevent Google Chrome apps from knowing tab is not on top ?

[edit]

I would like to be able to leave something loading or running on a tab, then go to another tab to do something else, then return when the original tab is done. However, as soon as I go to a new tab, some web applications detect that their tab is no longer active and suspend the process. How do I prevent this ? StuRat (talk) 17:29, 22 March 2016 (UTC)[reply]

Do you have an example? I know some downloadsites do this, but I can't find a good example. The Quixotic Potato (talk) 18:02, 22 March 2016 (UTC)[reply]
Related question: how do they do that? Something similar to OptinMonster's method? Or do they have a counter that they compare with the time and does the browser simply stop running the JS which desyncs the timer? The Quixotic Potato (talk) 17:57, 22 March 2016 (UTC)[reply]
Electronic Arts' Tiberium Alliances game seems to behave like that. When I go to another tab, the player roster lists me as "Away" instead of "Online", then logs me out after a few minutes. Very annoying. StuRat (talk) 18:06, 22 March 2016 (UTC)[reply]

Any suggestions ? StuRat (talk) 16:46, 27 March 2016 (UTC)[reply]

Stupid question, I do not have a TA account anymore, but are you able to evade this by simply making it a new window instead of a new tab? Does it detect inactive windows? I tried to find a Greasemonkey script that allows you to disable this AFK-stuff, but I haven't found any. The Quixotic Potato (talk) 19:51, 28 March 2016 (UTC)[reply]
I'll give that a try, but I am skeptical that it will make a difference. Note that TA doesn't do this all the time, but sometimes it's very quick. That is, I switch to another tab, then come back within 5 minutes, and it's already logged me out. I am guessing that when server load is high, they log out everyone in the "Away" status, and you get that status by not having that window and tab active. StuRat (talk) 19:55, 28 March 2016 (UTC)[reply]
@StuRat: Have you seen this thing? You can download it here. There is a Page Visibility API. Googling "Disable Page Visibility API" or "Spoof Page Visibility API" gives some results. For more info see this and that. The Quixotic Potato (talk) 20:42, 28 March 2016 (UTC)[reply]
Thanks. I'm not sure if EA will interpret not knowing if the tab is active as if it is or isn't. In the latter case, that would make it even worse, as then it would close the active tab, too. StuRat (talk) 23:08, 28 March 2016 (UTC)[reply]
@StuRat: I haven't looked at the code (yet). I am curious to know if it works, please let me know if you get a chance to test this. The Quixotic Potato (talk) 23:25, 28 March 2016 (UTC)[reply]

Finite fields

[edit]

I have two things I want to implement as Python functions:

  • Determining if a given polynomial is irreducible in a given Galois field.
  • Calculating the multiplicative inverse of any number in a given Galois field with a given polynomial.

I am unable to find a good description or even already-written code for doing either. I already have a function for performing multiplication over a given Galois field, if that helps. How do I do the above? — Melab±1 19:13, 22 March 2016 (UTC)[reply]

You might try the Math Desk. StuRat (talk) 20:27, 22 March 2016 (UTC)[reply]
or math.stackexchange.com —Tamfang (talk) 05:36, 24 March 2016 (UTC)[reply]
Yes, this is pretty niche. I'm not sure how many readers we have who are 1) good at algorithm design 2) know python 3) are comfortable with polynomial factorization in finite fields. Maybe I'm wrong. I could probably do it given enough time, but I'm also not surprised that you can't find extant python code. You might have better luck searching for code in SageMath or Magma_(computer_algebra_system). You can probably understand the gist of it, then translate to python, though one advantage of Sage is that it has nice built-in classes for some of these mathematical structures. For example I quickly found this: [1]. At a glance I'm not sure if it contains example code that you want, but it might. You also can think about adapting ideas mentioned in factorization of polynomials and perhaps use Gauss's lemma (polynomial). SemanticMantis (talk) 14:29, 23 March 2016 (UTC)[reply]

Hacking into a Windows Vista/Windows 8 shortcut to find the target file

[edit]

Out of 'idle' curiosity, I recently tried to find the original file linked by the IDLE file editor shortcut for Python. The "target" line in a fully updated Windows 8 is blank - there is nothing under any of the properties to say where the file is. I could copy the shortcut, not see where it points. After going round and round a bit I looked it up and found Stackexchange help for this problem ... for Windows Vista.

The advice given in that works. I went to our comparison of hex editors, decided to bite the bullet and download a current version of Emacs, used M-x hexl-find-file to open the shortcut, and found that it links to C:/Python27/Lib/idlelib/idle.pyw (just as Stackexchange said). But why wasn't it listed?

Being suspicious maybe this text was some forensic thing for the FBI only and not really used for me (because there are some numbers in the hex code - registry entries maybe, I'm no expert - that might be used somehow to look something different up) I edited the .pyw to .pyz and sho'nuff, the shortcut stopped doing anything when double-clicked. As a control I changed it back and it worked again, so that's not emacs screwing up the save either.

So if these shortcut files really contain the target link that is really used to open the file, why is Microsoft failing to display it through two whole version updates of Windows? Do they just have that many open bugs they don't care about? Or is keeping the target a secret some kind of feature they want to push? On that note I might mention that the site linked by the Stackexchange entry above for "LNK parser" ([2]) is now a 404. I suppose making a program to spill the beans about what program you're running might count as illicit "reverse engineering" that invalidates your Windows license, if not outright "exceeding your authority" to access a computer/OS that belongs to various IP holders much more than it belongs to you. But that's a legal question and I know you can't answer it.

But a question I can ask is why does Python use this type of shortcut, which Stackentry called an "advertised link", rather than a plain old link? I mean, I made my own shortcut for idle.pyw and it was 1 kb instead of 3, and it listed what its target is. By hex editor the internal layout is all different. I'd think Python developers would prefer this, so why not? Wnt (talk) 19:24, 22 March 2016 (UTC)[reply]

(Update: sorry, I missed that you already tried munging the path, so there's something wrong with my theory, but I'll leave what I originally wrote here.)
I think that it is not actually using that command line to launch IDLE; it's a fallback in case the main launch method fails. (You could test that by zeroing out the path and seeing if the shortcut still works, but I'd make a backup first.) The main launch method is via Windows Installer, which has some extra capabilities, such as offering to install IDLE if you had set it to install on first use.
I was able to download the .lnk parser from here and run in on the IDLE .lnk file. The Windows Installer information is in the "Darwin Properties" section (Darwin being the pre-release code name of Windows Installer). It's a string with "TclTk>" in the middle and 20 random-looking ASCII characters on each side. Those random-looking characters are base85-encoded GUIDs. The GUIDs probably identify something in the registry and/or in the MSI file. It would likely be a lot of work to sift through all of the data structures and figure out what the ultimate launch path is. -- BenRG (talk) 20:23, 22 March 2016 (UTC)[reply]
As BenRG has said, the site you linked to does not 404. As to the benefits of advertised shortcuts, BenRG has already covered this mostly [3] [4] although I'm not sure why you messing up the installation wasn't fixed. (If I had to guess, the installer wasn't designed to detect the change you did.) [5] has a view of advertised shortcuts from Wine and [6] has a bunch of ways to find the target of an advertised shortcut. Note as mentioned in most of those refs and also [7] [8] don't have to be installed so there may be no actual path despite the shortcut existing and working (except the path to the installer). Nil Einne (talk) 13:01, 23 March 2016 (UTC)[reply]

Distinguish between file and directory in FTP?

[edit]

At work, I have to develop a .NET C# service that periodically downloads the contents of a directory on an FTP server, recursively along with its subdirectories. I noticed the download fails if it's trying to download a directory as if it were a file. I'm using .NET System.Net.FtpWebRequest for the download. How can I reliably distinguish between files and directories when I have a filename on the FTP server? In other words, how do I know whether the name refers to a file or to a directory? I've searched for it online, and all answers have either suggested looking at whether the name has an extension (unreliable, as nothing prevents extensionless files or directories with extensions) or parsing the output of detailed listing to see if it begins with d or contains <DIR> (non-portable across different implementations of FTP servers). Is there an easy way to do this? JIP | Talk 19:55, 22 March 2016 (UTC)[reply]

If you don't want to parse the output of ls (I've only ever seen UNIX ftp servers, which all look pretty similar), why don't you simply try to download, catch the error, and then go to the other case? Not elegant, put simple and probably robust. --Stephan Schulz (talk) 22:17, 22 March 2016 (UTC)[reply]
It looks like I have to try that. I'm just averse of using exceptions for flow control. But if nothing else works, this is what I have to go by. I'll just have to define the precise error conditions that cause this, and not other errors. JIP | Talk 22:24, 22 March 2016 (UTC)[reply]
FTP is an awful protocol and if you have to use it then hacks are the order of the day. If you have a choice, switch to anything else. SFTP is a well designed protocol that should have replaced FTP a decade ago. -- BenRG (talk) 23:20, 22 March 2016 (UTC)[reply]
It seems the problem is that the FTP command LIST was intended to be read by a person, and the format it reports isn't rigidly specified. So, as you've discovered, you often get the Unix ls -l format, but not always. RFC 3659 added the MLST and MLSD commands, which produce results in a predictable, readily parsable format. I don't know if the standard .NET library supports this RFC - this StackOverflow question has a reply from the author of WinSCP saying (in 2015) that it did not, but pointing to his C# wrapper for WinSCP's communications libraries, which does. -- Finlay McWalter··–·Talk 22:20, 22 March 2016 (UTC)[reply]
I'll have to look further into this. JIP | Talk 22:24, 22 March 2016 (UTC)[reply]
To echo the above replies, FTP is an ancient clunky mess. See here for some more details. As mentioned in the link, there is no standard format for the LIST command. Basically, don't use FTP if at all possible. If you have no other choice, you're just going to have to accept clunky hacks that might break. --71.110.8.102 (talk) 00:28, 23 March 2016 (UTC)[reply]
Just out of curiosity... Why are you rewriting rsync/robocopy? You said it is periodic, so add it to a cron job and you're done. 209.149.114.215 (talk) 19:47, 24 March 2016 (UTC)[reply]