rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

We don't do your homework for you. Make an honest effort and post your code here when you hit a brick wall.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is why you need to read my tutorial about using PHP properly as an object-oriented language. Don't do this stuff inline. Build your data strings dynamically in a class method or a function first, then output it.

https://www.daniweb.com/web-development/php/tutorials/484310/why-you-dont-want-to-mix-php-and-html-directly

mattster commented: Too true..... +4
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
  1. The loop for(i=0;i<=4;i++) should be for(i=0;i<4;i++)
  2. You should set a 'largest' variable as found and then output that after the loop has terminated. Following is how to do that.
  3. You also have a bunch of other issues that should make your compiler throw up...

    #include<iostream.h>
    int main(void)
    {
        int arr[4]={23,38, 81,12};
        int biggest = 0;
        for(i=0; i < 4; i++)
        {
            if(arr[i]>biggest)
            {
                biggest = arr[i];
            }
        }
        cout << "largest integer is" << dec << biggest << endl;
    }
    
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I'm not familiar with this tool, but since it is generating binary executables my experience shows that when it works in debug mode but not production mode (segfaults, etc), it is due to the fact that debug mode pads arrays and such with extra memory. As a result, you might consider buffer overflows as a cause of this problem. IE, you need to analyze your code to see if you need buffer and array sizes to accomodate string terminator (null bytes) and similar.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There are a number of methods to do this. There are native MySQL API's for C, ODBC, etc. Go to the MySQL web site for all the information you need: http://dev.mysql.com/

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I appreciate any and all comments that help expand upon what I wrote for this tutorial. Writing good web code is not simple or straightforward, and many sites are vulnerable to hacking and malware infections because proper diligence is not applied to the code. Hopefully this thread will help steer web developers in the right direction.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

PHP is an object-oriented language, based (loosly) upon C++. It has classes, methods, member variables, and all that other good stuff. It runs on your web server, not in the client, but the HTML, JavaScript, and other stuff such as CSS blocks that it emits with its output commands are run on the client.

The purpose of this tutorial is to explain why you don't want to mix your PHP and HTML, JavaScript, etc. One reason is if you do that, it becomes pretty much impossible to debug. Another is that is it inefficient.

  1. Use classes and methods to build up your output HTML strings from the logic, passed $_GET, $_POST, and other global variables, and ONLY output them once they are completely formed.
  2. This allows you to recursively call (include) the same PHP code from forms that are created and output, providing you the capability to get some really complex stuff working that would be impossible otherwise.
  3. You can better validate passed variables, SQL query predicates, etc.
  4. If needed, you can emit debug data when inside your class member functions that would not be visible if you tried to do that when inside a JavaScript block of code.

So, don't mix PHP and HTML, etc. Build your output strings inside your PHP class functions and only output them once you have finished.

Example (mostly pseudo code):

<?php
    class MyClass {
    public
        $output = '';
        $debug = false;
        function __construct() {}
        function __destruct() {}
        function display()
        {
            echo "$output"; …
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

OCR in 50 words or less.

  1. Scan input
  2. Extract each item (character) from the input
  3. Apply pattern matching algorithm to each item
  4. Generate output
  5. Validate output

Have fun...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Some compilers will bitch at you if you try to assign a string literal to a char* (often depending upon how you set the strictness level of type-checking for the compiler). You SHOULD use a const char* instead in such cases. The first case is a clear violation of intentional programming - do what you intend. If you INTEND for the string to be mutable, then use the char var[] = "a string" construct. You can use var as a char or const char pointer as necessary without needing to any casting.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Myself, I like Wirth's "Algorithms + Data Structures = Programs". It's a bit dated, but it was the seminal treatise on the subject.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Sorry. We don't do your homework for you. Create a program to solve this problem (it is a trivial one) and when you have issues with it, then post your code here for help.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

steamcmd seems to want to write state data to /home/gmod and I assume that you are running steamcmd from your account. So, you probably need to be sure that you have the appropriate rwx permissions on /home/gmod. Also, since you are downloading/installing gmod at the same time, it is likely (possible) that the gmod installation has altered the permissions on /home/gmod, causing this problem.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There is a lot of noise about systemd's faults all over the net. I've been in a discussion on the LinkedIn Linux Experts group about this very topic. Honestly, in many regards it is a hacked design for such a system-critical component (no formal methodology, modeling, verification, etc.) and many of us are of the opinion this is going to become a serious problem instead of the solution it purports to be. If I were Linus, I would be butting heads also!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As I recall, these are the names of the various releases of Eclipse. Get the latest stable release and you should be ok. I think they are in alphabetical order, so Luna should be the latest.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Ivzirnalsradeys, you keep asking us to do your homework for you. If we do that, then what do you learn? Make a proper effort to solve the problems, show what you have done, describe the errors you are getting, and THEN we may decide to help you sort this stuff out. Until then, you are on your own!

Ivzirnalsradeys commented: i understand and sory +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As for the validation of February dates, this is a simple leap year calculation (easily found in Wikipedia):

boolean isleap(year)
{
    boolean leapyear = false;
    if (year is not divisible by 4) then (it is a common year)
    else
    if (year is not divisible by 100) then (it is a leap year)
    else
    if (year is not divisible by 400) then (it is a common year)
    else (it is a leap year)
    return leapyear;
}

This is a better algorithm than yours as it is generic and applicable to any year. Then, you just need to decide:

if (month == February)
{
    if ((isleap(year) and day <= 29) or (day <= 28)) then
    {
        date is ok
    }
    else
    {
        date is bogus
    }
}

Do note that this is pseudo-code, but easily translatable into either C or C++.

Ivzirnalsradeys commented: thanks +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You need to push all of your site data into a tarball, install the required software in the new hosting site, move the tarball to the new site, extract the data, and start testing.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Leave off the trailing '/'. IE: ls -l python*
Assuming that the directory is not a soft-link, then you will see the contents of the directory (or directories).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What Hiroshe said. Also, file name extensions are conventions - they really don't mean anything. You can rename any file with a .zip extension, but that doesn't mean that it is a compressed zip file.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can't "fix" bad disc sectors. Most modern drives have the ability to map bad sectors to spare sectors, but once a disc starts to go bad, those get used up quickly and when you get an error like this all you can do is to backup all the data you can, realizing some cannot be recovered.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Antenna design is a dark art. I studied software genetic engineering with a very bright US Air Force captain at MIT who was using genetic algorithms to help design phased array radar antennas. He ended up with some very strange designs that out-performed anything that mere humans had come up with to that point...

All of that aside, I personally prefer WiFi devices with high gain external antennas. I replaced the external antennas on my Linksys router/access point with high gain antennas and found it just about doubled the range of the device. Before that, I used a range extender, which worked ok inside the house. Now, I don't use the extender any longer.

FWIW, house construction materials will significantly impact the range of WiFi devices. My house has aluminum siding, which makes it a poor man's Faraday cage, blocking most radio signals from getting out, but also from getting inside. IE, I can't get reliable cell phone coverage inside the house, so if I want to check my voice mail or make a cell phone call, I have to go out on the porch!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The 4096 cores is a limitation built into the kernel. If you want to modify the kernel, you could increase that. There are Linux supercomputers that have lifted that limit considerably - not a task for the noobie kernel hacker... :-)

As for the 128TB RAM limit, that is probably due to the fact that the x86 architecture is still a segmented one. Each segment has 48 bits, and 16 bits (of the 64-bit register size) is reserved for the segment. You can use 64K x 128TB of RAM, but you would have to implement the segmentation code in the kernel yourself. Having done this in the deep dark past of i286 processors, I can testify that it is a real PITA.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

First, you are confused... :-)

The ostream& operator<<(ostream& output, classname& cn) returns a reference to the output object, allowing multiple outputs to the same stream in one expression such as cout << "foo" << "bar" << " " << dec << 1001 << endl;, which would display "foobar 1001". Your example of foo&() {...} is invalid on the face of it. Your compiler should give you an error about that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, your addrec() method has no code, so it won't do anything...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You shouldn't lose the data unless you drop/cancel the account. Just disconnecting from it should not do that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

An 8 bit value, such as a char, can be signed, or unsigned. So let's look at chars - you can have a signed or unsigned char. The top-most bit for a signed char is the sign. If set, the value is negative. If not, it is positive. In this case, we have only 7 bits for the actual value (plus the sign bit which == -1).
00000001 == 1
00000010 == 2
00000100 == 4
00001000 == 8
00010000 == 16
00100000 == 32
01000000 == 64

Add them up (1+2+4+8+16+32+64) and you get 127.
if you have 10000000, then you have -1. If all the other bits are set, add them up (negatively) and you get -128.

On the other hand, if the char is unsigned, then 10000000 == 128, so if all bits are set, you get 255. This rule applies to larger integers such as 16, 32, and 64 bit values as well.

Are we sufficiently confused yet? :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is the purpose of the ODBC libraries - they provide a database-neutral means of accessing most any database without changing your code. Before ODBC existed, I wrote an ODBC-like API for manufacturing systems, and a set of loadable shared libraries for each supported database (Oracle, Sybase, Informix, Ingres, and Interbase) that accomplished the same thing. Trust me, you don't want to reinvent that wheel! But, it worked great, and is still in use in a number of major manufacturing cell control systems 25 years later.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Here is a good tutorial on the subject of random number generators: http://www.phy.ornl.gov/csep/CSEP/RN/RN.html The math requirements aren't too onerous, and translation from the Fortran90 examples to C or C++ shouldn't be too difficult. My wife is a particle physicist and Monte Carlo routines and RNG's are her life blood. Most such physicists have migrated from Fortran to C++ some time ago, especially utilizing libraries such as Boost for higher-level maths, unlimited precision arithmetic, etc.

Two great quotes:

Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin. -- John von Neumann (1951) 
Anyone who has not seen the above quotation in at least 100 places is probably not very old. -- D. V. Pryor (1993) 
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A 1.6 GHz Atom processor running a 32-bit OS is not going to get much better, performance-wise. It is probably already doing its best.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

In the future, if you want to run Debian on a Window system then download and install VirtualBox. You can then install Debian or other Linux distributions in a virtual machine, avoiding the problems you incurred, and the wrath of your IT department. That's what I did at my last job since I had to do most of my development work on Linux, yet the company laptop had a security hardened Windows 7 installation with all the company cruft on it.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There a built-in open source nVidia driver for Linux called Nouveau. nVidia also has proprietary Linux drivers for their gear which work very, very well. The proprietary drivers are much more efficient than the Nouveau driver. I run Nouveau on my laptop which has an nVidia GPU, and the proprietary driver on my workstation which has an 8800GT video card. I use the proprietary driver on that system because I run multiple HD displays and do quite a bit of video processing so it needs the best drivers available, which happen to be the nVidia proprietary ones.

FWIW, nVidia also has Linux SDKs for using the graphics cores for serious parallel number crunching.

Also, since nVidia is working with the Nouveau team at providing better support for their cards in the open source universe, Linus has withdrawn his extended middle finger from pointing at nVidia... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What Schol-R-LEA said. For a cross-platform GUI development tool set, use either Qt, or Wx - Qt is preferred. That said, they are C++, not C API's. AFAIK, there are no standard GUI tools that are strictly C based, other than text-based ones such as curses/ncurses.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Get a degree in computer science. Learn multiple programming languages. Become competent in graphics development. BTW, Newtonian physics is also helpful for game development.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you are considering switching into more current web-based programming, then get up-to-speed on PHP and LAMP. PHP is really a web server based version of C++. If you are going to use it properly, you need to understand well the foundations of OOP (object-oriented programming). A lot of currently written PHP code is an abomination and subject to major sercurity issues. Well-written PHP code is clean, debuggable, and secure. Unfortunately, there are more web sites out there with the former kind of PHP coding... :-(

I had to re-write a tool at my former employer (Nokia) that was written in the former (abominable) style - a mish-mosh of intewoven PHP, HTML, and JavaScript code with some complex CSS thrown in for formatting. You could not debug it. I took the good parts and embedded them into real PHP classes and methods. The result ran faster, could be debugged, and was a LOT easier to modify (which I had to do to meet new requirements).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

These days, a 4 CPU system will have from 8 (more likely 16) cores, to as many as 32. More cores == slower clock speeds. You can overclock 4 core high-end Intel CPU's to about 5GHz, and possibly more with agressive liquid cooling.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Then try a new battery or take it in for repair. How old is it?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Are you plugging into a wall charger, or is it plugged into a computer USB port? As JorgeM suggested, try an alternate charger. So, if you don't have another wall charger, try a USB connection to a live computer. If it still doesn't get beyond 10%, then it is most likely a bad battery, or a bad charging circuit in the phone.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
class Address // Assumes address is in USA
{
private:
    std::string street;
    std::string city;
    std::string state;
    std::string zipcode;
public:
    const std::string& getStreet() const;
    const std::string& getCity() const;
    const std::string& getState() const;
    const std::string& getZipCode() const;
};

class Map
{
.
.
.
public:
    void showLocation( const Address& addr ) const;
    // Alternative implementation:
    void showLocation( const std::string& street,
                       const std::string& city,
                       const std::string& state,
                       const std::string& zipcode ) const;
};

So, the class Map can use the getter methods in Address::showLocation( const Address& ) const to determine where the location is, and then display that. Note that this is a VERY rudementary example, but the point is that passing objects instead of lower-level scalar data can be useful, more terse, and less error prone.

ddanbe commented: Great answer! +15
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

It depends upon the drive. Some manufacturers' drives run hotter than others. On my system, my 2TB WD green drives run about 10C cooler than my 320GB Seagate system drive. They are all healthy, at least according to the SMART interface data that I monitor. That said, I have had Seagate 500GB-2TB drives that ran too hot and failed sooner than they should have. Fortunately, most were under warranty, so I only had to pay for shipping in a couple of cases. The replacements are still running hot, so I have decided to use 7200rpm WD drives for now. They have been much more reliable, have fewer bad sectors, and don't overheat.

As for noises when you copy files, that is probably the head positioning drivers. They do make noise to some extent - which is why I usually stream some music when I am running my system (like right now)... :-)

FWIW, Hitachi has a good reputation, and as a disclaimer, I used to consult with Seagate. I still prefer Western Digital drives.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I assume you are using a dual-boot capability from your post. What video hardware does your system have? You need the appropriate drivers. By default, Ubuntu will not install proprietary video drivers, but there is a System (possibly in Preferences) entry that will provide the ability to install the appropriate drivers for your video, giving you full resolution capabilities. If your Linux distribution cannot handle your specific hardware, then it will revert to the VESA api's that most all hardware supports, but that has limited resolution as you have seen. VGA drivers? Those would be limited to 800x600 which you already have. VESA would provide higher resolution, but not suitable for video streams.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Glad to help. Remember, the voltage is key. Amps is the current it can provide, so you want at least as much as the device can draw, otherwise, the power factor staying equal, it will drop the voltage and can damage the device. Basic electricity - high school physics stuff. Here is the wikipedia article on Ohm's Law: http://en.wikipedia.org/wiki/Ohm%27s_law

cambalinho commented: thanks for all +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
Wh == Watt Hours
Watts == volts * amps
Ah == Amp Hours
Watt Hours == Amp Hours * volts

So, 1200mAh == 1.2Ah which  * 3.7V == 4.44Wh
    950mAh == .95Ah which * 3.7V == 3.51Wh

This is just about what the specs say. They are just rounding down to the nearest decimal place.

So, no. It will not damage your gear. The key is the volts provided. The Amp Hours / Watt Hours is the capacity of the battery. Since they provide the same voltage, the 1200mAh battery will, as seen, provide more capacity to run without charging.

cambalinho commented: thanks for all +3
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please be specific about your needs and situation. I can give good advice (occasionally), but I first need to know what your needs are in order to make that advice suitable for your situation.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you need real security to deal with banking and such, then create/use a bootable liveDVD Linux OS (see Unetbootin). It won't allow any persistent viruses to be stored on the device (the device will be read-only, but temporary data will be stored to RAM disc, which evaporates when you shut down the system). I do this when I have to use an untrusted system.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Have you tried Microsoft's Security Essentials? It is free, and does a decent job at cleaning such issues. Also, there is the FOSS (Free and Open Source) tool ClamAV. FWIW, I never use just one cleaner in these cases.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, I have to disagree with Mike2K with regard to UML, but that depends upon the tools you use. I employ Sparx Enterprise Architect for my design needs, and then use it to generate source code. If I have to work with existing code, then I used its reverse engineering capabilities to capture the code design into UML diagrams. I have designed major software systems in use for many enterprise systems since the early to mid 1990's using UML or earlier OOP tools (I was there when Booch, et al announced UML 1.0 at OOPSLA in San Jose). Modern tools such as Enterprise Architect, Rose, Tau G2 (Rose and G2 are currently owned by IBM), and such are often capable of forward and reverse engineering from model to code to model. So, there is no doubling of effort, provided you use appropriate tools.

Many of the complex systems I have designed and implemented since the early 1990's would have not been possible without the use of modern design tools (UML, Booch diagrams, CRC cards, etc). The complexity is very much clarified with such tools, allowing one to understand the relationships between classes that would be daunting if you only have source to analyze.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Linus Torvalds uses one, but keeps it at 1 mph, otherwise it interfers with his typing and train of thought. Myself, if I want to take a walk, I take a walk... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, this is wrong:

 else if (signedNum[0] == (str[0] || str[1]) &&
signedNum[1] == isdigit(signedNum[1]))

You should use

 else if (signedNum[0] == (str[0] || str[1]) && isdigit(signedNum[1]))
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Also, there are some sub-classes such as the reference counter classes that stuff is derived from, which you will need to remove since that is used by the reference-counting garbage collector which I am not releasing at this time - it is a field I am still doing active research on. It allows programs to use appropriate "smart pointers" to run for years at a time with no deletes. We had 10 million lines of code written with this tech that I invented that had zero deletes, and no memory leaks, that our customers (Samsung, Philips, Intel, Seagate, et al) used for their factories which they would only shut down 1 day a year for preventative maintenance. If the software failed for ANY reason, the costs to them was in excess of $10 million in profits per hour of downtime. Let's just say they would not be happy if that happened!

Vasthor commented: well, that's cool! +2