Wikipedia:Reference desk/Archives/Computing/2009 December 5
Computing desk | ||
---|---|---|
< December 4 | << Nov | December | Jan >> | December 6 > |
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. |
December 5
[edit]HP Laserjet M1120 vs Linux - CLOSED
[edit]Done
Short and sweet ('s 2 am here and I'm dying): does anyone have any experience with HP's all-in-one M1120 on Linux (I'm running Zenwalk Linux specifically). Broader: which all-in-one, if any, would you guys/gals recommend? I know I will prefer a laser printer over an ink jet printer, and I'd like to have a scanner. Xeros machine functionality would be nice, but I'll live without it. No networking/fax/misc magical powers are really necessary. Thanks for your input, friends. Cheers, Ouro (blah blah) 00:35, 5 December 2009 (UTC)
- The open printing database quotes one person who says printing and scanning work (on Ubuntu at least) out of the box. -- Finlay McWalter • Talk 02:15, 5 December 2009 (UTC)
- I'm gonna close this because I did some searching and I found that it's supposed to work thanks to the libraries hplip and foo2xqx. Thanks, Finlay, for your contribution! --Ouro (blah blah) 16:37, 7 December 2009 (UTC)
C
[edit]Two questions about C programming:
1. When I run a compiled C program from the terminal using the "exec" command, the terminal closes when the program finishes. How can I get it to stay open?
2. Consider the following code:
void main(void) { // some lines of code check(); // Line A // some lines not calling check() check(); // Line B // more code }
If no key was pressed between lines A and B, check() returns a one-item list containing 0. If a key was pressed, check() returns a list of values corresponding to the keys pressed, in the order that they were pressed. Furthermore, check() does not cause any break/pause/etc in the execution of the program.
Are there any functions that can be used to create check()?
If it's pertinent, I use Code::Blocks and GCC. 72.197.202.36 (talk) 00:39, 5 December 2009 (UTC)
- Don't use exec, or exec a command followed by a pause command of some sort (which really means you've spawned a new shell anywasy, so you may as well skip exec and just do program && pause && exit. Exec means the program replaces the shell, and when the program goes, so will the shell.
- A non-blocking single character read would work, but real input handling is OS dependent. You'd need to give more details. —ShadowRanger (talk|stalk) 00:44, 5 December 2009 (UTC)
- For question 2, consider using keyboard hooks for a Windows system.--TParis00ap (talk) 04:28, 5 December 2009 (UTC)
- I don't think you want to use keyboard hooks, since that will capture all key activity even when your window doesn't have the input focus. For a Windows console application, ReadConsoleInput is the function you want (or just ReadFile if you don't care about mouse clicks and non-ASCII keys and such). To avoid blocking, you should first call WaitForSingleObject with a timeout of 0 to check whether there's anything available to read. To get keypresses immediately, instead of line by line, you need to use GetConsoleMode/SetConsoleMode to disable line input. The Linux equivalents are read, select/poll, and tcgetattr/tcsetattr. -- BenRG (talk) 02:13, 9 December 2009 (UTC)
- For question 2, consider using keyboard hooks for a Windows system.--TParis00ap (talk) 04:28, 5 December 2009 (UTC)
Can I use a RAID controller without any RAID?
[edit]I am trying to buy a cheap older computer to work as a data server in my house, and I already have a couple of large SATA drives already filled with data. I am looking at a Dell Dimension 8400 because the specs say it can take four SATA drives, and I think I'll buy another someday. When reading the manual it talks about RAID configurations 0 and 1, which both sound very nice, but if I understand them correctly neither is what I want. I want to keep the data on the drives (neither will have the OS), and I'd like to be able to a) remove them easily with everything working fine and b) take them to another computer, possibly as an external drive. So can I use a RAID controller in this manner? Thanks for your help. mislih 00:48, 5 December 2009 (UTC)
- What you describe is called a JBOD ("just a bunch of disks"). That page you linked doesn't seem to mention RAID, so I guess that the machine doesn't come with one, and that you intend to install a PCI RAID (from someone like Adaptec), right? Every RAID controller I've ever used had a JBOD mode; but I'd check the specs of the specific RAID controller you're thinking about before buying one. Note that you can get a PCI SATA expansion card (that doesn't do hardware RAID) for a bit less than a RAID card (and, perhaps confusingly, you can still do RAID anyway, just with the OS and the CPU doing the work). -- Finlay McWalter • Talk 01:45, 5 December 2009 (UTC)
- No, I picked this machine because it has four SATA ports on the motherboard as shown in the page I linked to above. When I read the manual is where it talks about RAID (the pdf I linked to is a pretty big). From other reading, I think it means the motherboard has 'fakeRAID' built in. Are you saying I can I run it in JBOD mode and get seperate disks? mislih 02:22, 5 December 2009 (UTC)
- p22 talks about turning "RAID On", and talks about machines being delivered without that configuration. So that seems to me to be a pretty strong implication that, with RAID off, it's just a JBOD. -- Finlay McWalter • Talk 02:30, 5 December 2009 (UTC)
- Thanks for the help! mislih 04:19, 5 December 2009 (UTC)
- Be careful with the JBOD mode, in some cases it refers to a series of disks that the controller stitches together to form one logical disk. If you use the disks in this manner they will *not* be independently removable or transportable. --66.195.232.121 (talk) 17:17, 7 December 2009 (UTC)
adding Wikipedia search engine to my page
[edit]I would like to add Wikipedia search engine to http://sovietdream.com/researches/ , so that client would be taken to Wikipedia separate result page after entering search words to, that engine in my page. Could I get html code of such search engine? —Preceding unsigned comment added by 78.58.207.25 (talk) 08:50, 5 December 2009 (UTC)
my email - [redacted] —Preceding unsigned comment added by 78.58.207.25 (talk) 08:54, 5 December 2009 (UTC)
- email removed to avoid questioner suffering spam. Question reformatted. --Phil Holmes (talk) 10:52, 5 December 2009 (UTC)
- Here is the basic template used on most Wikipedia pages. It is pretty straightforward to modify; all I did was all the full en.wikipedia URL to the "action" value to make it portable.
<form action="http://en.wikipedia.org/w/index.php" id="searchform">
<input type='hidden' name="title" value="Special:Search"/>
<input id="searchInput" title="Search Wikipedia" accesskey="f" value="" name="search" />
<input type='submit' name="go" class="searchButton" id="searchGoButton" value="Go" title="Go to a page with this exact name if one exists" />
<input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="Search" title="Search Wikipedia for this text" />
</form>
- Enjoy. --Mr.98 (talk) 15:21, 5 December 2009 (UTC)
Problem with MediaWiki code which I copied over to swfanon.wikia.com
[edit]Hey,
I copied {{Article issues}} over to the Star Wars Fanon Wiki: http://swfanon.wikia.com/wiki/Template:Mult_issues. I also copied over any other needed templates: {{DatedAI}}, {{Ambox}}, {{Ambox/core}} and {{ns0}}. Now, on Mult_issues/test, I cannot seem to get any of the parameters (which are all new, replaced ones, and no originals) to show up. Have I deleted a crucial bit of code? Or am I still lacking a certain template? Neither the Sysop nor I can figure out what's wrong with it. I hope you guys can do a better job ;-)
Thanks in advance, :-),--213.168.119.120 (talk) 09:30, 5 December 2009 (UTC)
- Wikipedia has a lot of MediaWiki Extensions. Often, the more complicated templates on Wikipedia are deeply interwoven into these kinds of software modifications. All of them are freely available, and you can compare which sets are installed on Wikipedia's MediaWiki Version Information and the corresponding page on your wiki. I can't see any of the obvious ones missing (ParserFunctions is often missing on third-party wikis). All this is still hinging on the hunch that the trouble is based on a missing extension, which may not be the case, but it's what I would check first. Nimur (talk) 14:50, 5 December 2009 (UTC)
- And they are often dependent on markup in MediaWiki:Common.css and code in MediaWiki:Common.css. See m:Help:Transwiki. ---— Gadget850 (Ed) talk 15:42, 5 December 2009 (UTC)
- The last link should probably be MediaWiki:Common.js. --Andreas Rejbrand (talk) 17:15, 5 December 2009 (UTC)
Find the center of a triangle in Blender
[edit]In Blender, I want to add a vertex at (I think) the circumcenter of a triangle. That is, a location equidistant to the three other points. Selecting the three points and choosing snap->cursor to selection doesn't do the job: it moves the cursor to (I think) the centroid, the average of the three points, instead. Any idea how to get my desired kind of center? This would be useful for constructing polyhedrons and probably for other things. 93.97.21.17 (talk) 11:19, 5 December 2009 (UTC)
- I don't use Blender, but the circumcenter is indeed equidistant from the three vertices, and can be constructed by drawing the perpendicular bisectors of the three sides. Does Blender have a routine for this? Dbfirs 13:26, 5 December 2009 (UTC)
- If it does not, Blender supports Python scripting, so you can write your own routine. The math would be fairly simple to compute the circumcenter; the hardest part would be locating the API to access the current vertices and get their coordinates. That would be the list() routine to get your object name, followed by the getData() routine to get its mesh and vertices. We have a WikiBook on Blender Scripting which walks through an example of getting vertex information. In addition, the official manuals and tutorials are available from the Blender website. Nimur (talk) 14:58, 5 December 2009 (UTC)
- That is a most useful-looking wikibook, thanks for the link. 213.122.21.216 (talk) 15:53, 5 December 2009 (UTC)
- If it does not, Blender supports Python scripting, so you can write your own routine. The math would be fairly simple to compute the circumcenter; the hardest part would be locating the API to access the current vertices and get their coordinates. That would be the list() routine to get your object name, followed by the getData() routine to get its mesh and vertices. We have a WikiBook on Blender Scripting which walks through an example of getting vertex information. In addition, the official manuals and tutorials are available from the Blender website. Nimur (talk) 14:58, 5 December 2009 (UTC)
Force no redirects when searching
[edit]Hello all. I have attempted to solve this myself but I am not very good at these things. When I type a URL into my address bar (I use Firefox) and I make a typo, I get automatically redirected to Bing search for the typoed URL. 99.99% of the time what I want is to simply go back to the address bar and fix the letter I omitted or typed wrong and hit enter and I have no use for the search results. However, I can't do this since the URL has been changed to Bing's search URL. Is there a way to only go to exactly where I typed without being redirected (in the case of typos, I guess to nowhere with my browser saying the page cannot be found) so that the address in the URL is never changed for me. Thanks in advance.--68.160.242.48 (talk) 15:56, 5 December 2009 (UTC)
- There are several things which might redirect you. Your ISP may redirect bad DNS lookups to a search URL - there's not much that can be done about this (though you can override the default DNS with an alternate public service). More likely problems which might be causing this are due to your browser - I find these "fixups" very irritating. (I am often on a private network with valid URLs like http://nimur. When I type "nimur" into my URL bar, I do not want a "keyword search," I want Firefox to go to the correct server). You can disable these irritating "auto-fixup" features by disabling "search from the address bar" and other "url fixup" options in Firefox. You can also download ClumsyFingers addon, which disables several shortcuts (like "ctrl-enter" to automatically append ".net" and other DNS changes). There may be some other specific tweaks for your browser to make sure that you get a true "Server not found" error message, rather than a redirect to a different computer, when you mistype a DNS name or URL. Note the important distinction between a typo that results in a host not found, and a 404 error.Nimur (talk) 19:22, 5 December 2009 (UTC)
Assigning a string to a variable in C
[edit]With out doing it when I declare the variable, how can I assign a string to a variable?
For example:
#include <stdio.h>
#include <string.h>
#define STRSIZ 20
typedef struct inventory{
char product_cat, /* Catergory of each product */
depart_name[STRSIZ], /*Name of department*/
product_name[STRSIZ], /* Name of the product */
meat_type, /* type of meat */
plants, /* fruit or veggie */
aisle_side, /* side of asile */
nonfood_cat; /*category of nonfood item*/
int cost_item; /* Cost of item in cents */
int packaging_date, /* Date of packaging */
expiration_date, /* Date of expiration */
aisle_number;
} any_product;
int main (void)
{
struct inventory any_product;
char pad; /*absorbs stray \n from buffer */
printf("Enter product category (M,P,D,C,N,Q): ");
scanf("%c", &any_product.product_cat);
printf("%c\n", any_product.product_cat);
scanf("%c", &pad); /*absorbs stray \n from buffer */
switch (any_product.product_cat)
{
case 'm':
case 'M':
printf("Meats\n");
any_product.depart_name = "Meat department";
...
The last assignment doesn't work. How can I make it so it does? -- penubag (talk) 20:41, 5 December 2009 (UTC)
- Use strcpy, like this:
strcpy(any_product.depart_name, "Meat department");
- of course, you want to be sure the text never exceeds 19 characters in length.
- I can see several improvements that could be made, but I assume this is something in an early stage of development so I'll leave it to you to learn. Astronaut (talk) 21:03, 5 December 2009 (UTC)
- Thank you much! Please tell me what can be improved. -- penubag (talk) 21:58, 5 December 2009 (UTC)
- Here are three recommendations. First, never use scanf() unless you absolutely need to process freeform input. The fact that it does not distinguish between space and newlines for most purposes can be very confusing when you use it interactively. Instead, use fgets() to read in one line (of convenient size; allow for several hundred characters) and then use sscanf() to examine that line and see if it has the form you expect.
- Second, when you #define the maximum size of something, make it the maximum size of the string and add 1 to get the array size. So instead of
- Thank you much! Please tell me what can be improved. -- penubag (talk) 21:58, 5 December 2009 (UTC)
#define STRSIZ 20 char depart_name[STRSIZ];
- write
#define STRSIZ 19 char depart_name[STRSIZ+1];
- Then STRSIZ tells you the actual maximum size of the string, which is more self-documenting and may also be useful if you find yourself needing to do arithmetic on it.
- Third, learn the difference between declaring a struct template and typedeffing the type. Your first declaration did both at once. If you are going to refer to your struct types in the style "struct inventory", then you don't need to use typedefs. Typedef defines an alternate name for a type, which allows you to not use the keyword "struct" all the time. Personally I think that is a bad approach when working with structs, but some programmers prefer it. In this case you have (presuambly accidentally) typedeffed the name "any_product" to be a synonym for "struct inventory". This would have allowed you, when you wanted to declare the variable "any_product", to write "any_product any_product;"! In practice, most programmers who use typedefs for structs use the same name as the struct tag, so they write "typedef struct inventory inventory;" or "typedef struct inventory { (template here) } inventory", and then declare "inventory any_product;".
- Hope this helps. --Anonymous, 09:26 UTC, December 6, 2009.
- Thanks you very much. It does help! -- penubag (talk) 23:51, 7 December 2009 (UTC)
- Hope this helps. --Anonymous, 09:26 UTC, December 6, 2009.
How do I play a movie DVD in my computer?
[edit]I cannot get a movie DVD in my DVD drive to play, neither with Windows Media Player nor with VLC. What do I need to do to view the movie please? I have WinXP. 92.27.148.85 (talk) 21:18, 5 December 2009 (UTC)
- In order to play a DVD you need a DVD drive and the computer has to have the necessary software to interpret the DVD drive. Without those, VLC and Windows Media Player will not be of any use for playing a DVD. To start with the obvious, do you have a DVD player, rather than a standard CD player? Usually it tells you that it is a DVD player on the front of the drive. Falconusp t c 21:48, 5 December 2009 (UTC)
- Try reading the top bit again please - it says "in my DVD drive". 92.27.148.85 (talk) 22:48, 5 December 2009 (UTC)
- VLC contains the necessary software; it does not need an external codec to decode a DVD. -- Finlay McWalter • Talk 22:42, 5 December 2009 (UTC)
I tried trying to start it with VLC but nothing happened. 92.27.148.85 (talk) 22:48, 5 December 2009 (UTC)
- VLC has a menu option (it's in "tools" on my machine) called "messages". Open that and retry to open the disk (using VLC's Media->open_disk option). The messages screen should display whatever VLC thinks is the error. Also try to play one of the (large) .VOB files on the disk by opening it in VLC. -- Finlay McWalter • Talk 22:53, 5 December 2009 (UTC)
Thanks, did that. The message box says "main error: ES_OUT_RESET_PCR called main error: ES_OUT_RESET_PCR called libmpeg2 error: invalid picture encountered" 78.146.29.54 (talk) 23:57, 5 December 2009 (UTC)
- It thinks the DVD files are corrupt (that they don't contain proper MPEG streams). Does this happen with all DVDs? -- Finlay McWalter • Talk 23:59, 5 December 2009 (UTC)
I've tried another DVD, and this time it plays, in a manner of speaking, but the image is very very very corrupted, nearly all garbage. The message box says: "main error: ES_OUT_RESET_PCR called main error: ES_OUT_RESET_PCR called libmpeg2 error: invalid picture encountered spudec error: overflow in SPU next command sequence libmpeg2 error: invalid picture encountered libmpeg2 error: invalid picture encountered libmpeg2 error: invalid picture encountered" with the last comments repeated many times. I am in the UK where PAL is used rather than NTSC. I do not know if that makes any difference to the DVD encoding. The previous DVD was "widescreen" according to the box. The other more recent DVD that I tried gives more information on the box: PAL 16:9, DVD-5, Region 2. I suppose the 16:9 proprtion means that was wide-screen as well.
When I tried to run the DVDs with Windows Media Player I got an error message saying "Windows Media Player cannot play the DVD because a compatible DVD decoder is not installed on your computer." This lead to a webpage which said (edited): DVD Playback Options for Windows......install a compatible DVD decoder (also known as a MPEG-2 decoder) before continuing with......Playing a DVD......Playing video files that were encoded with the MPEG-2 codec (.mpeg, .mpg, and some .avi files) To purchase a compatible DVD decoder, visit Plug-ins for Windows Media Player."
Update: I've tried another DVD, this time 4:3 format. It will not play in Windows Media Player, giving the same error message as above. It does play imperfectly in VLC, with some garbage on screen, very choppy sound, and I have not figured out how to get past the opening menu. Thanks Update 2: Despite uninstalling VLC and re-installing the latest version, I still get the same problems. 89.243.153.124 (talk) 13:37, 6 December 2009 (UTC)
- You may have to clean your laser lens in the drive, it may have dirt or fluff on it. Graeme Bartlett (talk) 20:48, 6 December 2009 (UTC)
- To test this, I put a non-movie DVD and a CD into the drive, and they both read perfectly with no problems. So probably the lens is clean. 78.146.231.126 (talk) 12:33, 7 December 2009 (UTC)
- You may have to clean your laser lens in the drive, it may have dirt or fluff on it. Graeme Bartlett (talk) 20:48, 6 December 2009 (UTC)
huawei
[edit]i'm posting this questions after 7 hours of thorough googling. i received a modem from my bro that had been locked. he's in another country and i'm in Kenya and i would want to unlock it so as to use the networks available in my country. It's a Huawei E160 3g modem and here guys are charging heavily for unlocking modems yet they've downloaded the software from the net for free. Anyway anyone who knows a site i can download the unlocker preferrably for free ,i've already changed it's dashboard but i need the unlock code. The one at nextgenserver.com is givin a mscoree.dll or something error message when i run it. please assist. —Preceding unsigned comment added by 212.49.88.34 (talk) 22:29, 5 December 2009 (UTC)
- Two idle google clicks of my own make me think it's asking you to install .NET, as per [1]... 81.131.30.94 (talk) 04:52, 6 December 2009 (UTC)