Wikipedia:Reference desk/Archives/Computing/2009 March 11

Computing desk
< March 10 << Feb | March | Apr >> March 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.


March 11

edit

Skype problems

edit

Please help my microphone wont work with Skype on my laptop but it works with the Skype on my other computer. Skype used to work with my old microphone and I didn't change the settings so I assumed its broken so I got a new one and it won't work either! The test call doesn't say its muted or any other error message but I can't hear the message playback at all. My laptop is a Compaq, I'm running Windows XP, I have Skype version 3.8.0.188 and I have a Logitech headset. Can anyone help please? --124.254.77.148 (talk) 03:42, 11 March 2009 (UTC)[reply]

This is from the "blindingly obvious" department, of course, but have you ensured that your microphone's volume setting on the computer isn't turned way, way down? It wouldn't show up as muted then, but if it's turned down low enough, it won't pick anything up, either. -- Captain Disdain (talk) 08:50, 11 March 2009 (UTC)[reply]
This happens to me once in a while. Go to the Control Panel and open Sounds and Audio Devices. Click on the Audio tab and ensure that your microphone is enabled for the Sound recording. Mostly like it has been replaced by another device. Regards, Bendono (talk) 14:18, 13 March 2009 (UTC)[reply]

Gnome Sort

edit

Hello. Can someone tell me how the Gnome sort can have a best case performance of O(n)? Also, how do you find the average case complexity of such an algorithm?--202.88.229.115 (talk) 04:34, 11 March 2009 (UTC)[reply]

Best case scenario is when everything is already sorted. It will check n-1 items, which is O(n). -- kainaw 04:38, 11 March 2009 (UTC)[reply]
okay,thanks. so the average case is also o(n*n)?--202.88.229.115 (talk) 04:53, 11 March 2009 (UTC)[reply]
It is, in my opinion, just insertion sort. Instead of a nested loop, they mess around with the list pointer. The average case for insertion sort is O(n2). So, gnome sort would be the same. -- kainaw 06:06, 11 March 2009 (UTC)[reply]
Even the ultra-crappy bubble sort is O(n) in the best case. Best-case isn't usually very interesting. We're mostly interested in worst case (if we know nothing about the data and are in need of finishing within some known amount of time) - or average case (especially if we know something about our data - and if we'll be doing a lot of sorting so that the average is likely to be statistically correct).SteveBaker (talk) 00:52, 12 March 2009 (UTC)[reply]

/stalk for pidgin

edit

On Chatzilla, you could type /stalk some phrase and it would stalk that phrase or user. If that phrase was said, you would get the notification as if your name had been mentioned. Now that I've switched to Pidgin, it seems there is no such function. Is there any add-on, extension, etc. that will add this feature? flaminglawyer 06:32, 11 March 2009 (UTC)[reply]

I think this function is often called "highlight" or "hilight".... (but I don't think Pidgin has it. It's far from a real chat client (but is awesome for IMs.)) --grawity 21:05, 13 March 2009 (UTC)[reply]

PNG in PHP problem

edit

Recently, I've been trying to teach myself PHP. I have a free domain at X10hosting.com where I am trying to make a PHP-based website. According to X10hosting, GD is already installed, but when I try something like:

<html>
<body>
<?php
    $img=ImageCreate(300,300);
    
   //Do stuff to the image...
                                                            
    ImagePNG($img,"images/test.png");
    ImageDestroy($img);
?>
<img src="images/test.png" border=0>
</body>
</html>

it doesn't display anything at all. And it isn't just this particular example, it seems to be more specifically the "ImagePNG" statement, I have tried it in various ways but it doesn't seem to work. Thanks in advance, Jkasd 07:50, 11 March 2009 (UTC)[reply]

Have you tried checking the return from ImagePNG? I suspect your problem might lie in the image paths—the path used by executing code is *rarely* the same as the URL. But a better approach (assuming you don't need the images after the users' requests) would be to have a php script create the image and send it directly to the browser. You can accomplish that using the same ImagePNG command, just drop the filepath (see example at php.net). You could then just pass the URL of this image-processing php file as the src of the img tag. Not only will it be faster for single-use images, but it also conveniently avoids the problems of cross-session corruption and temporary file removal. – 74  08:40, 11 March 2009 (UTC)[reply]
Ok, I've tried that (I think). I've put something like:
<img src="image.php">
in a different html file. But it will just display the browser icon for an unreadable image. The image.php file is more like:
<?php
    $img=ImageCreate(300,300);
    
   //Do stuff to the image...
                                                            
    ImagePNG($img);
?>
this time. Is that how you mean, or am I still doing something wrong? Jkasd 02:27, 12 March 2009 (UTC)[reply]
Take a look at the "unreadable image" — it might be an error message. --98.217.14.211 (talk) 03:56, 12 March 2009 (UTC)[reply]
The correct image header needs to be attached to the image. Here is the php.net example code:
<?php
$im = imagecreatefrompng("test.png");

header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>
Note the header "Content-type"; that's what tells a browser how to handle the byte-stream that follows. Essentially, you should be able to point your browser at image.php and see the image. – 74  08:14, 12 March 2009 (UTC)[reply]

Java programming - how do I do this...

edit

Hi,

I am currently writing some code which runs a loop, and in each run of the loop it creates an object (CD, say) - but I want it to create a differently named object each time, by incorporating the loop number into the name. How do I do this? Here's roughly what my code looks like:

for(int q = 0; q < database.size(); q++)     // where database is an ArrayList
{
   CD myCD* = new CD();        //where * is, insert the varible q
}

I want this loop to produce varibles myCD0, myCD1, myCD2 etc.

Anyone know how to do this? Or point me in the right direction?

Any help is much appreciated.

Thanks! —Preceding unsigned comment added by 81.156.58.73 (talk) 10:29, 11 March 2009 (UTC)[reply]

Let me point you in another direction. The name of the variable is internal to your application and in itself is fairly meaningless. Thus, if it your intention to store a number with each instance of a CD for whatever reason, then you need to store that within the CD object itself. For example, you could define CD as such...
class CD
{
	public CD(int number)
	{
		this.number = number;
	}
	
	public int GetNumber()
	{
		return number;
	}
	
	private int number;
}
In your initial code, please recognize that all of your CD objects will go out of scope (ie, become inaccessible) immediately after each iteration of the loop. Finally, you could use it like...
public static void Foo()
{
     // Suggest parameterizing this with a type
     ArrayList database = // ...
		
     // Need a place to store CDs
     List<CD> cds = new ArrayList<CD>();
		
     for(int q = 0; q < database.size(); q++)
     {
	// Create CD instance; store loop number.
	CD myCD = new CD( q );
	   
	// Add CD to list.
	cds.add(myCD);
     }
		
     // Test: Output the stored numbers for each CD
     for (CD cd : cds)
     {
	System.out.println( cd.GetNumber() );
     }
}
Hope this helps. Regards, Bendono (talk) 11:02, 11 March 2009 (UTC)[reply]
Note that in Java, it is very uncommon for a program to have variable names like cd0, cd1, cd2, cd3... If that is desired, you should (at a minimum) use an array like:
CD[] myCD = new CD[database.size()];
for(int q = 0; q < database.size(); q++)
{
  myCD[q] = new CD();
}
It is nearly what you asked for - just the addition of a [ and ]. -- kainaw 12:57, 11 March 2009 (UTC)[reply]
Certainly a typo, but if not obvious to others you will need to remove the type CD preceding myCD[q] in the for loop. Bendono (talk) 14:24, 13 March 2009 (UTC)[reply]
Correct - changed code. Luckily, that's a typo the compiler would complain about. -- kainaw 17:05, 13 March 2009 (UTC)[reply]

digital pen/stylus

edit

Would this work on my HP Compaq 4400? I want a cheaper alternative to this, which the tablet originally came with. ~EdGl (talk) 15:42, 11 March 2009 (UTC)[reply]

Since my laptop screen isn't touch-sensitive, I guess I need to use the pen that comes with the laptop :\ I can't find any for less than $40 though, which sucks. Guess I'm outta luck, huh? ~EdGl (talk) 19:42, 11 March 2009 (UTC)[reply]
I'm afraid so. If your tablet using magnetic tracking you absolutely need a stylus specifically designed to work to work with that tablet. APL (talk) 13:20, 12 March 2009 (UTC)[reply]

Incorrect behaivour or mailicious code?

edit

Moved from misc desk

Hi,

I'm using Internet Explorer version 6.0.2009.2180.xpsp_sp2_qfe.080814-1242. When i search on Eliot Ness and press go. I get a file download. This does not happen with other search word as e.g. apple. And not in FireFox. I dont know what the file is I did scan it with symantec antivirus but that found nothing.

Just tought that I should inform you of this. —Preceding unsigned comment added by 213.31.11.24 (talk) 15:02, 11 March 2009 (UTC)[reply]

The problem is almost certainly at your end. There is no known behaviour in the wiki software that would allow a file to pop up when you are just searching for an article. --Richardrj talk email 15:26, 11 March 2009 (UTC)[reply]

Sync Evolution and Collanos

edit

How can I synchronize Evolution (software) with Collanos? Is there any way of exporting Collanos' data and importing them into Evolution? Is there a general format for task data? Mr.K. (talk) 17:23, 11 March 2009 (UTC)[reply]

Finding the same text in two different files

edit

I have this Boston_Celtics_all-time_roster, and this Los_Angeles_Lakers_all-time_roster. Now, how can I find players that played in BOTH teams (if there's such a player)? I'd need something like diff or cmp but I'm not sure. Thanks! --Taraborn (talk) 17:56, 11 March 2009 (UTC)[reply]

I'm not on a unix machine, so I can't test this, but here's what you do: say you have two text-files, "players1.txt" and "players2.txt", concatenate them, sort them, and then look for duplicate lines (using uniq). So something like this:
cat players1.txt players2.txt | sort | uniq -d
But as I said, I can't test it right now, but that would be a way to do it. 195.58.125.47 (talk) 18:38, 11 March 2009 (UTC)[reply]
Thank you! --Taraborn (talk) 20:03, 11 March 2009 (UTC)[reply]
What you should use is join. Assuming that both players1.txt and players2.txt are sorted,
join players1.txt players2.txt
will give you what you want. --173.49.15.165 (talk) 02:29, 12 March 2009 (UTC)[reply]
What you want is comm. The problem with comm is that it requires both files to be sorted. So, sort both files (sort will do that easily). Then, use comm -1 -2 boston.sort lakers.sort. The -1 suppresses entries only in the first file. The -2 suppresses entries only in the second file. What is left is entries in both files. -- kainaw 03:37, 12 March 2009 (UTC)[reply]

Google Currency Converter to Only Two Decimal Places?

edit

Is there anyway to get Google currency converter to display the result to only two decimal places, unlike the current way it's shown?

--91.104.49.185 (talk) 19:02, 11 March 2009 (UTC)[reply]

I think you can set that in your preferences (if you have a Google account). I'll check it out and get back to you. — Ched ~ (yes?) 19:49, 11 March 2009 (UTC)[reply]
hmmmm ... couldn't find anything in either basic preferences or the calculator. Maybe one of the links it provides with result would give you more the output you're looking for. Sorry — Ched ~ (yes?) 19:49, 11 March 2009 (UTC)[reply]
An easy solution would be to use a bookmarklet: just create a new bookmark on your browser's toolbar with the name as "Currency" and for the location paste this in:
(code hidden to prevent widening page in browser)
javascript:(function() { for (var i = 0, h2s = document.getElementsByTagName('H2'); i < h2s.length; i++) { var h2 = h2s[i]; if (h2.className == 'r') { h2.innerHTML = h2.innerHTML.replace(/( = \d+[.,]\d\d)\d+/, '$1') } }; void(0); })()
Now when you are looking at the ugly decimals, just click on "Currency", and they'll vanish. Greasemonkey basically does the same thing, but spares you having to click anything, at the cost of some complexity in setup. --Sean 21:12, 11 March 2009 (UTC)[reply]

Speex audio from Adobe Flex / Flash Player 10 .flv via Red5 to .wav PCM?

edit
  Resolved

I am having trouble converting a .flv audio-only file uploaded from Adobe Flex / Flash Player 10 to a Red5 server using the Speex voice coder:

http://livedocs.adobe.com/flex/3/langref/flash/media/Microphone.html

http://jira.red5.org/confluence/display/codecs/Speex+Codec (which references an "official patch" to ffmpeg at the end)

Questions:

1. How do I extract the audio track out of such a .flv file?

2. How do I convert it from Speex to .wav PCM?

Thanks. 69.228.87.198 (talk) 21:54, 11 March 2009 (UTC)[reply]

This is resolved; I needed the speex-1.2rc1 tarball instead of the debian/ubuntu libspeech-dev package, which is too old to link up with current versions of ffmpeg's --enable-libspeex.
cd ~/src/speex-1.2rc1/
./configure --prefix=/usr
make; make install
cd ../ffmpeg
./configure --enable-libspeex
make; make install
ffmpeg -i SpeexQ6R16Efalse.flv foo.wav
...worked. 69.228.87.198 (talk) 06:59, 12 March 2009 (UTC)[reply]

Access 2007 and autogenerated form fields

edit

Hi, apologies if this is covered in the archives. My basic problem is that I don't know enough Access jargon to Google the answer, and the same goes for searching on Wikipedia.

I'm looking for a way to make Access 2007 create blank copies of a group of fields within a record, as soon as data is entered into any field of the original group. The idea is to use a database to track each action taken on different parts of a work project, and when details of an action are entered, to have the database automatically create blank fields for the next action. Ideally using a form to enter the details, with the form's target fields being autoupdated at the same time. Can this be done while keeping all the data within one record - actually, can it be done at all?

Love the refdesks btw - so far you guys have answered every dumb question I posted here, both as an IP and when logged in :-) — FIRE!in a crowded theatre... 22:02, 11 March 2009 (UTC)[reply]

I was under the impression that Access already behaved in this manner (though I may be confusing it with one of its SQL siblings). When you create a new record, all the fields in the record should be created as well. You can set these fields to a default value, but I think the default default value is blank. When updating a record, new fields should *not* be created (they should already exist). You might try using some sort of status indicator to determine which actions have and have not been completed. – 74  08:26, 12 March 2009 (UTC)[reply]

iPhone and Blackberry

edit

This may be a dumb question... can you surf the internet like you would on a normal computer on an iPhone or Blackberry? Alientraveller (talk) 22:37, 11 March 2009 (UTC)[reply]

(ec):Yep! The method is quite awkward, in my opinion at least, and some pages don't display properly, but it is possible. Note: You would want a data plan from your service provider, otherwise it could get quite expensive. Thanks, Genius101Guestbook 22:53, 11 March 2009 (UTC)[reply]
The browser on the iPhone (I've never used a Blackberry, so I don't know about them) is extremely good and uses topical zooming to display large pages on the small screen. THis is different from other small-screen targeted browsers, which either just had a small pagesize (which breaks pages that assume a given screen size) or which tried to do clever things to pages (which inevitably breaks lots of them). It's let down by the network connection - even on 3G it's frustrating to use because of the network speed. So really "yes" in theory, but you probably wouldn't want to do (for long) in practice. 87.115.143.223 (talk) 23:20, 11 March 2009 (UTC)[reply]
So, to summarize, yes, you can "surf the internet", but no, it's not "like you would on a normal computer". StuRat (talk) 01:22, 12 March 2009 (UTC)[reply]
To add more detail, yes and no. Right now the iphone safari doesn't support flash, so those page elements will unviewable. But the iphone safari browser is a huge improvement over the old internet explorer mobile (have not used a recent version). Also, many pages, especially google pages, will default to a iphone specific version that may limit some features but fit better on the screen, and with the navigation elements. Sometimes you can override these page versions, but that depends on the site you're visiting. The iphone does not replace a computer-based browser, but it can certainly fill in a lot of holes. If you have some specific page you're concerned about, or concern you're getting at, you should ask about it. Shadowjams (talk) 05:55, 12 March 2009 (UTC)[reply]

When does a MAC Address Change?

edit
  Resolved

Would I be right in assuming that MAC Addresses only change if some hardware change (which hardware by the way?). Will my MAC Address be the same if I switch OS (XP -> Ubuntu)?

TIA. PrinzPH (talk) 22:51, 11 March 2009 (UTC)[reply]

The MAC is generally encoded into the ethernet adapter. In times of yore it was fixed (either by pull-up resistors or jumpers) on the ethernet card. Now it's generally kept in non-volatile (flash memory, generally) storage alongside the ethernet firmware. That means that it won't change when you reboot your machine or boot to a different OS, even if you blank (or replace) the disk entirely. You can, however, change it yourself if you want (or need) to (although there's rarely much point) - on linux there's an option to do that in ifconfig (ifconfig eth0 hw ether ab:cd:ef:01:23); I don't know of a standard way to do the same in Windows. 87.115.143.223 (talk) 22:59, 11 March 2009 (UTC)[reply]
Oh, I didn't answer the "which hardware" part of your question. On old machines there was a separate ethernet card (and you might still have a separate wireless ethernet card or USB adapter) - the MAC address belongs to that, so changing that would result in a new MAC. These days most machines have the ethernet adapter built into the motherboard, so you'd have to change motherboard to accidentally get a new MAC. 87.115.143.223 (talk) 23:10, 11 March 2009 (UTC)[reply]

Ahh thank you... I used to think that the MAC address somehow had something to do with being an identifier for your computer's current setup (what memory, hdd, etc)... Maybe I confused it with how windows recognizes your computer and if you change too many components it will refuse to boot (into windows)? PrinzPH (talk) 00:24, 12 March 2009 (UTC)[reply]

Microsoft have, at least in the past, used the MAC as part of the algorithm to determine your Globally Unique Identifier; in addition Microsoft does use the MAC as part of the scheme for Windows Product Activation. So you're right. 87.115.143.223 (talk) 00:58, 12 March 2009 (UTC)[reply]
We have instructions for changing your MAC address under different OSs in b:Changing Your MAC Address. If you have changed the MAC address in one OS but not the other, or changed them differently in different OSs, then your MAC address would indeed change when you switch operating systems. --76.167.241.45 (talk) 04:21, 12 March 2009 (UTC)[reply]
What? How can a value that's stored in a chip on a card vary depending on what OS you've booted? 93.97.184.230 (talk) 09:15, 12 March 2009 (UTC)[reply]
On startup, the ethernet card loads its default MAC from flash and stores this in RAM. It uses this value when generating ethernet frames. When it receives the "set your MAC" instruction (e.g. from ifconfig) it changes that RAM copy, but not the flash copy. So the change lasts only until the card is reset or powered off. For a change to be almost-permanent, in the way 76.167.241.45 suggests, you'd put that ifconfig line into the OS's startup scripts. That said, some cards do allow you to permanently change the MAC stored in the flash. Note that changing the MAC is not without risk; factory set MACs are guaranteed to be unique, but if you set your own you risk duplicating an existing MAC on your network (in practice that's almost impossible if you pick a truly random MAC, but quite likely if you idly decide just to change one digit). In that event your local switch with get utterly confused, and the resulting network anarchy will be extremely difficult to diagnose. 87.115.143.223 (talk) 12:52, 12 March 2009 (UTC)[reply]