Internet Thoughts and My Life

All about Internet Business and My Life

Sunday, December 09, 2007

New place

I have started a new blog at home.

See you there.

Wednesday, May 10, 2006

errno exception

Simple, but useful c++ exception class in errno-supporting environment:


#include <errno.h>
#include <strings.h>

#include <iostream>
#include <fstream>
#include <stdexcept>

class errno_exception : public std::exception
{
std::string msg;

public:
explicit errno_exception(const std::string& arg) : msg(arg)
{
msg += ": ";
msg += strerror(errno);
}

virtual const char* what() const throw()
{
return msg.c_str();
}

virtual ~errno_exception() throw() {}

};


int main()
{
try
{
std::ifstream ifs("test.data");
if(!ifs) throw errno_exception("ifstream");
std::string word;
ifs >> word;
std::cout << word << std::endl;
return 0;
}
catch(const errno_exception& e)
{
std::cerr << "EE: " << e.what() << std::endl;
}
catch(const std::exception& e)
{
std::cerr << "E: " << typeid(e).name() << ": " << e.what() << std::endl;
}
catch(...)
{
std::cerr << "unknown exception" << std::endl;
}
}

Tuesday, April 18, 2006

Google DaVinci Code Quest

Looks like, Google decided to try itself in a role of games maker: today they announced The DaVinci Code Quest.

First step in the brand new direction? ;-)

Wednesday, March 08, 2006

Web Accelerator

Oh shit... Just a few seconds ago i found, that Google has started its own web accelerator.

The fun here is that for a long time internet accelerator and web accelerator were common lure for muggles in the Net. Almost any adware or spyware here was promoted as internet accelerator at least once.

Thursday, March 02, 2006

Date & Time formats

More on time formats:

%z (zone) parameter of strftime(3) generates string in rfc822 (and new rfc2822) format:

The zone specifies the offset from Coordinated Universal Time (UTC, formerly referred to as "Greenwich Mean Time") that the date and time-of-day represent. The "+" or "-" indicates whether the time-of-day is ahead of (i.e., east of) or behind (i.e., west of) Universal Time. The first two digits indicate the number of hours difference from Universal Time, and the last two digits indicate the number of minutes difference from Universal Time. (Hence, +hhmm means +(hh * 60 + mm) minutes, and -hhmm means -(hh * 60 + mm) minutes). The form "+0000" SHOULD be used to indicate a time zone at Universal Time.
The problem I met is that here is another standard that specifies format of zone string: ISO 8601. It requires zone string to be almost the same but with delimiter between hours and minutes. Something like +02:30.

Now it looks like we need to add another one formatter for strftime(3) :-)

Wednesday, March 01, 2006

Datetime minitrouble

Yesterday I had the problem with my RSS generator: w3.org feed validator told, that my generated feeds are not valid because of timestamps format. Generated timestamp was something like this: Wed, 01 Mar 2006 11:03:40 UTC. I spent few hours to reading all mans around, but nothing. Key idea was to read rfc822 :-)


After reading this I found that abbreviation UTC does not conform to rfc822. Valid abbreviations are GMT and UT. Also, instead of abbreviations it's possible to use 4-digits form like +0200.

PS: ... just well known strftime(3) format string to generate correct rfc822-conforming datetime: "%a, %d %b %Y %H:%M:%S %z"

PPS: rfc822 is obsoleted by rfc2822.

Monday, February 27, 2006

Hi.

This blog has changed a master. Now it's me. Some posts of previous author can be found here.

I hope, you'll enjoy my posts too :-)