It’s called bar. It seems to be a nifty little script that does what you would normally do with simple invocations of cat, tar, and cp, but it prints a progress bar.
Like this:

It’s called bar. It seems to be a nifty little script that does what you would normally do with simple invocations of cat, tar, and cp, but it prints a progress bar.
Like this:

I’m sure I’ve blogged about this before. I just don’t know where.
It drives me nuts. In what other languages, other than C and C++, is it acceptable to totally ignore the style that the standard uses? In Java, the “standard” is the Java API written by Sun. Everyone, and I mean everyone who writes Java uses that style or they are a laughingstock.
The same goes for lisp. The same goes for PHP. The list could go on and on.
But C++? Well, what the hey! Microsoft writes its code a certain way, so that must be an acceptable style, no? Arrrgggghh. The style used by K&R, Stroustrup, and the standards committee is nothing like what Microsoft (and consequently, thousands of programmers) use on a regular basis, and it drives me batty.
In C, names should be brief and descriptive, generally one word or multiple, abbrieviated words. Everything should be lower cased, except for preprocessor macros, which should generally be capitalized.
In C++, names should generally be more descriptive, and words should be separated by an underscore character (i.e., ‘special_vector’ or ‘address_table’). This includes classes, which people sometimes use the Microsoft style, which is *wrong*. Of course, style is arbitrary and not actually defined in the standard – but convention in most languages is generally to do things like the standard library does it, and Microsoft does not do it like the standard library does it. The same rules apply to preprocessor macros.
If I never see a class with camel-case styling again it’ll be too soon.
I have scoured the net for FLTK 2.0.x binaries, and there aren’t any.
Until now. I have compiled the static libraries for FLTK and have created a Windows installer (it will get listed in the “add/remove software” dialog).
Come and get it: FltkSetup.msi.
I have written a threaded timer that will start on command, and stop on command using the boost threads library. here’s the code:
/* copyright Benjamin Collins 2006
* please contact for licensing information */
#include
#include
#include
#include
#include
#include
typedef boost::recursive_mutex::scoped_lock rt_slock;
namespace
{
bool _start = false;
boost::recursive_mutex start_mutex;
boost::condition start_condition;
bool started()
{
return _start;
}
void start()
{
rt_slock lk(start_mutex);
_start = true;
}
void stop()
{
rt_slock lk(start_mutex);
_start = false;
}
}
class timer_func
{
public:
timer_func()
{
boost::xtime_get(&_time, boost::TIME_UTC);
}
void operator()()
{
while(true)
{
{
rt_slock lk(start_mutex);
start_condition.wait(lk);
}
while(started())
{
_time.sec += 1;
boost::thread::sleep(_time);
if(started())
std::cout << "." << std::flush;
}
}
}
private:
boost::xtime _time;
};
int main()
{
timer_func timer;
boost::thread t(timer);
while(true)
{
if(!started())
{
std::cout << "press enter to start: " << std::flush;
std::cin.get();
start();
std::cout << "starting" << std::endl;
start_condition.notify_one();
}
else
{
std::cout << "press enter to stop: " << std::flush;
std::cin.get();
stop();
std::cout << "stopping" << std::endl;
}
}
return 0;
}