Jump to content

Wikipedia:Reference desk/Archives/Computing/2010 October 21

From Wikipedia, the free encyclopedia
Computing desk
< October 20 << Sep | October | Nov >> October 22 >
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 21

[edit]

How to remove the HD?

[edit]

From one of these...


...before disposal. Thanks, hydnjo (talk) 00:25, 21 October 2010 (UTC)[reply]

I know this is not the point, but are you sure you don't want to try selling one of those? They're quite sought after. Chevymontecarlo 06:24, 21 October 2010 (UTC)[reply]
Have you tried Googling "replace hard drive iMac G4"? There are quite a few tutorials. You need Torx #10 and #8 screwdrivers (which are non-standard unless you take Macs apart often, which I imagine you don't based on the question), but otherwise it looks pretty straightforward. --Mr.98 (talk) 13:50, 21 October 2010 (UTC)[reply]
It's possible to securely delete all the information off a hard drive before sale (or disposal or recycling). I looked at the Google cache of this (temporarily down?) page, and it has some options. It's also possible to use dd to copy /dev/random over the entire disk a couple times, which should be more than sufficient. You'd need a Linux live CD for PowerPC to do that, which shouldn't be hard to make. Paul (Stansifer) 18:21, 21 October 2010 (UTC)[reply]
Thanks to all for your suggestions. hydnjo (talk) 22:36, 22 October 2010 (UTC)[reply]

C: Pointers to Pointers and other Pointer Issues

[edit]

I'm really kind of confused with pointers in C. Let's say you malloc a blob of memory:

void * blob = malloc(sizeof(char *) + sizeof(int));

and you use the blob to hold two things like this: | a char * | integer value |

so blob would point to the memory adress of the beginning of the blob of malloc'd memory.

If you made a pointer to point to it:

void * pointToBob = bob;

Could you use bob and pointToBob interchangeably?

Or what if you had

void ** pointToBob = bob;

How could you used that?

I'm confused how you could possibly use a pointer to a pointer to change a value in the originally malloc'd blob. I'd appreciate any help with this problem and any sort of general explanations on the questions of pointers. I feel like I don't understand much more than "a pointer holds an adress to a place in memory". Thank you very much :) —Preceding unsigned comment added by Legolas52 (talkcontribs) 00:58, 21 October 2010 (UTC)[reply]

Am I safe in assuming that bob/Bob is everywhere a typo for blob/Blob? Assuming yes, the answer is that void * pointToBlob = blob; makes pointToBlob have the same type and value as blob. However, void ** pointToBlob = blob; will give you a compile warning, because a pointer to a pointer is not the same type as a pointer. But a more basic problem is that your malloc line is a thing that ought not to be done. In some systems, the "int" type must be aligned in a specific way in memory space, so it may not be possible to store an int at the place you think you are going to store it. This is simply bad code. Even if it works, referring to things in memory that has been allocated in this way is so ugly that I'm not even going to try to write it. If you want to store multiple different things in a single block of memory, create a struct to hold them. Looie496 (talk) 01:23, 21 October 2010 (UTC)[reply]
As Looie said, your malloc statement is not a permissible way to allocate a pointer and an int, because of alignment restrictions; trying to access the int might crash your program.
However, void ** pointToBlob = blob; is legal C and won't produce a warning, because C allows void * to be implicitly converted to any other pointer type (though C++ doesn't). There's no deep logic to this; it's just a special exception intended to make malloc easier to use. The result of this definition will be that pointToBlob will point to the same memory block as blob does, except that it will "think it's pointing to" a void *. You could then store a void * into the memory block through that pointer, even though you allocated space for a char *, because those pointer types happen to be guaranteed to have the same size. But that's probably not what you intended. If you wanted a pointer to the blob variable itself (which is a different thing from the memory you allocated), then you should have written pointToBlob = &blob instead of pointToBlob = blob.
Basically, the rules for pointers are straightforward: if you say &foo then you get a value that points to foo, if you say *p in an expression then you get the value of whatever p points to, and if you say *p = (whatever); then you change the value of whatever p points to. For example, if you wrote void ** pointToBlob = &blob;, then *pointToBlob = malloc(100); would be the same as blob = malloc(100); (they both write the result to the blob variable). But if you wrote void * pointToBlob = blob; and then pointToBlob = malloc(100);, you would be assigning to the variable pointToBlob, which is a different variable from blob, so blob would remain unchanged. Although those rules are simple, they're hard to think about. The reason seems to be that human beings are not good at separating the name of something from the thing itself. For example, what does pointToBlob mean? Do you intend it to point to the variable named "blob", or are you thinking of the memory you allocated as the "blob" that it points to? This kind of ambiguity is what makes pointers difficult. The good news is that it gets easier with practice. -- BenRG (talk) 02:16, 21 October 2010 (UTC)[reply]
As has been said, you can't use a pointer to point to both a char * and an int like that. You can, however, do it like this:
struct mystruct
{
  char *p;
  int i;
 };
 struct mystruct *blob = malloc(sizeof(struct mystruct));
You can then use blob->p and blob->i to refer to the char * and int values, assuming the malloc() succeeded. You can easily check this, because if malloc() fails, the resulting value will be a null pointer. JIP | Talk 12:09, 21 October 2010 (UTC)[reply]
Pointers really come into their own when you use them to point to arrays of dynamic size (although other structures and uses are also important). Consider this (not production-quality) code:
Several code examples
Single math test input
int n,i;
float *a;
printf("How many questions are on the math test? ");
scanf("%d",&n); /* give scanf() a pointer to n so it can assign to n through it */
a=malloc(n*sizeof*a); /* enough space for n floats; *a is a float, so sizeof*a==sizeof(float) */
printf("What are the answers? ");
for(i=0;i<n;++i) scanf("%g",a+i); /* a[i]==*(a+i), so a+i==&a[i] and we store into each in turn */
Now suppose that we have more than one test to give. Each might have a different number of questions, so now we need a separate array for each. Each array is (indicated by) a float*, so we need a float** to refer to all of them together:
Multiple math test input
int nt,*nq,i,j;
float **a;
printf("How many math tests? ");
scanf("%d",&nt);
a=malloc(nt*sizeof*a);   /* enough space for nt float _pointers_ */
nq=malloc(nt*sizeof*nq); /* enough space for nt ints */
for(i=0;i<nt;++i) {
  printf("How many questions are on test #%d? ",i);
  scanf("%d",nq+i);
  a[i]=malloc(nq[i]*sizeof*a[i]); /* enough space for nq[i] floats */
  printf("What are the answers? ");
  for(j=0;j<nq[i];++j) scanf("%g",a[i]+j);
}
Of course, you could also use a struct, as JIP mentioned:
A struct instead of two arrays
struct test {int n; float *ans;};
int nt,i,j;
struct test *a;
printf("How many math tests? ");
scanf("%d",&nt);
a=malloc(nt*sizeof*a); /* enough space for nt test structures */
for(i=0;i<nt;++i) {
  printf("How many questions are on test #%d? ",i);
  scanf("%d",&a[i].n);
  a[i].ans=malloc(a[i].n*sizeof*a[i].ans); /* enough space for a[i].n floats */
  printf("What are the answers? ");
  for(j=0;j<a[i].n;++j) scanf("%g",a[i].ans+j);
}
You can use a pointer to conveniently point to an object temporarily (which often involves the structure-pointer operator ->):
Using a temporary pointer
struct test {int n; float *ans;};
int nt,i,j;
struct test *a,*current;
printf("How many math tests? ");
scanf("%d",&nt);
a=malloc(nt*sizeof*a); /* enough space for nt test structures */
for(i=0;i<nt;++i) {
  current=a+i; /* point at the i-th element of the array; no new object is created here! */
  printf("How many questions are on test #%d? ",i);
  scanf("%d",&current->n);
  current->ans=malloc(current->n*sizeof*current->ans); /* enough space for current->n floats */
  printf("What are the answers? ");
  for(j=0;j<current->n;++j) scanf("%g",current->ans+j);
}
Finally (and this is very optional), you can use pointers as your loop variables to make idiomatic, very direct C code:
Replacing integers with pointers in for(...)
struct test {int n; float *ans;};
int nt;
struct test *a,*current,*end;
printf("How many math tests? ");
scanf("%d",&nt);
a=malloc(nt*sizeof*a); /* enough space for nt test structures */
end=a+nt;              /* points just past the end of a */
for(current=a;current<end;++current) {
  float *fcurrent,*fend;
  printf("How many questions are on test #%d? ",current-a); /* you can still get the index if you want */
  scanf("%d",&current->n);
  current->ans=malloc(current->n*sizeof*current->ans); /* enough space for a[i].n floats */
  fend=current->ans+current->n; /* points just past the end of current->ans */
  printf("What are the answers? ");
  for(fcurrent=current->ans;fcurrent<fend;++fcurrent) scanf("%g",fcurrent);
}
Just to wedge in one more use of float **, we can apply the "convenient alias for something" idea one more time:
With extra aliases
struct test {int n; float *ans;};
int nt;
struct test *a,*current,*end;
printf("How many math tests? ");
scanf("%d",&nt);
a=malloc(nt*sizeof*a); /* enough space for nt test structures */
end=a+nt;              /* points just past the end of a */
for(current=a;current<end;++current) {
  float *fcurrent,*fend,**fpp=&current->ans;
  int *ip=&current->n;
  printf("How many questions are on test #%d? ",current-a); /* you can still get the index if you want */
  scanf("%d",ip); /* this assigns to current->n, so we'll have the number later, but we can also call it *ip now */
  *fpp=malloc(*ip*sizeof**fpp); /* enough space for *ip floats */
  fend=*fpp+*ip; /* points just past the end of *fpp */
  printf("What are the answers? ");
  for(fcurrent=*fpp;fcurrent<fend;++fcurrent) scanf("%g",fcurrent);
}
Fundamentally, pointers let you access something that you get to choose (at runtime if you like). There are several reasons to choose things at runtime:
5 reasons
  1. When you don't know how much space you'll need, so you ask for it dynamically.
  2. When you have an array of things (dynamic or not) that you want to work on one at a time, and you make the pointer point to each one in turn (like current). (You can also work on them in any other order by writing a[whatever]: a[2*i*i-3*j+42], a[askUserWhich()], a[phaseOfMoon()], a[pickRandomly()], etc. Each of those uses pointer arithmetic to pick out an element for you.)
  3. When some other code is picking an object for you; it gives you a pointer to the one it chose.
  4. When you're picking an object for some other code: you pass it a pointer to which object you want it to work on. This is especially important when your objects are large: you pass merely its address, and no copying occurs. (See also aliasing; this is very useful, but can also be confusing.) Sometimes "work on" means "assign a value to", like with scanf(): you tell it where to put the value it reads from the input.
  5. Not really about runtime but about convenience: even if everything is allocated statically, it might be useful to keep a pointer to, say, myStaticArray[3][5].structMember[2] if that long expression refers to a value that you need to refer to frequently.
Except for #3 (which is just the opposite of #4), we used all of these in the examples I gave. Another way of looking at it is that there are only three things that can go on the left side of an assignment:
  1. A (non-array) variable name: x=1;
  2. A part of a struct: struct.y=1;
  3. A dereferenced pointer: *p=1;
Without the third choice, the struct would itself have to be a variable name or a member of another struct, so all you would get would be a.b.c.….z=1;, which is not very interesting. The third choice gives all kinds of possibilities because dereferencing a pointer can give you another pointer or a struct as well as a normal variable: a[4]=1; (because that's *(a+4)=1;), getPointer()->a=1; (because that's (*getPointer()).a=1;), **(*myStruct.ptrMember->memOfTarget)->mem2ndTarget=1;, etc.
I hope this long ramble ("general explanation") helps; I find that the usual introductions to pointers (like int i; int *p=&i; *p=42; printf("%d\n",i);) are so anemic that they prevent seeing the true utility of the subject. --Tardis (talk) 15:09, 21 October 2010 (UTC)[reply]


Thanks for all of your replies! The one thing I kept seeing over and over was that I must use a struct to access this info, can't I do this instead?:

void * blob = malloc(sizeof(char *) + sizeof(int));
char * blobChar = blob;
int * blob = blob + sizeof(char *); //since the integer is 4 bytes after the char *

—Preceding unsigned comment added by Legolas52 (talkcontribs) 21:40, 22 October 2010 (UTC)[reply]

I think you meant
void * blob = malloc(sizeof(char *) + sizeof(int));
char ** blobChar = blob;                   /* since it _points to_ a char * */
int * blobi=(char *)blob + sizeof(char *); /* can't do arithmetic on void * */
It might work, but it might also crash, or summon the nasal demons (and the answer will depend on the machine you try it on). (Also, who said that sizeof(char*)==4 everywhere?) The struct, as a language construct, exists so that this can be handled properly by the compiler. It also requires less typing and is more readable: struct {char *str; int len;} *s=malloc(sizeof*s); …and that's it! We now already have s->str and s->len with no further work. --Tardis (talk) 23:32, 22 October 2010 (UTC)[reply]
One reason why that might not work is that some systems require pointers of a certain type to be aligned at specific intervals in memory, such as addresses divisible by 2 or by 4. In your case above, you might end up with a misaligned pointers. By using a struct, the compiler guarantees that the addresses of the members are aligned, by inserting padding bytes between them if it has to. JIP | Talk 07:42, 23 October 2010 (UTC)[reply]

compiling emacs

[edit]

Hello. I am trying to compile emacs 23.2. After a successful ./configure, make gives me the following:

PS223:~/Downloads/emacs-23.2% make
cd lib-src; make all                            \
         CC='gcc' CFLAGS='-g -O2 -Wdeclaration-after-statement -Wno-pointer-sign  ' CPPFLAGS='-D_BSD_SOURCE  ' \
         LDFLAGS='-Wl,-znocombreloc  ' MAKE='make'
make[1]: Entering directory `/home/rksh/Downloads/emacs-23.2/lib-src'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/rksh/Downloads/emacs-23.2/lib-src'
boot=bootstrap-emacs;                         \
       if [ ! -x "src/$boot" ]; then                                     \
           cd src; make all                                    \
             CC='gcc' CFLAGS='-g -O2 -Wdeclaration-after-statement -Wno-pointer-sign  ' CPPFLAGS='-D_BSD_SOURCE  '         \
             LDFLAGS='-Wl,-znocombreloc  ' MAKE='make' BOOTSTRAPEMACS="$boot"; \
       fi;
cd src; make all                            \
         CC='gcc' CFLAGS='-g -O2 -Wdeclaration-after-statement -Wno-pointer-sign  ' CPPFLAGS='-D_BSD_SOURCE  ' \
         LDFLAGS='-Wl,-znocombreloc  ' MAKE='make' BOOTSTRAPEMACS=""
make[1]: Entering directory `/home/rksh/Downloads/emacs-23.2/src'
make[1]: *** No rule to make target `/usr/local/include/gtk-2.0/gtk/gtk.h', needed by `dispnew.o'.  Stop.
make[1]: Leaving directory `/home/rksh/Downloads/emacs-23.2/src'
make: *** [src] Error 2
HPS223:~/Downloads/emacs-23.2% 

What is going on here? It looks like there needs to be a rule to make gtk.h, but this can't be right? Anyone got any idea how to get round this? Thanks, Robinh (talk) 08:58, 21 October 2010 (UTC)[reply]


have you installed the gtk development headers? (Or configure without gtk). The package is normally called gtk-dev (debian/ubuntu etc) or gtk-devel (redhat/mandrake etc). CS Miller (talk) 10:47, 21 October 2010 (UTC)[reply]
Thanks for this. I am on SuSe 11.3, and YAST isn't particularly clear (there are lots of gtk-type options, but checking them results in an incompatibility warning. How do I tell whether gtk-dev is installed? Thanks, Robinh (talk) 11:03, 21 October 2010 (UTC)[reply]
I've never used YaST, so I'm not sure how to check what packages are installed with it. However, this [1] seems to be a useful guide. The package you want is probably called libgtk-dev / libgtk-devel, now that I think about it. CS Miller (talk) 11:42, 21 October 2010 (UTC)[reply]
Got it!
Resolved
. Cheers, Robinh (talk) 11:54, 21 October 2010 (UTC)[reply]
Hmm, this really shouldn't have happened. The autoconf script that wrote configure should check for gtk headers (and version), and indeed when I configure emacs on Ubuntu I see it checking gtk headers, libraries, and associated things like Pango, Cairo, and Freetype. If these aren't found, or are of the wrong versions, it should be be configure that fails, not the make. If you can reproduce this on a fresh install of SuSe, that's a notifiable bug in the configure.in script. -- Finlay McWalterTalk 13:18, 21 October 2010 (UTC)[reply]
Hello Finlay. I too thought that configure would find any problems. The behaviour is not reproducible, following a 'make clean' which may have cleared out some problem file somewhere. Best wishes, Robinh (talk) 13:36, 21 October 2010 (UTC)[reply]

Minor problem with my LG Flatron

[edit]

OK, so I've been having some non-critical yet annoying problems with my LCD display (a Flatron W1934S, to be specific). The overall image appears fine, but there are some wavy patterns jizzing up on my screen, which can be seen especially on a dark background. Is it because of an unstable AC connection or something? Blake Gripling (talk) 10:35, 21 October 2010 (UTC)[reply]

Noisy AC connection (perhaps from an electric motor on the same ring), loose AC connection, loose or damaged video cable, or source of RF interference near the display or the video cable. -- Finlay McWalterTalk 11:34, 21 October 2010 (UTC)[reply]
Apart from the above, and don't ask me how it works... but try adjusting your contrast. I had the same problem with a Dell monitor. Sandman30s (talk) 14:31, 21 October 2010 (UTC)[reply]
So to avoid interference, place any wireless emitting devices away from the monitor, and make sure that there are not that mucgh intercerence from devices from the cables to and from your computer and monitor. See if that helps. Sir Stupidity (talk) 21:37, 21 October 2010 (UTC)[reply]

Blackberry 9500 Storm

[edit]

Hi, I have my phone blacberry 9500 storm, was using zero line of france, turkey, I'm staying on the contract has expired, other operators çalıştıramadığımdan, mep2 code entered incorrectly 10 times, mep2 does not turn on, I can not enter the MEP code. please help. Thank you.

my adres= [email removed] —Preceding unsigned comment added by 88.224.127.41 (talk) 13:23, 21 October 2010 (UTC)[reply]

I've removed your email address, to prevent you getting spam on it. People will answer here, not by email. -- Finlay McWalterTalk 13:32, 21 October 2010 (UTC)[reply]
I expect it's not likely to be easy [2]. It's usually a rather bad idea to hit the limit with phone unlock codes. If you haven't actually entered the MEP2 code incorrectly 10 times then I'm not sure what's wrong. It may be worth calling your operator. As your contract has expired, they may be willing to provide any unlock codes for free perhaps even with instructions. BTW just to emphasise you should stop typing anything in until you know what to do Nil Einne (talk) 05:52, 22 October 2010 (UTC)[reply]

tsql

[edit]

Hi! Why doesn't exist the 'end tran' keywords? the rollback statement must always immediatly follow the trasnsaction to rollback? t.i.a. --217.194.34.103 (talk) 14:47, 21 October 2010 (UTC)[reply]

The database would have to store the state it was in before the transaction, and it gets too hard with several transactions that may be modifying the same data. So it just sticks to the latest one. Graeme Bartlett (talk) 21:11, 25 October 2010 (UTC)[reply]

motherboard

[edit]

where is the rt clock and how the quartz is deformed in order to produce the regular square wave? t.i.a. --217.194.34.103 (talk) 14:50, 21 October 2010 (UTC)[reply]

The real time clock can be positioned anywhere on the board, and may be integrated to some other ASIC on the board. Our article lists some examples; you can check your motherboard for one of those chips. You might want to read crystal oscillator; the quartz is an electromechanical resonator in the form of a piezoelectric crystal. Nimur (talk) 15:22, 21 October 2010 (UTC)[reply]
thank you, I read "When the field is removed, the quartz will generate an electric field as it returns to its previous shape, and this can generate a voltage. " But thus voltage is sinusoidal or square? --217.194.34.103 (talk) 15:51, 21 October 2010 (UTC)[reply]
It is a complicated waveform; it is not perfectly sinusoidal because in real life, crystals are not simple harmonic oscillators; but it is really close to sinusoidal. The exact waveform shape depends on the perfection of the manufacturing process and physical properties of the crystal. Digital systems usually need a square-wave. For this reason, a crystal oscillator will usually be connected to an active circuit with a power source. This circuit includes a transistor amplifier (or a more sophisticated IC) to "clip" the sine-wave into a square-wave, and often one or two external tuning capacitors. A simple clip circuit with two diodes is shown in our article. More complex circuits exist to shape the waveform, but for most purposes, an "approximately" square-wave signal is good enough. The particular parameters to worry about would be the rise time and the jitter - a well-designed circuit will have a "fast" rise-time and a "small" jitter (by using a good tuning circuit and a very high gain). Exactly how fast rise-time and how tiny the jitter will be determined by cost and requirements. Many RTC clock ASICs will contain all/most of these analog circuit elements, plus some digital logic, internally. Nimur (talk) 16:23, 21 October 2010 (UTC)[reply]

Internet Usage

[edit]

I've just downloaded a program called NetMeter to keep an eye on my internet usage. I'm in a hotel and have a daily limit of 1 GiB. I'm looking at the program now and my upload and download figures are increasing. Even though, to my knowledge, nothing is uploading or downloading. It says that I'm downloading 36 KiB/sec at the moment, and that I've downloaded 21 MiB in the last 30 minutes.

  • Why are the upload and download figures increasing when this is the only web browser I have open?
  • Does that amount of use sound plausible?
  • It's WiFi, so could that figure be the whole router's traffic and not just my laptop?

Some internet sites say that 5 GiB per month is enough to use Skype and YouTube. But according to NetMeter, I'd use 10 GiB a month just by leaving the machine connected to the internet for six hours a day; without even watching a single video or making a single call. What's going on?! Fly by Night (talk) 15:19, 21 October 2010 (UTC)[reply]

Consider using a system program like netstat to see what programs have open socket connections. Lots of programs use a network connection - this is very irritating if your network usage is being monitored. netstat -b will tell you the program name for each process that has an open connection. It's also possible that your NetMeter program has an internet connection open, and relays monitoring data to some server Nimur (talk) 15:24, 21 October 2010 (UTC)[reply]
My laptop runs on Windows Vista. I've just typed netstat -b and it says that "The requested operation required elevation." What does that mean? I typed netstat -no and it returned a table whose column titles were Proto, Local Addresses, Foreign Address, State and PID. There are currently three different local addresses connected to different foreign addresses.
  • What does all of that mean?
  • Are the other local address other people using the same router?
  • Does that mean that the Netmeter stats were for the router and not just my laptop?
Fly by Night (talk) 15:45, 21 October 2010 (UTC)[reply]
If you're getting 'The requested operation required elevation', try opening netstat or the cmd window if you're using that as administrator. Either right click on the program in start menu and choose 'run as administrator' or rather then pushing enter use ctrl+shift+enter. Nil Einne (talk) 15:57, 21 October 2010 (UTC)[reply]
Here is the Windows netstat documentation. Local address is your computer's address - specifically, which address the network socket is connecting into. It can help you diagnose the purpose of the connection. Foreign address is the IP of the server on the other end. State is the socket status - which is explained here - but basically tells you if the connection is "active." PID is the process ID for the responsible program that owns that socket; using "-b" tells you the program name so the PID is redundant (unless you are running multiple copies of the same program). Nimur (talk) 16:40, 21 October 2010 (UTC)[reply]

Windows Update maybe? I disabled it on my computer, but I think if you have it enabled it will automatically download new updates. Also, check which network interface the program is monitoring; if it's set to "all interfaces" it could be seeing network activity which isn't related to the internet, or could be seeing double the amounts depending on your setup. 82.44.55.25 (talk) 15:55, 21 October 2010 (UTC)[reply]

NetMeter's network inteface is set to All interfaces (no loopback, no duplicate). I've used the netstat -b command. I had to run it as an administrator as Nil suggested. I closed down all of my windows and ran netstat -b, the only thing running in the background was justched.exe which is a Java update checker. I stopped that. Then I ran netstat -b again and nothing was accessing the internet. But NetMeter still said that I was downloading 9 KiB/sec! Fly by Night (talk) 16:22, 21 October 2010 (UTC)[reply]


Sigh, for "computer experts" you're pretty incompetent. @OP; netmeter is not designed to work with wireless, so it's picking up on every network packet between your wireless adapter and the router. The excess bandwidth you're seeing is just the two devices communicating with each other. A program designed to work with wireless would filter this out. 72.95.222.173 (talk) 16:30, 21 October 2010 (UTC)[reply]

72, perhaps you would like to explain what communication the device is sending to the router? If there are no open sockets, there is no IP traffic. Are you suggesting that netmeter is capable of monitoring lower-level packets than IP (link or phy data)? Do you have a source for that? Nimur (talk) 16:34, 21 October 2010 (UTC)[reply]
That's a very good point, 72.95.222.173. It did seem far too high. Fly by Night (talk) 17:28, 21 October 2010 (UTC)[reply]
I'm pretty sure that 72.95.222.173 is wrong. -- BenRG (talk) 05:42, 22 October 2010 (UTC)[reply]
While not necessarily agreeing with the OP72, I wonder if this is being approached from the wrong way. It's been a while since I've used bandwidth monitoring programs on Windows but can't you find some which will tell you more details about what connections the bandwidth is being used on rather then the complexity of trying to working out from netstat? [3] may work although may also be unnecessary complex for the OP Nil Einne (talk) 17:19, 21 October 2010 (UTC)[reply]
What have I said that you don't agree with? Fly by Night (talk) 17:28, 21 October 2010 (UTC)[reply]
Sorry for the confusion as I was thinking about this discussion rather then the thread so by OP I meant 72. Nil Einne (talk) 19:34, 21 October 2010 (UTC)[reply]
P.S. Other then per IP, from memory some programs may also tell you per program which may be more useful Nil Einne (talk) 05:54, 22 October 2010 (UTC)[reply]
P.P.S. Just realised I used OP to refer to two different people in that comment. Oops! (Basically I was thinking of 72's comment and said OP to refer to them as I was replying to Nimur then started thinking of the general thread and said OP to refer to the real OP. Nil Einne (talk) 01:54, 24 October 2010 (UTC)[reply]

The usage graph in NetMeter has changed now that I'm using Skype. It was all red. Now there is a yellow sub-graph. It looks like the yellow is my usage and the red is something else. Maybe other people's usage or traffic between my computer and the router. I've just ended the call and the yellow part has vanished. Does anyone have any idea how to change the settings? Fly by Night (talk) 19:56, 21 October 2010 (UTC)[reply]

Red is download, green (and yellow) is upload. 82.44.55.25 (talk) 20:05, 21 October 2010 (UTC)[reply]
According to the key, red is download and green is upload. There is no green representation in the graph. Fly by Night (talk) 21:45, 21 October 2010 (UTC)[reply]
Yellow and green are the same. The green turns yellow when it's in front of red. 82.44.55.25 (talk) 21:59, 21 October 2010 (UTC)[reply]

php

[edit]

Say in php there was

echo "There are $number pages";

how could you get the script to put that into a .html file? 82.44.55.25 (talk) 18:38, 21 October 2010 (UTC)[reply]

If that is in a php script, accessing it through a web server will produce HTML. If you mean "I want to save this to a file", you need to open a file pointer and write it like:
$fp = fopen("your_file.html","w");
fputs($fp, "There are $number pages");
fclose($fp);
Then, you will have a file with that text inside of it. -- kainaw 18:40, 21 October 2010 (UTC)[reply]
Or, if you meant you wish to run from the command-line, you may want to use PHP Command Line Interface. Nimur (talk) 18:44, 21 October 2010 (UTC)[reply]
Or, perhaps, the questioner has a command-line script and wants to put it in a web page. Assuming the web server can parse PHP, you add to your HTML document the text: <?php echo "there are $number pages"; ?> -- kainaw 18:54, 21 October 2010 (UTC)[reply]

Spreadsheet of irregular payments

[edit]

I have a long list of rent money paid, and the dates they were paid on. i.e. the spreadsheet has two columns. The tenant was supposed to pay a fixed amount on the 1st of every month, but actually paid the rent very irregularly. Some months were missed completely, some were paid late, a few may have been paid early. The tenant has to pay x percent compound interest on late payments, if they are paid more than fourteen days late.

The question is: how do I work out on a spreadsheet what the tenant owes, including interest? The problem is that the data has irregular and missing dates, so it will be much harder to calculate than if the dates were just regular dates one month apart. Not a homework question. Thanks. 92.15.29.194 (talk) 20:11, 21 October 2010 (UTC)[reply]

charge them simple interest, not compound. Sorry, it's not right of you to charge them the 15% you feel confident you could have made on the stock market either. Charge them 8% simple interest. 85.181.49.255 (talk) 21:02, 21 October 2010 (UTC)[reply]
I think you might have to put in a third column with the dates that each rent payment should have been paid on - ie the first of each month. You may have to add rows in for the months that the rent was not paid - for these months, you should manually insert the amount of rent into the the rent column and put N/A in the date column. Then, assuming that we're starting on row 2 and that column A has the date the rent was paid and column B has the rent amounts and column C is the one you added in, put the following in cell D2: =IF((A2-C2)>14,B2*(1+Data!A$1)^((A2-C2-14)/365.25)-B2,0). This deals with the months when the rent was paid. For the months when the rent was not paid, put the following into E2: =IF(A2="N/A",B2*(1+Data!A$1)^((Data!A$2-C2-14)/365.25),0).
The sheet Data has the annual interest rate in cell A1 and today's date (or the "as-of" date) in cell A2. I can't check if this works since I don't have access to Excel on this computer. You'll get errors in column D for the months where no rent was paid (you can get rid of them automatically by selecting column D and pressing ctrl+G) - then add up columns D and E. Zain Ebrahim (talk) 21:37, 21 October 2010 (UTC)[reply]
When the rent was paid for a particular month, was it always paid in full? If so, that makes the calculation much easier. Work out a daily interest rate. When you simply subtract 2 dates in Excel, it calculates the number of days. So, suppose the due date is in column A, the paid date is in column B, and the amount due is in column C, then column D could contain the number of days paid late as B2-A2, and column E could contain the interest due as '=IF(D2>14,(D2-14)*C2*daily_interest,"")'. Calculate a sum at the bottom of column E and request they pay that. However, if they are already struggling to pay the rent do you really think asking for the interest is actually going to make them pay more quickly in the future? You might just be dumping further despair on your tenant. You also need to consider what to do if they refuse to pay the interest, do you persue them through the small claims court? And if they are a benefit claimant you might eventully get the money at the rate of £1 per week. Your local Citizens Advice Bureau will almost certainly be able to provide you better advice, for free. Astronaut (talk) 21:54, 21 October 2010 (UTC)[reply]
The former tenant is quite well off and rented the place as part of a business. 92.29.125.8 (talk) 11:05, 22 October 2010 (UTC)[reply]

I'm wondering how to deal with a missed payments. Supposing the tenant missed one payment in January but paid all other payments that year in full and on time. Should I calculate the interest due from the January until the present time; or should I regard the February and subsequent payments as late payments for the previous month? 92.29.125.8 (talk) 11:05, 22 October 2010 (UTC)[reply]

The 14 day interest-free period causes both methods to give different answers. Note that if you go with the second approach (which seems like the likelier option), then my answer above would not be right. Zain Ebrahim (talk) 11:20, 22 October 2010 (UTC)[reply]
The 14 days is not interest free. If the rent was paid on day 13, no interest added. If it was paid on day 15, then 15 days of interest are added. I'm wondering if this would make the two modes of calculation equivalent, if all the late rents were more than 14 days overdue. 92.15.28.203 (talk) 19:39, 22 October 2010 (UTC)[reply]

As the comments above note, there are multiple ways of calculating compound interest when the debt is being sporadically incurred and repaid. If this is just an academic question, then the answer depends on the method described in the hypothetical credit agreement that both parties entered into at the beginning of the contract and (depending on whether the debtor is a consumer or a limited company, several acts of parliament). But your post (as ip 92.29.125.8) strongly suggests this is a real scenario, which means this question is veering off into the territory of legal and professional advice, which the reference desk absolutely does not provide. You should speak to a qualified accountant. I'm reluctant even to tell you which laws you might be breaking (lest I help you self-help yourself to Pentonville) but I definitely would not go sending an invoice or a demand until you've spoken to a qualified professional. -- Finlay McWalterTalk 17:15, 22 October 2010 (UTC)[reply]

This is about manipulating data with a spreadsheet and maths, no legal stuff involved. I could re-write it if you wish as a scenario in Cuckooland, where the teddy bears trade Smarties. 92.15.28.203 (talk) 19:39, 22 October 2010 (UTC)[reply]