Wikipedia:Reference desk/Archives/Computing/2018 February 19
Computing desk | ||
---|---|---|
< February 18 | << Jan | February | Mar >> | Current desk > |
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. |
February 19
[edit]IF EXIST (Dos command)
[edit]Can it ask if any file is present in a folder? I want to be told if a folder is not empty. Thanks. Anna Frodesiak (talk) 04:00, 19 February 2018 (UTC)
- I'm almost sure you can't do that from a batch file.
- Can't find any resources on the net, but I remember in the nineties I had to write a script to detect and optionally delete empty directories.
- Wildcards are valid with "exist", so I tried
if exist *.* command
, which seemed to be valid syntax, but it always executed "command", probably because of the.
and..
entries (standing for "this directory" and "parent directory"), which are present in any directory, empty or not. After several days of struggle I gave up. - I ended up writing a simple utility in Turbo Pascal, which was a quick and clean solution.
- You may want to do some further testing yourself, these memories are from 25 years ago... :) Jahoe (talk) 10:31, 19 February 2018 (UTC)
- This is easy. Learn some shell scripting, using Bash. This has been a commonplace part of Unix for forty years now.
- If you're on Windows, there is no point in messing with the awkward and limited standard command shell. Instead install either Cygwin or PowerShell. It's pretty easy. Once you have them installed, then particularly for Cygwin, there are lots of cookbook examples out there.
- You could also skip shell scripting altogether and go for something like Python. You can install that in such a way that the scripts appear as much part of the shell as shell scripts do - and it's a far more powerful programming environment. Andy Dingley (talk) 10:45, 19 February 2018 (UTC)
- Thank you kindly, Andy Dingley and Jahoe. The above is way, way above my intellectual pay grade when it comes to computer stuff.
- What I know about computers: Smoke = bad. Flickering orange light = flames, worse. Anna Frodesiak (talk) 00:10, 20 February 2018 (UTC)
SET folder=C:\yourfolderhere\ for /F "delims=" %%a in ('DIR %folder% /A-D /B ^| FIND /C /V ""') do set files=%%a IF "%files%" GEQ "1" (echo Folder is not empty.) ELSE (echo Folder is empty.)
— Preceding unsigned comment added by 77.101.141.178 (talk) 11:07, 19 February 2018 (UTC)
- Thank you. Is this safe? Will it work in dos? Will it cause flames? Anna Frodesiak (talk) 00:10, 20 February 2018 (UTC)
- I'd go with Cygwin. It's an easy install, once it's done then you can use pretty much all of the Unix shell techniques (there's any amount of cookbook stuff on the web). It's easier to change to this good platform than it is to try and achieve anything useful in the restricted DOS-based environment. Andy Dingley (talk) 10:14, 20 February 2018 (UTC)
- Thank you, you're very sweet, Andy. But my need is very simple. I just want to know if there's something in those folders.
- Also, I have no head for all that programming and those programs. I mean, I'm not stupid. My I.Q. has been tested at 82 and that's only 18 away from the genius level of a perfect 100. So, I'm pretty darn smart. Best, Anna Frodesiak (talk) 10:32, 20 February 2018 (UTC)
- I guess both Andy and I were thinking you were doing some advanced scripting job. If you're after a simple solution for something, it might help if you'd be more specific on what you're trying to do. Jahoe (talk) 12:24, 20 February 2018 (UTC)
- Or check if your solution is on this [1] page. Jahoe (talk) 13:02, 20 February 2018 (UTC)
Hi folks. It's okay. I have a bunch of temp1 temp2 temp3 folders in all the drives different drives just for some quick dumping grounds for various things. I keep them empty but wanted a quickie batch to run once in a while to see if I've left anything around. No big thing and manual is not much extra effort.
Now, would someone please say "I guess you didn't you know, but 150 is genius level."
Best, Anna Frodesiak (talk) 19:08, 20 February 2018 (UTC)
- I knew you were joking. Bubba73 You talkin' to me? 19:09, 20 February 2018 (UTC)
- Come on, Bubba73. Say it. :) Anna Frodesiak (talk) 19:21, 20 February 2018 (UTC)
- I used a similar joke in a letter to the newspaper in the 1970s or 80s - "my IQ is 98 - almost perfect". Bubba73 You talkin' to me? 19:25, 20 February 2018 (UTC)
- Bubba73, you still didn't say it. :) Anna Frodesiak (talk) 19:34, 20 February 2018 (UTC)
- Oh come on Anna! We all understand you're well over 82½. Jahoe (talk) 19:53, 20 February 2018 (UTC)
- Awwwww, fine. You spoiled a perfectly good joke! Anna Frodesiak (talk) 19:57, 20 February 2018 (UTC)
- Really? Hm. :) Jahoe (talk) 20:23, 20 February 2018 (UTC)
- Okay Jahoe, fine. It was a stupid joke. :) Anna Frodesiak (talk) 21:43, 20 February 2018 (UTC)
- Really? Hm. :) Jahoe (talk) 20:23, 20 February 2018 (UTC)
- Awwwww, fine. You spoiled a perfectly good joke! Anna Frodesiak (talk) 19:57, 20 February 2018 (UTC)
- Oh come on Anna! We all understand you're well over 82½. Jahoe (talk) 19:53, 20 February 2018 (UTC)
- Bubba73, you still didn't say it. :) Anna Frodesiak (talk) 19:34, 20 February 2018 (UTC)
- I used a similar joke in a letter to the newspaper in the 1970s or 80s - "my IQ is 98 - almost perfect". Bubba73 You talkin' to me? 19:25, 20 February 2018 (UTC)
Well, I figured it out. I made a batch file using ">>" that first produces a text file called file1.txt of what's in all the folders. The batch file then uses comp (command) to compare that file1.txt to file0.txt. That file0.txt is a list of all the folders when empty. It then sends the comp (command) result using ">>" to result.txt and opens it a notepad for me to see. If result.txt says file1.txt and file0.txt are the same, then I know all the folders are empty. When I close the notepad, the batch deletes file1.txt and result.txt to clean up after itself. Done. Anna Frodesiak (talk) 21:43, 20 February 2018 (UTC)
- I would have done it like this. Create a small executable which opens each file in turn, reads its contents into DS:DX with AX being the number of bytes actually read, then closes the file. For each file, store the value of AX in a unique buffer. At the finish, any non-empty buffer identifies which file. Very simple opcodes, which I use and can supply you, using INT 21h. No need for cleanup at finish. Akld guy (talk) 06:41, 21 February 2018 (UTC)
- You're very sweet, Akld guy. That would require that I understand how to make an executable, and that I know what these words mean: DS:DX, unique buffer, opcodes, and INT 21h.
- Anyhow, all's well that ends well. The thing works. Problem solved. Thanks to all. :) Anna Frodesiak (talk) 01:00, 22 February 2018 (UTC)
- @Anna Frodesiak: OK, it was worth a try because although you said you didn't understand others' suggestions, you did indicate some familiarity with (and interest in) DOS. To create an executable (a fancy word for a program), you type out the commands in a text window and save it. Then you command the Assembler to work on the text file and create the executable (file) which you can then run. There are plenty of free Assemblers around, including A86. Akld guy (talk) 01:19, 22 February 2018 (UTC)
- Hi Akld guy. Assembler? So that means I'd have to know a programming language and then write the program and then find an assembler which would convert it to an exe? Anna Frodesiak (talk) 02:35, 22 February 2018 (UTC)
- Yes, except that finding an assembler is not difficult because there is very little variation in syntax and most of them understand any custom variations. I wouldn't recommend learning assembler because it has almost no application today. Better to follow the advice given by others above and learn Python. However, assembler is easy to learn - you write in abbreviated versions of English commands such as MOV to move a value into a register, SHL or SHR to shift left or right, and REP STOSB to REPeatedly STOre a Single Byte (to overwrite a buffer). Akld guy (talk) 05:54, 22 February 2018 (UTC)
- Thank you, Akld guy, but I really will never do that. You are very kind to suggest it, nonetheless. Anna Frodesiak (talk) 06:53, 22 February 2018 (UTC)
- Yes, except that finding an assembler is not difficult because there is very little variation in syntax and most of them understand any custom variations. I wouldn't recommend learning assembler because it has almost no application today. Better to follow the advice given by others above and learn Python. However, assembler is easy to learn - you write in abbreviated versions of English commands such as MOV to move a value into a register, SHL or SHR to shift left or right, and REP STOSB to REPeatedly STOre a Single Byte (to overwrite a buffer). Akld guy (talk) 05:54, 22 February 2018 (UTC)
- Hi Akld guy. Assembler? So that means I'd have to know a programming language and then write the program and then find an assembler which would convert it to an exe? Anna Frodesiak (talk) 02:35, 22 February 2018 (UTC)
- @Anna Frodesiak: OK, it was worth a try because although you said you didn't understand others' suggestions, you did indicate some familiarity with (and interest in) DOS. To create an executable (a fancy word for a program), you type out the commands in a text window and save it. Then you command the Assembler to work on the text file and create the executable (file) which you can then run. There are plenty of free Assemblers around, including A86. Akld guy (talk) 01:19, 22 February 2018 (UTC)
- Anyhow, all's well that ends well. The thing works. Problem solved. Thanks to all. :) Anna Frodesiak (talk) 01:00, 22 February 2018 (UTC)
Selected items in Windows 10 are light blue
[edit]Can that colour be changed? I use a file manager that has a black background and yellow text, and that pale blue is hard to see. Many thanks. Anna Frodesiak (talk) 04:01, 19 February 2018 (UTC)
- @Anna Frodesiak: I've heard good things about Qttabbar, which might fix your issue. Anarchyte (work | talk) 10:09, 20 February 2018 (UTC)
- Thank you, my friend. I'm hooked on FreeCommander. You should be too. Anna Frodesiak (talk) 10:48, 20 February 2018 (UTC)
Old mainframe memory chip
[edit]I have a memory card from a 1982 CDC Cyber 170 mainframe. I'm trying to figure out how much each chip stores. From the number of cards and the maximum memory of the computer, I've figured out that each chip can hold at most 32 kilobits and there is a good chance that it is less. The chips are Fujitsu (or maybe Fairchild) MBM10470-20. I can find places that sell them but I can't find out their memory capacity. Can anyone tell? Bubba73 You talkin' to me? 04:31, 19 February 2018 (UTC)
- 4k bit (so equivalent to 256 byte) as 4096 × 1bit ECL RAM. https://4donline.ihs.com/images/VipMasterIC/IC/NATL/NATLE100002/NATLS15128-1.pdf?hkey=EF798316E3902B6ED9A73243A3159BB0 Andy Dingley (talk) 13:19, 19 February 2018 (UTC)
- Thanks, I couldn't find the details! It is National Semiconductor instead, but the same part number, so it must be equivalent. Bubba73 You talkin' to me? 15:50, 19 February 2018 (UTC)
Looking for term: "Serial" method overloading in Java
[edit]In Java (and like object-oriented programming languages), you can overload methods, i.e. use methods with the same name, but a different signature of variables. I'm looking for a good term to build a "tower" of ordered or lattice-like partially-ordered overloaded methods, step by step changing variables in the signature, e.g.:
- buildPoster (int width, int height, String headLine, String text)
- buildPoster (int height, String headLine, String text) [with fixed width]
- buildPoster (int width, int height, String text) [with default headline]
- buildPoster() [use default values]
I haven't found a term for this so far - is there an established one? --KnightMove (talk) 08:38, 19 February 2018 (UTC)
- Well, it's an emulation of default arguments that Java doesn't support (with the added flexibility of omitting non-final arguments if the types make it unambiguous). --Tardis (talk) 18:23, 19 February 2018 (UTC)
- There is also the builder pattern which is an alternative to what you are proposing. Anon126 (notify me of responses! / talk / contribs) 20:33, 19 February 2018 (UTC)
ecryptfs passphrases and wrapping passphrases
[edit]The default encrypting filesystem on Ubuntu is ecryptfs. When you set it up to encrypt your home directory, it does a thing where the real key is encrypted and in a file called $HOME/.ecryptfs/wrapped-passphrase
. It's encrypted (by default) with your login password. That way, if you change your login password, as I understand it, you don't have to re-encrypt all the files — you just re-encrypt wrapped-passphrase
. Is that basically right?
The issue is that I tried to use it to make an encrypted archive directory on an external drive, with a command like
mount -t ecryptfs /media/trovatore/external_drive /media/trovatore/external_drive
Then I can choose a passphrase, and copy files into that directory. If I unmount it from ecryptfs, but leave it mounted "raw", the files appear encrypted or at least the filenames do; I didn't really look at the contents; probably should so that's good.
But I can't find any corresponding wrapped-passphrase
file.
So I'm thinking maybe there isn't one, and when you use ecryptfs directly via mount -t ecryptfs
, the passphrase you give is no longer the wrapping passphrase, but rather the actual key used to encrypt the files.
Is that correct? If I wanted instead to use the wrapped-passphrase
methodology, but using mount
, is there a way to do that? --Trovatore (talk) 08:45, 19 February 2018 (UTC)
iPhone SE
[edit]I have an iPhone SE running iOS 11.2.2. And I have my personal email account set up in the default email app. I have a friend sending 10 photos per email, and they download automatically. Since I use mobile data to download emails, it affects me. But I cannot find a way to block that email address, or stop the images to stop downloading autmatically. Though I have the option Load remote images off. Any idea? Thanks. Miss Bono [hello, hello!] 13:24, 19 February 2018 (UTC)
- @Miss Bono: I believe disabling "Load Remote Images" fixes it. Worst comes worst, you can disable mobile data for just mail. Anarchyte (work | talk) 10:05, 20 February 2018 (UTC)
- Disabling "Load remote images" will work only if the images are actually remote; that is, if the email contains merely a link to the image, which is hosted on a server elsewhere. If the image is actually embedded in the email (as a MIME attachment), then the image will be downloaded when you read the email. The only options I can think of are to convince your friend to not send embedded images (although that will require that they host the images somewhere), or just don't read emails from them unless you are a wifi network. CodeTalker (talk) 15:07, 20 February 2018 (UTC)
- The images download themselves without me even opening the email. Miss Bono [hello, hello!] 18:26, 20 February 2018 (UTC)
- Are you using POP or IMAP to access your mail server? CodeTalker (talk) 19:03, 20 February 2018 (UTC)
- This is from six years ago(!) (a month is a long time in tech), but it might be possible to download the body of emails, but not attachments. [2]. However, HTML attachments are used for formatted emails, so it mightn't work well for you. LongHairedFop (talk) 20:16, 20 February 2018 (UTC)
- That might work, but only if IMAP is being used. From the description, I suspect the OP is using POP. If IMAP were used, the messages shouldn't be downloaded before they're viewed; only the headers should be downloaded. CodeTalker (talk) 22:44, 20 February 2018 (UTC)
- I'm using POP, yes. Miss Bono [hello, hello!] 13:39, 21 February 2018 (UTC)
- Well there's your problem. Switch to IMAP. Besides fixing this problem, your email will work better in many ways. For example, you can view your mail on multiple devices (eg. your phone and your PC). CodeTalker (talk) 20:24, 21 February 2018 (UTC)
- I live in Cuba, so the situation with this is really comlicated. I once started using IMAP, but I was told that it consumed data twice as fast as POP does. Miss Bono [hello, hello!] 20:49, 21 February 2018 (UTC)
- Well there's your problem. Switch to IMAP. Besides fixing this problem, your email will work better in many ways. For example, you can view your mail on multiple devices (eg. your phone and your PC). CodeTalker (talk) 20:24, 21 February 2018 (UTC)
- I'm using POP, yes. Miss Bono [hello, hello!] 13:39, 21 February 2018 (UTC)
- That might work, but only if IMAP is being used. From the description, I suspect the OP is using POP. If IMAP were used, the messages shouldn't be downloaded before they're viewed; only the headers should be downloaded. CodeTalker (talk) 22:44, 20 February 2018 (UTC)
- The images download themselves without me even opening the email. Miss Bono [hello, hello!] 18:26, 20 February 2018 (UTC)
Serialisation/deserialisation problem with Java REST API and dates
[edit]I've run to a frustrating problem at work. I am developing a REST service that has to call another REST service via a Java client. All my service has to do is call the existing REST service and return whatever it returns. But I have run to a problem. The existing REST service returns a JSON object serialised as a string, and my REST service is supposed to return the exact same JSON object. However, the JSON object returned has a date field that is serialised as a raw number of milliseconds, whereas it appears that my REST API expects an ISO standard timestamp, which causes a deserialisation failure. How can I specify how the fields in my data classes are supposed to be serialised and deserialised? JIP | Talk 21:46, 19 February 2018 (UTC)
- One proposal is to modify the Java half of the implementation.
- Your Java class should implement the java.io.Serializable interface. Then, to define the specific byte sequence that represents the object, you should write code to override the default writeObject and readObject methods. You can use the DateFormatter to convert dates to serialized character strings in any format your application requires.
- As a matter of general advice - Postel's law, as it were - it may be best to write to a standard format (like ISO 8601; or to whatever other standard your application requires); but when reading, you may choose to accept a date string provided in any of the various formats you can reasonably expect. Some organizations may actually frown on this style of "defensive programming," and prefer to reject any non-strictly-conforming input data.
- Nimur (talk) 03:22, 20 February 2018 (UTC)
Actually, the problem was rather easy to solve. I'm developing the REST service using Spring Boot, and it turns out Spring Boot has a rather easy-to-use configuration option to return dates in ISO standard format instead of milliseconds. I just had to add it to my Spring configuration file. I don't remember the exact option name and value, but I can look it up at work on Monday. JIP | Talk 22:35, 24 February 2018 (UTC)