Taking advantage of named pipes

Posted in Linux/Unix on February 10, 2009 by jweyrich

According to Wikipedia, the definition of a Pipe or Pipeline is:

In Unix-like computer operating systems, a pipeline is the original software pipeline: a set of processes chained by their standard streams, so that the output of each process (stdout) feeds directly as input (stdin) of the next one. Each connection is implemented by an anonymous pipe. Filter programs are often used in this configuration. The concept was invented by Douglas McIlroy for Unix shells and it was named by analogy to a physical pipeline.

  1. Creating a named pipe:
  2. mknod example.pipe p
  3. Running a background process which reads from the pipe, and writes to a zip file:
  4. gzip < example.pipe > oracle-scott.exp.gz &
  5. Feeding the pipe with data (here we’re exporting an Oracle schema):
  6. exp userid=scott/tiger file=example.pipe

Just for curiosity, Scott was one of the first employees at Oracle, and Tiger was the name of his cat.

Firefox extensions

Posted in Web on February 10, 2009 by jweyrich

Bellow follows the list of my preferred Firefox add-ons, wishing they shall be useful to you:

ColorZilla
Cooliris
Firebug
FireGPG
FireFTP
NoScript
Pencil
Poster
RExT
Selenium IDE
Stylish
Web Developer
YSlow

I’ll update this post later to describe one-by-one the features I appreciate.

Change your concept of job if you can

Posted in Hobby on October 5, 2008 by jweyrich

What do I do? I do what I really love. It’s my leisure. And I know few people that could say the same.

Also, as in any workplace, I have to do something I don’t like so much, and that’s exactly what I consider a job.

Do I get paid? Yes, but I consider my hobby as being sponsored, and for the worst part, I receive my salary.

Frequently I face big rocks on the way, and most of them can be considered part of my hobby because it’s just a matter of finding an alternative path, or choose the correct tools to climb it.

My satisfaction is a direct relation between how much time I practice the hobby, and execute the job. Being the first greater, you’ll very often see me smiling.

And if successful people do what they love, I’m one step ahead in my walk to the success.

Checking the OS with C macros

Posted in C/C++, Programming on October 4, 2008 by jweyrich
/*
 *	Author: Jardel Weyrich (jweyrich [at] gmail [dot] com)
 */

#define SYS_BASE		0x10
#define SYS_MAC		SYS_BASE+1
#define SYS_LINUX		SYS_BASE+2
#define SYS_FREEBSD		SYS_BASE+3
#define SYS_NETBSD		SYS_BASE+4
#define SYS_OPENBSD		SYS_BASE+5
#define SYS_MINT		SYS_BASE+6
#define SYS_BSD_BASED		SYS_BASE+7
#define SYS_SOLARIS		SYS_BASE+8
#define SYS_HPUX		SYS_BASE+9
#define SYS_RISC_OS		SYS_BASE+10
#define SYS_OS2		SYS_BASE+11
#define SYS_IRIX		SYS_BASE+12
#define SYS_AIX		SYS_BASE+13
#define SYS_BEOS		SYS_BASE+14
#define SYS_CYGWIN		SYS_BASE+15
#define SYS_OPENVMS		SYS_BASE+16
#define SYS_OSF		SYS_BASE+17
#define SYS_QNXNTO		SYS_BASE+18
#define SYS_WINDOWS		SYS_BASE+19
#define SYS_DREAMCAST		SYS_BASE+20

#if defined(__APPLE__) || defined(MAC_OS_CLASSIC) \
	|| defined(MAC_OS_X) || defined(macintosh)
#	define SYSTEM		SYS_MAC
#elif defined(linux) || defined(__linux) || defined(__linux__)
#	define SYSTEM		SYS_LINUX
#elif defined(__FreeBSD__) || defined(__DragonFly__)
#	define SYSTEM		SYS_FREEBSD
#elif defined(__NetBSD__)
#	define SYSTEM		SYS_NETBSD
#elif defined(__OpenBSD__)
#	define SYSTEM		SYS_OPENBSD
#elif defined(__MINT__)
#	define SYSTEM		SYS_MINT
#elif defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
#	define SYSTEM		SYS_BSD_BASED
#elif defined(sun) || defined(__SVR4)
#	define SYSTEM		SYS_SOLARIS
#elif defined(hpux) || defined(__hpux) || defined(__hpux__)
#	define SYSTEM		SYS_HPUX
#elif defined(riscos) || defined(__riscos) || defined(__riscos__)
#	define SYSTEM		SYS_RISC_OS
#elif defined(__OS2__) || defined(__EMX__)
#	define SYSTEM		SYS_OS2
#elif defined(osf) || defined(__osf) \
	|| defined(__osf__) || defined(_OSF_SOURCE)
#	define SYSTEM_		SYS_OSF
#elif defined(sgi) || defined(__sgi) \
	|| defined(__sgi__) || defined(_SGI_SOURCE)
#	define SYSTEM		SYS_IRIX
#elif defined(_AIX)
#	define SYSTEM		SYS_AIX
#elif defined(__BEOS__)
#	define SYSTEM		SYS_BEOS
#elif defined(__CYGWIN__)
#	define SYSTEM		SYS_CYGWIN
#elif defined(__VMS)
#	define SYSTEM		SYS_OPENVMS
#elif defined(__osf__)
#	define SYSTEM		SYS_OSF
#elif defined(__QNXNTO__)
#	define SYSTEM		SYS_QNXNTO
#elif defined(_arch_dreamcast)
#	define SYSTEM		SYS_DREAMCAST
#elif defined(WINDOWS) || defined(WIN32) || defined(_WIN32)
#	define SYSTEM		SYS_WINDOWS
#endif

C++ smart enum

Posted in C/C++, Programming on October 4, 2008 by jweyrich
/*
 *	Author: Jardel Weyrich (jweyrich [at] gmail [dot] com)
 */

#define DECLARE_SMART_ENUM(_TYPE) \
	inline _TYPE operator&(_TYPE v1, _TYPE v2) \
	{ return _TYPE(int(v1) & int(v2)); } \
	inline _TYPE operator|(_TYPE v1, _TYPE v2) \
	{ return _TYPE(int(v1) | int(v2)); } \
	inline _TYPE operator^(_TYPE v1, _TYPE v2) \
	{ return _TYPE(int(v1) ^ int(v2)); } \
	inline _TYPE operator~(_TYPE v1) \
	{ return _TYPE(~int(v1)); } \
	inline _TYPE& operator|=(_TYPE& v1, _TYPE v2) \
	{ return v1 = v1 | v2; } \
	inline _TYPE& operator&=(_TYPE& v1, _TYPE v2) \
	{ return v1 = v1 & v2; } \
	inline _TYPE& operator^=(_TYPE& v1, _TYPE v2) \
	{ return v1 = v1 ^ v2; } \
	inline _TYPE& operator++(_TYPE& v1) \
	{ return v1 = _TYPE(int(v1) + 1); } \
	inline _TYPE& operator++(_TYPE& v1, int) \
	{ return v1 = _TYPE(int(v1) + 1); } \
	inline _TYPE& operator--(_TYPE& v1) \
	{ return v1 = _TYPE(int(v1) - 1); } \
	inline _TYPE& operator--(_TYPE& v1, int) \
	{ return v1 = _TYPE(int(v1) - 1); }