Wikipedia:Reference desk/Archives/Computing/2011 September 28
Computing desk | ||
---|---|---|
< September 27 | << Aug | September | Oct >> | September 29 > |
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. |
September 28
[edit]dropbox problems
[edit]Hi. I use dropbox on my two macs: one home, one work. I work at home and create files. When I get to work the next day, the files are not in the dropbox folder. They are in the dropbox website, so I know I have created them, but the files are not in the dropbox folder. Can anyone advise? Robinh (talk) 00:47, 28 September 2011 (UTC)
- Have you tried re-installing the dropbox client? --Mr.98 (talk) 01:23, 28 September 2011 (UTC)
- thanks for this Mr98. It never occurred to me to do this; I was expecting there to be a "refresh" button somewhere which I couldn't find. Merely stopping dropbox and restarting it works fine. Robinh (talk) 01:48, 28 September 2011 (UTC)Resolved
- thanks for this Mr98. It never occurred to me to do this; I was expecting there to be a "refresh" button somewhere which I couldn't find. Merely stopping dropbox and restarting it works fine.
dd and /dev/random
[edit]Hello everyone,
A while back I saw a really cool command. it used dd and /dev/random to print random strings to the terminal. I remember that the rate of output would slow down, but if I typed on the keyboard, it would speed up. When I do < dd if=/dev/random > any keys I type end up also being displayed on my terminal, and I'd like to avoid that... How would I accomplish this (and if you know how to format the stream to look like strings that'd be nice too. Thanks so much! 70.186.193.113 (talk) 06:14, 28 September 2011 (UTC)
- See this stackoverflow question for several ways of doing this - one is "base64 --wrap=0 /dev/random". In case you didn't know, on some systems, there is also /dev/urandom, which continues producing pseudorandom numbers when it runs out of entropy (we have an article called /dev/random that talks about this, but I don't know how to link to it!). 130.88.73.65 (talk) 08:49, 28 September 2011 (UTC)
- Sorry, I somehow missed the part about not printing the keys you type - I'm not sure how you would do that. But I think on most systems, there are other ways of generating entropy for /dev/random, such as moving the mouse around, and performing operations on the hard disk. Probably it also works if you type into a different window (assuming you are using a graphical interface). 130.88.73.65 (talk) 08:57, 28 September 2011 (UTC)
- stty -echo turns off echoing of what you type. stty echo turns it back on. But if you want to feed the entropy pool from the keyboard without sending any characters to the terminal, there's an easy answer: just hit Shift/Alt/Ctrl repeatedly. 67.162.90.113 (talk) 09:40, 28 September 2011 (UTC)
/dev/random is a blocking device meaning it doesn't continue to give output when its entropy count runs low. /dev/urandom will use the same pseudo random number generator and yet not block. While in theory this is less secure, unless you're using it to generate key data, it's a very good source of randomness.
You'll probably want to convert the output to legitimate ascii, so things like dd if=/dev/urandom | base64 are probably the easiest. You can also use cat, so cat /dev/urandom | base64 works too. Alternatively you could use hexdump, or if you want it pure hex then cat /dev/random | xxd -ps should work too.
In either case the output is actually going to a separate stdout than your keystrokes are being displayed on. So if you wanted to pipe the output then your keystrokes won't be recorded. Read more about bash piping for more on that. Shadowjams (talk) 07:43, 29 September 2011 (UTC)
- Hey everyone, thanks for your suggestions. I am using < dd if=/dev/random bs=1 | od -x > but my keystrokes still show up when I type them. Is there something I can add so that they dont show up? Thanks and sorry for my ignorance. The only reason why I dont want to use stty -echo is because I want to have other individuals try this out, and I am afraid to mess up their terminal (some of them are even less experienced than me when it comes to shell commands.) I wanted to use /dev/random because I hope that the output rate is faster when they type than when they dont (this will illustrate how the amount of entropy affects this rng.) Thanks, 70.186.193.113 (talk) 00:29, 1 October 2011 (UTC)
Ghost spaces
[edit]For quiet a long time I have been observing that in my hard disk partitions (Wnidows XP 2)the occupied space is being shown more than the actual space occupied by the files in it. I am selecting all the files in it and clicking on the properties to know the space occupied and it is showing 1gb or 2gb or 3 gb space less than what is being shown when i click on the partition and then on the properties...........
Is this normal or some malware problem? — Preceding unsigned comment added by 119.235.51.130 (talk) 08:54, 28 September 2011 (UTC)
- There are a few reasons this can happen:
- If you haven't configured Explorer to show hidden and system files, you are probably not selecting the swap file and hibernation file, which are both hidden and can take up gigabytes each.
- System Restore data may not be included in Explorer's total.
- Metadata, like file names and the list of files in each directory, isn't stored in files but obviously takes up space.
- Disk space is allocated in multiples of 4K (usually), so some space is wasted at the end of every file that isn't a multiple of 4K.
- -- BenRG (talk) 09:35, 28 September 2011 (UTC)
- Well if disc spaces are in multiples of 4K then will I get wastage in GB? Looks improbable! — Preceding unsigned comment added by 119.235.51.130 (talk) 10:14, 29 September 2011 (UTC)
- It can make a significant contribution to your wasted Gigabytes because Windows creates many thousands of small files. I notice that some of my folders containing small files take up nearly twice as much space on the disc as the total file size. I assume you've taken into account that a disc Gigabyte is only 1000 MB. Dbfirs 20:45, 29 September 2011 (UTC)
Sixteen-segment displays
[edit]Why are the letters O and S often not distinguished from the digits 0 and 5, respectively, on sixteen-segment displays? --84.62.204.7 (talk) 09:36, 28 September 2011 (UTC)
- How could they be distinguished? At most, you could put a slash through the zero. A slash through the 5 would make it look more like $. -- kainaw™ 13:00, 28 September 2011 (UTC)
- This question appears to be from this guy. It should probably be closed or deleted. -- BenRG (talk) 17:08, 28 September 2011 (UTC)
More C programming, different problem
[edit]Following on from the successful resolution of the problem above, I have started working on an idea I had for my own program (mostly just stripping that earlier program down and rebuilding it), which I thought would be annoyingly long but yet quite simple and repetitive, it asks for a succession of numbers, and when one is entered as 0 it calculates the average those remaining would need to be to reach a particular total. However, having expanded it to now ask for four successive numbers, if I enter just one, it divides the remainder by two rather than three, giving the incorrect value.
#include<stdio.h> #include<conio.h> main() { int a,b,c,d; float avg; printf("1st:"); scanf("%d",&a); printf("2nd:"); scanf("%d",&b); if (b==0) { c=0, d=0; avg=(100-a)/3; } else { printf("3rd:"); scanf("%d",&c); } if (c==0) { d=0; avg=(100-(a+b))/2; } else { avg=(100-(a+b+c)) ; } printf("%f",avg); getch(); }
I am sure I am doing something obvious wrong, but still cannot see what, the sum is quite specific at (100-a)/3, so why does it give the answer to (100-a)/2?
148.197.81.179 (talk) 13:07, 28 September 2011 (UTC)
- Instead of trying to use "I'm too cool for formatting"-style brackets, I changed your code snippet to make it clear where each if/else block begins and ends. You can see that "if(c==0)" should be inside the else block that it is following. -- kainaw™ 13:17, 28 September 2011 (UTC)
That works, so each option has to go inside the previous one rather than after it, that makes sense now. And all I have to do now is write it out over and over to incorporate 30 different input numbers. Unless I do something else silly like that wrong. 148.197.81.179 (talk) 13:30, 28 September 2011 (UTC)
- You should use a
for
loop for that, not copy and paste the same code 30 times. It's not only less bug prone, but also much easier. Incidentally, a decent compiler should have warned you about the bug in this program (using an uninitialized variable). -- BenRG (talk) 16:57, 28 September 2011 (UTC)- Also,
123 / 456 == 0
in C. Dividing integers truncates the result to an integer, even if you assign the result to afloat
. You need to write something likeavg = (100 - (a + b)) / 2.0;
oravg = (float) (100 - (a + b)) / 2;
. -- BenRG (talk) 17:28, 28 September 2011 (UTC)
- Also,
OK, now I prove that I have no idea what I am really doing. Is there any way I can change this program so it saves the input data somewhere, such that it can bring up the numbers entered so far again rather than them all having to be typed in one by one every time the program is run? And I don't suppose there is any way of having it run outside the IDE, same as all the proper programs on my computer? 148.197.80.214 (talk) 19:43, 30 September 2011 (UTC)
- C is not that great a choice of language for beginning programmers these days. You're probably better off starting with something like Python, and moving on to C once you've gained more footing. 71.141.89.0 (talk) 11:09, 4 October 2011 (UTC)
Variable number of nested loops in BASIC
[edit]A while ago I asked a question on this, now archived so this is just a report, possibly of interest. Before, I was given a program to do the job, inelegantly GOTOed. I've now figured out a much neater, likewise non-recursive, version:
do '***** THIS IS THE INNERMOST LOOP ' MAIN CALCULATION IN HERE '***** CURRENT VALUES OF ALL s() ARE AVAILABLE i=1 while (i<=loops and s(i)=max(i)) s(i)=min(i) i=i+1 wend if i<=loops then s(i)=s(i)+1 loop while i<=loops
The variable "loops" is the number of loops, the value of each loop variable is in the array "s", with the lowest and highest values in the arrays "min" and "max". Initially, all values are set to their minimum.←86.155.185.195 (talk) 19:27, 28 September 2011 (UTC)
- For the record - this refers to Wikipedia:Reference_desk/Archives/Computing/2011_September_19#Variable_number_of_nested_loops.
- Yes, good work, exactly what I meant to write :) Imgaril (talk) 00:17, 30 September 2011 (UTC)
Font Problem
[edit]I have several fonts on my computer that I downloaded from other sources. Occasionally, when I am using one of them, the font suddenly becomes Arial for no apparent reason. The font bar of Word 2010 claims that it is still the font that I desired, and when I apply any formatting to the font (even growing or shrinking the size by half a point) it changes back to what it was before. Why is this? Interchangeable|talk to me 23:32, 28 September 2011 (UTC)