April 25th, 2009
I wanted an example of a class containing a struct and how you reference it.
Here is a complete c++ program.
#include <iostream> // Required if your program does any I/O
struct stick
{
int length;
int thickness;
};
class hand
{
public:
hand(); // constructor
stick poolCue;
};
hand::hand()
{
std::cout << “\nGreetings from the constructor!\n”;
}
int main()
{
hand my; // new hand called my
my.poolCue.length = 8;
system(”pause”);
return 0;
}
Posted in Uncategorized | No Comments »
April 24th, 2009
I got this error today. Here was my code.
ifstream inData;
while (!inData.eof())
{
cout << “doing something…” << endl;
cout << info;
inData.get(info);
}
inData.close();ifstream inData;
It was the inData.get that was blowing it up.
Not because that line was bad, but because info was the wrong variable type.
It was declared as an a char array
char info[256]
when it needed to be a plain ol
char info
So there.
Posted in c++ | No Comments »
April 22nd, 2009
I spent a while yesterday searching for a way to do a friendly name on an email sent by sendmail.
I had a line like this:
/usr/sbin/sendmail -bm -f mike_doughty@demo.com recipientguy@grapplinghook.org < $message
What I was hoping for was something like this:
/usr/sbin/sendmail -bm -f "Mr. Excitement" <mike_doughty@demo.com> recipientguy@grapplinghook.org < $message
I tried every permutation I could think of of the above, and nothing worked.
And Google was playing coy with me. Oh, that Google!
As near as I can figure, the line above is only the envelope information which is not actually transmitted to your email recipient.
Here’s how I ended up doing it:
$msg = "To: Mr. Excitement <mike_doughty@demo.com>\n";
$msg .= "From: recipientguy@grapplinghook.org\n";
$msg .= "Subject: Success at last\n";
/usr/sbin/sendmail -bm -f "Mr. Excitement" <mike_doughty@demo.com> recipientguy@grapplinghook.org < $message
So there is a simple sendmail example for you. Enjoy.
Posted in linux, php | No Comments »
March 30th, 2009
If you need to change unix group in the context of a session, you can use the newgrp command.
Just a little factoid that couldn’t be found in easily in Google. Until now.
Posted in Uncategorized | No Comments »
March 12th, 2009
Man it was hard to find curl sftp examples, sftp command line syntax for curl, or sftp push examples on the web.
So here is one that shows an sftp push to a target directory:
curl -T newfile.txt -u root:mysecretpassword sftp://192.168.30.24/targetdir/
you can also do that as
curl –upload-file newfile.txt -u -u root:mysecretpassword sftp://192.168.30.24/targetdir/
Did you see the way the slash trails off the end, like the spoiler on a fine Italian sportscar? Remember that, it won’t work without it. You’ll get a “curl: (9) Upload failed: Permission denied” error.
Posted in Uncategorized | No Comments »
March 12th, 2009
SFTP error:
Couldn’t get handle: Permission denied
*** sorry: 50 Put cmd fails
Meaning: trying to ‘put’ the file into a directory that doesn’t exist.
Posted in linux | Comments Off
January 27th, 2009
Synergy is a great software app that lets you use a single mouse and keyboard with several computers. I have a linux box and a windows box side by side with two monitors, and my mouse pointer can move seamlessly from the windows screen to the linux screen, and the keyboard switches over automatically when that happens.
But once in a while my synergy client (i.e. the one that does not have the keyboard and mouse plugged into it) has a problem, which requires a bit of configuration. Only a second, really. Except that due to the nature of the problem, I have no keyboard or mouse available! Well, that’s not exactly true, I keep a mouse plugged into it all the time for just such an emergency, but a second keyboard takes up too many desk-acres, and I got tired of switching USB plugs around.
So what I sought was a virtual keyboard - a keyboard on the screen that I can click on with the mouse. Google turned up a bunch of weird results, including some pay-for products.
But little did I realize that there is a free virtual keyboard program built into windows!
Just go to Start; All Programs; Accessories; Accessibility; On-Screen Keyboard. Perfect, free and already installed.
Posted in apps | Comments Off
January 15th, 2009
To fix the error message
URL file-access is disabled in the server configuration
edit your /etc/php.ini.
There are two parameters to look at: allow_url_fopen and allow_url_include.
Make sure those are both set to ‘On’.
Then do a service httpd restart.
That fixed me.
Posted in linux | Comments Off
January 13th, 2009
After installing apache and php on Linux, everything appeared to be working.
Php files did their proper php thing, html was interpreted correctly, and all seemed right with the world.
Then I tried embedding some php in a file ending in .html and it didn’t work.
For example:
<html>
<H1>Free Beer at my place</H1>
<? php
echo “Wait, how about your place instead?”;
?>
</html>
On my Linux box I had to edit /etc/httpd/conf/httpd.conf (you backed that file up first, didn’t you?) to include:
AddType application/x-httpd-php .php .htm .html
Then after a service httpd restart, my embedded php was then able to execute.
Posted in php | Comments Off
January 8th, 2009
Everyplace I google for finding php version mentions the phpinfo function. But is there a way to find your php version besides phpinfo?
Phpinfo seems to require you to be running a webserver, and in this case I’m not.
I was able to see my version by executing ‘php version’ at the command line.
Also, ‘php -i’ gives much info, though it outputs it in html format.
Posted in php | Comments Off