Script that works for bash and tcsh at the same time

test "$?BASH_VERSION" != "0" || goto tcshcmd

echo "running in bash"

if [[ "$1" == "test" ]]; then
  echo "you have passed test as argument"
return 0


echo "running in tcsh"

if ( "$1" == "test") then
  echo "you have passed test as argument"

gdb – string comparison in breakpoint

break foo if strcmp(string_var,"some_string") == 0

NetCat 8.1 participation is now open!

Make sure to join it if you are the fan of NetBeans and you like to do some serious testing!

NetCat 8.1

R – adding group value into result of auto.arima

If you want to use arima with data that are divided into groups, you can do something like this.

data <- read.csv("some_input.txt", header=TRUE, sep="\t")
 split_data <- split( data, data$group )
 for (name in names(split_data)) {
   pred <- c(spt1[[name]][['value']])
   indata <- stats::ts( pred )

Result will be grouped in sections, like this

[1] "1"
   Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
[1] "2"
   Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
[1] "3"
   Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
[1] "4"
   Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
[1] "5"
   Point Forecast Lo 80 Hi 80 Lo 95 Hi 95

If you want to add group No. into result, you can easily achieve that with awk

cat result | awk 'BEGIN{regex="^\\[";} \ 
{ if (match($0, regex)) { split($0,arr,"\""); number = arr[2]} \
else \
{ if ($0 ~ /Point/) {} \
else \
{ print $0,number } }}'

And Now for Something Completely Different – Chemicals are releasing new album !! :)


Final proof that there is a “bigger half” :)

You know that “bigger half” thing. When you divide a cake and the other guy says, “I want that bigger half”.

And you probably know that mathematicians freak out when they hear that.

But, you know, there is a proof that there is actually a bigger half. If engineer says so, and it works, it must be the true :)


Some people complain that numbers are not clear. So, to be precise:

1 => 2:23
1/2 => 1:58

Syntax theme and custom name of the first page

I was struggling, recently, with Syntax theme. This is super cool theme if you are focusing on writing. Simple, very plain, no fancy stuff around. Just text.

There is, however, one thing I had to change. In the menu (you can find it on the left side of the page), first page is called “Home”. I wanted to have it titled “Cover” – take a look here –

I had to modify function syntax_page_menu_args inside inc/extras.php to get it working.

I have replaced following line

function syntax_page_menu_args( $args ) {
//  $args['show_home'] = true;
  $args['show_home'] = 'Cover';
  return $args;

And now, instead of “Home” I have “Cover”


Cleaning Time Machine’s disk

If you get close to the capacity of Time Machine, you can easily solve that by:

Note! You will work as root! You may destroy things!

shell> su -
shell> cd /Volumes/your_time_machine_disk/Backups.backupdb/machine_name
# to find what you can delete just use command (make sure you get correct result)
shell> find . -maxdepth 1 -type d ! -newermt yyyy-mm-dd
# after you know what will be removed
shell> find . -maxdepth 1 -type d ! -newermt yyyy-mm-dd -exec tmutil delete {} \;

Effective Modern C++ by Scott Meyers


Summary: Solid introduction to modern C++

On a day to day basis I work with C++ legacy code. No surprises, just classes and some overloaded operators. Nothing special. I have jumped into Effective Modern C++ as I wanted to know what’s really behind C++11 and C++14. And there’s a lot.

I bet, after reading this book, you will immediately try to drop all your NULLs in favor of nullptr (have you ever tried to overload function that has either pointer or int as argument). I bet you will strongly consider {} based initialization. Aliases and scoped enums are also nice to have features of the langue. And, what really caught me by surprise were auto variables. I am in favor of strong typing, but after reading explanation of autos and how can you benefit from them in context of templates, I think I will change my mind.

The same thing refers to pointers. I am an old school, C based developer, and I always use regular, old style pointers. But I am pretty sure I will take a closer look at std based ones.

Book explains topics in consistent, but demanding way. This is not a C++ primer or cook book style title. It will not give you straight answers related to your code and problems that you might be facing. Instead, it will give you systematic, and pragmatic overview of new features in C++11/C++14. There are lots of references to C++98 that give you explanation for why should you consider moving forward.

If you are new to C++, wait a little bit before reading this one. Take a closer look at Professional C++ by Marc Gregoire instead. Then, get back to this one.

Anyway, if you work with C++ legacy code and you want to get familiar with new stuff that is already out there, I really recommend this one.

O’Reilly (print): Effective Modern C++
Safari Books Online: Effective Modern C++

Teaser № 3