rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Assuming you are running Android 2.2 or later, you should have a wireless hotspot capability on the phone. You configure it with an SSID and optional security (WEP/WPA) with passphrase. Then, up to 5 computers can use the phone as a WiFi access point. I've done that with my 3g Nexus One, and it works very well. It was like having a 2mbps DSL internet connection. Web browsing was snappy, and YouTube videos played without excessive buffering.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

When you turn the system on, hold down either the Escape or F2 key on the keyboard (don't let it up). Most BIOS will see that as a keyboard error and bring up the BIOS anyway.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You either have a virus, or your AV software is causing the system to refuse to install the driver software. First, do a full system scan (setting your scanner preferences to look at EVERYTHING, and as deep as possible into all archives), then clean up the registry (there are tools to do that), and finally disable the AV software. Then, reboot and try to install the hardware again.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you do a cold shutdown of a system with applications running that have files opened, it can scramble the hard drive. Try running the disc check utility. If it doesn't see the drive at all, then it probably scrambled the partition table / boot sector. It may be recoverable with the appropriate tools, but it may be that you will have to restore the boot sector, repartition the drive, and reformat it.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I wrote a repeatable 32-bit hash function some years ago (about 20 - when C++ compilers were still very non-standard) for use in a major manufacturing execution system. In all the years since, I have not heard that it caused any collisions. Let me dig up the code and post it here. That is to say, it probably will generate collisions, but extremely rarely. One of its features is that it generates the same hash value no matter the hardware or system architecture (little-endian, big-endian, 32-bit, or 64-bit).

Ok. Here it is:

union CharMask {
  unsigned	in[sizeof(unsigned)];
  char		ch[sizeof(unsigned)*sizeof(unsigned)];
  CharMask();
};

CharMask::CharMask()
{
  for (register unsigned i=0; i<sizeof(unsigned); i++)
    for (register unsigned j=0; j<sizeof(unsigned); j++)
      ch[sizeof(unsigned)*i+j] = j<i ? 0xff : 0;
}

/*
 * Return a case-sensitive hash value.
 */
unsigned hash(unsigned char* data)
{
// This modification is to assure inter-platform consistency of string
// hash values.  IE: str.hash() on Sparc == str.hash() on Alpha
  static CharMask chmask;
  static unsigned shift = (sizeof(unsigned) == 4) ? 2 : 1;
  register unsigned h, i, j;
  register unsigned char* c = data;
  union
    {
      unsigned char cdata[sizeof(unsigned)];
      unsigned udata;
    } pad;

  h = 0;
  // Compute starting bit pattern for h
  j = length();
  if (j > 0)
    {
      for (i = 0; i < sizeof(unsigned); i++)
	{
	  pad.cdata[i] = (unsigned char)(j % 256);
	  j /= 256;
	}
      h = pad.udata;
    }

  // Hash data in string to the initial bit pattern
  for (i = length(); i >= …
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Be careful of your math. This expression change * 1.85 + 2.50 will be interpreted as (change * 1.85) + 2.50. If you intended this change * (1.85 + 2.50) then that is NOT what you will get. So, make sure to properly bracket your math expressions, or you may not get the results you intended, and the satellite you launch may end up in the ocean instead of orbit... :-)

Also, you are not setting 'total' in your calculate() function. If you want to add the change to 'total' and return that, then this would be more appropriate, assuming the math is what you intended.

double calculate( double change )
{
   change = (change * 1.85) + 2.50;
   return total += change;
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

For something like this you would need a global map object that maps names with data, so your function could create the new object and add it with its name to the map which is the real global container of these objects. Then, create a function that allows you to do lookups by passing the name, getting the object back in return. You might want to implement this as a class, with accessor, destructor, and other such functions, so the global object would be an instance of this class.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, without seeing the calling code and called code completely, this is hard to nail down. Until then, nothing is cast in concrete...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Yes, that would result in a problem. You need to change the hdrContent argument to be a char**, and pass the address that holds the pointer. Then, you probably also need to free the old memory. So, maybe something like this is appropriate:

if (hdrContent == 0)
{
    /* Error - invalid argument */
}
else if (*hdrContent != 0)
{
    free(*hdrContent);
}

*hdrContent = (char*)calloc((strlen(command)+strlen(data)+sizeof(bool))+4, sizeoof(char));
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, without seeing what the rest of your code looks like, I can only make some uneducated guesses. One thing to look for is variable overloading. That is when you have a global variable defined somewhere, and yet somewhere else, in a header or in your source file, there is another variable of the same name. For example, if you declared/define a variable in your local translation unit, or local function, with the same name as an external global variable, the local one would take precedence and the global one would not be modified.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I thought it sounded tricky. Didn't know it was NP-hard.

You'd have to generate hash values for every possible member of the set, and since the set is effectively infinite...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Your code to clear the contents of the hdrContent variable is wrong, and won't clear the entire allocated space. This is a case where calloc() is a better option than malloc(), as it allocates and clears the memory at the same time. The calloc() function takes two arguments: the first is the number of elements, and the second is the size of each element.

So, your allocation code would be something like this:

hdrContent = (char*)calloc((strlen(command)+strlen(data)+sizeof(bool))+4, sizeof(char));

Also, make sure you have allocated enough space for a terminating null byte.

n1csaf3 commented: This fixed future bugs in my code, thank-you. +1
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can generate a unique ID with 48 hex characters or less, effectively. There is no way to generate a guaranteed non-colliding hash value mathematically. It is one of those NP-Hard problems. So, generate a GUID, and forget hash values if a collision will indeed be "fatal".

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Roshki made some good points. As for controlling your bandwidth usage, most torrent clients have the ability to limit the number of uplinks that you will provide, reducing upload overhead by some factor. The entire idea of bittorrents is to distribute the load and bandwidth needed by many downloaders trying to get the same file, so as your system downloads chunks of the file, those become available for others to get from you. Since your upload speed is usually smaller than your download speed, too many connections will cause some congestion, hence the ability of most tools to limit this. However, bear in mind that if you limit upload access too severely, your download connections will become lesser as this balancing (the more you give, the more you get) is part of the bittorrent algorithm.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What slots does your motherboard have? Usually they have 1 PCIe x16, 1 x4 (or an x16 that also supports x4), and some PCIe x1 slots, at least newer ones do. I'm not sure if you can use an x1 board in an x4 or x16 slot - probably not, but as some have slots that support both x16 and x4 cards, there are some x4 slots that also support x1 boards. My advice is to go to the motherboard manufacturer's web site and look at the board specifications.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Try 3.4.4 - it works well with 2.6.21 Debian ARM kernels.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Gnome, and I think Compiz, use the GTK+ toolkit to build GUI apps and applets. You need to read the developer's documentation, available online from the gnome foundation.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Newer + more RAM == better. Go to the nVidia web site and their specs on all their boards will help you determine which is best/better for you. In any case, a GS 7600 is likely much better than a GT6600 as it has a lot more memory. I have a 3+ year old 8800GT board, and until you get to very expensive high end boards, it is as good as any newer ones, at a lower power consumption rating.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A 64-bit machine can access much more memory and run bigger applications. Speed may be faster, or slower, depending upon a lot of factors too complex to go into here. If your system has less than 4GB of RAM, go 32-bit. If 4GB or more, go 64-bit. FWIW, most 64-bit systems can run 32-bit apps just fine, and contrary to what jingda said, they shouldn't crash, unless you are missing some 32-bit shared libraries (not uncommon, but not hard to fix). I run 32-bit apps on my 64-bit systems all the time. I had trouble with 32-bit Skype because of the missing shared library issues, and it took me an hour to figure out what they all were, and install them. Once done, Skype works perfectly on my RHEL 6 system.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What distribution+version of linux are you running? Newer systems use Pulse Audio (as well as ALSA), which should allow you to change your output hardware from speakers to the headphone port.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

1. CD/DVD drives: I've used Plextor CD/DVD drives in the past. They are good quality devices. Right now, I think my drives are NEC units. No problems in 3 years of use, and 100's of discs burned.
2. Memory: both Kingston and Crucial are quality brands. Either should be fine. Do, however, get a motherboard that supports fully buffered ECC RAM, and get the appropriate memory sticks. It is a very little bit more expensive, but you will be protected from system crashes due to memory failure, random cosmic rays flipping bits, etc. Mine has saved my bacon a number of times.
3. Video Card: Both AMD and nVidia have killer cards. I prefer nVidia because the do support Linux systems well, and because they are killer devices for number crunching.
4. TV card/tuner - there are a number of cards that Linux supports. Don't have one, so no personal advice here.
5. Sound card: the build-in sound card on my Dell laptop (D630), and Intel motherboard both work just fine.
6. Floppy drive: fergeddaboutit... These days, if you need a bootable device to run stuff like Seagate's disc diagnostics, or such, then use a USB thumb drive. That's what I do. However, if you have a bunch of old data on floppies, then an external usb-connected unit might be in order, but don't bother with an internal one.

Everything else seems pretty reasonable. All motherboards today have USB 2.0, most have gigabit ethernet, …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I did some research on the web for components that would meet my requirements. Then I had a local white-box system builder purchase the parts and assemble the system for me. I could have put it together easily enough myself (I've done so numerous times in the past), but I really didn't want to fuss with it. I could have put it all together for a little bit less than he charged, but since he could buy components cheaper than I can, it was not a whole lot more. A couple of hundred $$ on a $5000 system isn't all that much, which is about an hour of my consulting time. As I figured dealing with all the ordering, assembling, testing, and such would burn up at least a day or two of my time, it was a no-brainer.

So, my specs were as follows:

Motherboard:
1. Dual quad-core Intel Penryn E5450 (low-power) 3GHz processors.
2. Up to 32GB (or more) of ECC (error correction) RAM.
3. Dual gigabit ethernet ports on motherboard.
4. Plenty of (at least 6) USB ports.
5. 6 Sata drive ports
6. IDE/ATA interface for legacy DVD/CD drives.
7. Major manufacturer with good support policies, warranty, and fast turn-around on repairs/returns.

I looked at a number of boards from Intel and other manufactures, but I selected Intel's S5000XVN workstation/server board because Intel has the best Linux and Unix support of those I looked at. I …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I do exactly what you are trying to accomplish. I am running a custom built system with an Intel S5000XVN motherboard w/ removable system drive carrier, so I can install whatever OS I want without "dual-booting" the system drive. I just shut down, pull one drive, plug in another, boot, and voila! This mobo is dated (all of 3 1/4 years old now... bleading edge when purchased, obsolete now), but it has been dead-bang reliable. Anyway, for custom systems, get a good enclosure, big power supply (750VA or better), Intel motherboard (dual processor capable is good) WITHOUT built-in video, lots of RAM (8GB or more), and an nVidia graphics board. FWIW, Intel workstation/server motherboards also include HD audio gear that works very well. No need for add-on cruft there. Anyway, I have run just about every OS you have heard of (and then some) without problems on this unit - Windows, Linux, Solaris, BSD, QNX, Free-DOS, etc. It has dual E5450 3GHz quad-core Penryn processors, 8GB (32GB max) RAM, nVidia 8800GT video card (512MB), 4 internal sata drives for user space, 1 removable sata drive for system/boot, and an esata add-on raid card for external storage. I still have one sata/esata connection for an additional RAID if I ever need it...

Pretty much, it is the same configuration as a top-end Apple Mac Pro, but at about $3K USD less.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, it takes a small (but distinct) amount of time before your network interfaces (and other services) are up and running after they start. Adding a 20-30 second delay in the script isn't a bad idea, and if it works as you say, then I'd say that is an appropriate solution. BTW, is your workstation using DHCP to get a network address? If so, then that would explain the delay needed as it takes a bit of time for a DHCP client to obtain an address and set up the network appropriately.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Have you verified that your laptop's wifi driver is installed and working?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Non of these settings, excepting possibly vm.swappiness or the actual filters used when your rp_filter settings are enabled, should impact network performance, and I'm uncertain about the vm.swappiness setting.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What OS is running on the server? Has it been updated recently? You also may want to see if your iptables firewall services are running, and if so, what the rules are that it is using. It may be that some of the firewall rules are affecting this.

Also, have you tried this after the system boots up, from a root command line?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

SNAFU, FUBAR, toast. Enjoy your new doorstop! Actually, the Dell Dimensions have good cases, enclosures, power supplies, etc. You should be able to drop in a new mobo, but if you do that, the OEM version of Windows that was on the machine (unless you installed a new one that you bought from MS), will not work, since they check the BIOS and (possibly) CPU information to determine if you are running on the original manufacturer's equipment. If that is your situation, may I encourage you to take this opportunity to not only get a new computer, but also try out Linux? I use Linux exclusively in my consulting business and it works great for me! As someone once said, it is cheap at twice the price, and 10x more secure than Windows!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I think Dev C++ is usually for C++ not C thought I am not sure

Please correct me if I am wrong

Given that C is a subset of C++, it should work ok. I'm not familiar with it, however.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Ubuntu is good. They have what is called a Live CD and/or DVD which you can use to boot your system for recovery purposes.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There are plenty of Windows editors, plus open source development environments such as code::blocks and eclipse that you can use which have built-in code editors.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Assuming your system is running Windows of some sort? For a free one, you can get MinGW, which is a GNU compiler implementation for Windows. Look at www.mingw.org

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can download a recovery and/or live CD/DVD from the distribution web site for your version. When you boot from the CD/DVD, login as root. Then you will create a mount point (directory) for the system / directory, such as: mkdir /mnt/rootfs

Finally, you will mount the root file system, assuming it is the 3rd partition on the system drive, as: mount /dev/sda3 /mnt/rootfs - at this point you can access your shadow password file (a text file) which would be /mnt/rootfs/etc/shadow

In any case, get the recovery/live CD/DVD, get to where you can boot up and logged in as the root user. Then we can help walk you through the process in detail.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

DVI is just an interface. You really don't need to concern yourself with that. It is the video card (physical or virtual) that you need to communicate with. For VirtualBox, using VESA API's in the client would be appropriate, or normal system graphic API's, such as Qt, OpenGL, DX10, etc.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

FWIW, DLL's are "Dynamic Link Libraries". They are NOT suitable for static linkage. For Windows, you need to link *.lib files, not *.dll files... They may reside in directories other than where you find the .dll ones.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Effectively, not possible! Linux/Unix passwords are encrypted with (at the minimum) with 56-bit DES encryption, and they are one-way encrypted (no way to determine plain-text from encrypted version). My suggestion is to boot with a recovery CD/DVD/USB drive, mount your root file system, and set the user password to blank in /etc/shadow. Then boot, login (no password needed) and reset the password.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A couple of (or a few) questions:

1. What video hardware (video board) are you using?
2. What kind of display?
3. How are you trying to program the display?

Modern cards are 24-bit or 32-bit color capable. There is a standard api interface that most all modern cards support called VESA. If you aren't using a card more than, say 15 or 20 years old, then they have VESA support, which will handle 24-32bit color pallets quite nicely. NO ONE uses VGA direct framebuffer I/O any more except possibly for raw console/BIOS output.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Multisets are the same as sets, except that they can have multiple instances associated with a single key. They are templates, as you know, but the signature of multiset is not multiset<T>, but multiset<Key_Type, Value_Type, Key_Allocator = Allocator<Key_Type> >. IE, you need at least 2 template arguments when declaring multisets, as in:

multiset<double, double> my_double_mset;
multiset<int, int> my_int_mset;

So, if you wanted a multiset that is keyed on the number of instances of a string, you could do this:

multiset<unsigned, string> counts_of_strings;

Kind of silly examples, but hopefully you get the point.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I assigned the values on line 19

Yes, but your terms were reversed. You should have done this: num[g] = numb;

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Look at line 19. Do you see the problem? numb = num[g];

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What version of RHEL are you running? 4, 5, 6? In any case, the process is this.

1. Login as root
2. cd to /etc/yum.repos.d
3. Remove red hat specific .repo files.
4. Copy CentOS or Scientific Linux repo files to /etc/yum.repos.d
5. You should be done, except to install/update your packages

I ask what version you are running because I have the repos for CentOS 5 as well as SL6. I can get the repos for you for SL back to version 3, but if your RHEL system is that old, you would be well advised to update pdq.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

How exactly is this an obvious question?

Who asked you to write my program for me?

This is a specification and it must be met. The function head has a char, so I must pass a char, not a char *.

Well, atoi() and the rest do NOT take char types. They take const char* types. You can pass an array of chars, but that is just the same as a pointer.

Anyway, I have been doing this for 30+ years. Don't try to teach your grandmother how to suck eggs!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
const char* ptr = "255";
unsigned int i = (unsigned int)strtoul(ptr, 0, 10);
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There are a number of functions in the atoi() family, some of which can be used for floating point values. These functions are strtof(), strtod(), and strtold(). Don't use atoi() or atof() functions - it is better to use strtol() and strtof() type functions instead as they give you better support when parsing input. If you are running Unix/Linux systems, see the man pages. If Windows, see the MSDN library documentation, or look up online.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Windows has supported NFS, as a client at least, for a long time, since Win2000 anyway, with their SFU (Services for Unix) package - a free download from MS. NFS would be most useful when your Unix/Linux servers are not going to run Samba. If Unix/Linux is the client and Windows is the server, then I would advise using CIFS since that way there is better preservation of Windows file/directory permissions, ACLs, and such. Anyway, staying with CIFS/Samba just keeps your Windows users from needing to futz with all the *nix cruft. All they need to do is share folders as usual, or connect to a group share on the *nix system(s) like they do to another Windows box.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I'll need to look that up in my copy. May be a few days before I can respond.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What about mounting a Windows box's CDRom?

I don't bother with that, since I only run Windows these days in a virtual machine on a Linux host... :-) If Windows shares the drive, then it should work just fine.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

CIFS - Common Internet File System

This is the updated version of SMB (Server Message Block), or Samba. Linux systems use CIFS to mount Windows shares, but will use a Samba server to provide shares to Windows systems. CIFS is the protocol. Samba is the application/server code. So, yes Samba per se has been outdated by CIFS, and you can indeed directly mount Windows shares in Linux. I do it all the time. Likewise, vise versa for Windows mounting Linux shares.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

When you run into that problem, you will discover that you have 10K lines of code to fix... Be safe. Read the ANSI/ISO C++ standard. They are very clear on this point. In the company I was senior/principal engineer at for almost 20 years, we made that part of the company coding standards. We learned early on that there were cases when it was not good. We were developing major enterprise systems in C++ that had to build and run identically on many different hardware and operating system platforms, ranging from PC's with Windows to QNX real-time systems, to just about every Unix variant out there (AIX on PPC, SunOS/Solaris on Sparc, HPUX on PA-RISC and Itanium, Tru64 Unix on DEC Alpha, and SysV on NCR, plus others). This bit us once, and when I pointed out that the Standard is clear on this point, there was no argument from management to change our coding standards to be FIRM on this point. Don't assume that all compilers behave identically - they manifestly do not!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

In your example, you are calling the constructor CircularLinkedList(int), which does not initialize the head pointer. You assume that add() does that, which it should, but that is a bad practice. In any case, there are a number of issues. Whatever you do, make sure that you initialize your member variables in the initialization block, before the body of your class constructors. This will save a LOT of grief. IE, instead of this

Node(int in, char* val,Node* nextNode){
     index = in;
     value = val;
     next = nextNode;
  }
.
.
.
   CircularLinkedList(){
      head = NULL;
   }
   CircularLinkedList(int capacity){
      size = capacity;
      for (int i = 0; i < capacity; i++)
         add(i,NULL); //add new node value of char* NULL      
   }

do this

Node(int in, char* val,Node* nextNode)
  : index(in), value(val), next(nextNode)
  {
  }
.
.
.
   CircularLinkedList() : head(0) {}
   CircularLinkedList(int capacity) : head(0)
   {
      size = capacity;
      for (int i = 0; i < capacity; i++)
         add(i,NULL); //add new node value of char* NULL      
   }

Also, DO NOT USE 'NULL' for generic null pointers in C++. Use the value 0 instead. Why you ask? Because NULL is defined as ((void*)0), and that cast may be a problem in some cases. You are ALWAYS safe to assign 0 to a pointer for a null value. Says so right in the ANSI C++ standard... :-)