PORTAGE_SYNC_STALE for stale portage tree warning

When I was trying to install a library for compilation, emerge told me the portage tree was 30 days old:

$ emerge -pvt1 log4cplus
 * Last emerge --sync was 30d 9h 12m 12s ago.
[snip]

This was the first time I ever noticed it. After grepping the source code of emerge in /usr/lib/portage/pym/_emerge/sync/old_tree_timestamp.py, I found where the message was produced:

92:  out.ewarn("Last emerge --sync was %s ago." % \
95:  out.ewarn(_("Last emerge --sync was %s.") % \

Of course, this is a built-in feature of emerge to remind user to update system. The default PORTAGE_SYNC_STALE variable is set to 30 days. From emerge(1):

The PORTAGE_SYNC_STALE variable configures warnings that are shown when emerge --sync has not been executed recently.

I have been trying to do the update every 30 days for a few months, I think this message proves that switching from the previous weekly update is a good decision.

There is no reason to update that often, it probably could only start to go bad after 30 days, and that date is just for reference like the dates for imitation cheeses, you can still eat them even way beyond one year of the date if you dare.

Whether you do it every day, three days, seven days, thirty days, even odd numbered dates, Fibonacci numbered dates, random dates, flipping the coins, or whatever you choose to update, as long as you can put a number into PORTAGE_SYNC_STALE, that might remind you to do the update, because it surely did to me. I thought the next update would be around 20-something this month, but nope, it’s 13th.

Okay, maybe only the cheese, but really don’t try that on Gentoo, 30 days, maybe two months at most.

Put a number in Bash prompt

I was thinking to take a screenshot of commands and outputs, a thought or a question come to me:

Is there anyway I can refer to a line of command without (re-)pasting?

If I have some simple and short reference points, it would be easier to write for me, and clearer to read for readers.

1   IPython Prompt Numbers

Immediately, I thought of IPython, even I don’t even have it installed nor do I use it, I probably only had used it a couple of times since the day I learned Python. Nevertheless, I always could tell the console of IPython.

IPython has something called Prompt Numbers, it would look like, from Introducing IPython:

In [1]: %timeit range(1000)
100000 loops, best of 3: 7.76 us per loop

In [2]: %%timeit x = range(10000)
   ...: max(x)
   ...:
1000 loops, best of 3: 223 us per loop

As you can see, there are [1] and [2], good and clear referencing points for writing.

2   Bash Command Number

In Bash prompt, there is Command Number (\#) for PS1 (also History Number \!), which is the number of current command of current session, for example:

PS1 $ bash
PS1 $ PS1='[\#] \$ '
[2] $ true
[3] $ false
[4] $

The problem is, perhaps my lack knowledge of session, I can’t find a way to reset a session, that is resetting the number. The only way I know is starting a new shell process.

3   Numbering with Arithmetic Expansion

The following simple prompt utilizing Arithmetic Expansion does the trick, you can easily reset the number [3] without starting a new shell:

PS1 $ bash
PS1 $ PS1='[$((++N))] \$ '
[1] $ true
[2] $ false
[3] $ N=0
[1] $ true
[2] $

If you want to produce a clear output for either a screenshot or pasting the text, mis-typing happens, although you still need to re-type, but if you don’t need to start a new shell, just a quick a reset the variable, that might be more preferable, at least for me.

The only drawback I am aware of is if you just press without entering anything, the Command Number would not be increased, but the method above would, which may not be you want if you are super picky.

GCC_UNUSED, GCC unused attribute

When I was making a video of tclock.c of ncurses-examples, I noticed this part:

int
main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
{
    /* ... */
}

I could already guess that GCC_UNUSED is a GCC variable __attribute__, although I have never used that extension before:

unused
This attribute, attached to a variable, means that the variable is meant to be possibly unused. GCC does not produce a warning for this variable.

If you have unused variables with related warning flags on, -Wunused-parameter and -Wunused-variable, or simply -Wall -Wextra, GCC would show warnings like:

GCC_UNUSED.c: In function 'main':
GCC_UNUSED.c:4:7: warning: unused variable 'shout_about_me' [-Wunused-variable]
GCC_UNUSED.c:2:10: warning: unused parameter 'argc' [-Wunused-parameter]
GCC_UNUSED.c:2:22: warning: unused parameter 'argv' [-Wunused-parameter]

For a code as shown below:

int
main(int argc, char *argv[])
{
  int shout_about_me;

  return 0;
}

To disable those warning when using GCC, GCC_UNUSED seems commonly defined for being used like the following:

#define GCC_UNUSED __attribute__((unused))

int
main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
{
  int shout_about_me GCC_UNUSED;

  return 0;
}

Just like the one I’ve seen in tclock.c. GCC_UNUSED would specifying that the variable and parameters are unused, GCC wouldn’t tell you anything if those are not used.

The identifier is used very common, ncurses, lynx, or xterm, all have it defined in the same name. As far a I could tell, it’s not defined by any standard headers, you would need to define it in your codes.

Not all compilers used are GCC, so I have even seen more often another approach is taken, which would check __GNUC__, if undefined, it then defines as a comment to avoid errors in other compilers, more or less like the following code:

#ifdef __GNUC__
// curses.h or other sources may already define
#undef  GCC_UNUSED
#define GCC_UNUSED __attribute__((unused))
#else
#define GCC_UNUSED /* nothing */
#endif

I used the code above because I don’t want the warnings, for instances ncurses would define it be /* nothing */ if not already defined, so a redefinition is needed to ensure it goes my way; or you can define before including curses.h.

GCC used variable attribute seems good to utilize, but what if I want warnings for using unused variables?

int using_unused GCC_UNUSED;

using_unused = 1;
printf("%d\n", using_unused);

I’d like GCC to spit a warning, when I use an unused variable, so I could take GCC_UNUSED off the variable.

SotD: The Fox (What Does The Fox Say?) by Alvis

I first heard The Fox (What Does The Fox Say?) by Alvis, who are Norwegian, via one of DreamHack tournaments, couldn’t remember which one, but you can bet DreamHack always plays the strangest music videos for you at the down time.

https://i.ytimg.com/vi/jofNR_WkoCE/maxresdefault.jpg

If the frame above can’t convince you this music video is bizarre, dunno know what to say…

This song hadn’t been in my mind for some time until I was making a video of cowpy. While trying to think of a good line for the cow to say just moments ago, “What Does The Fox Say?” popped up from nowhere, hence we are having this blog post.

The lyrics do not make any sense at all, and the music video is just weird from the beginning to the end. You understand each word, words form sentences, you still understand, sort of.

But when putting everything together, what the F!@#$ does the fox say?

As of now, it has been wondered for 446,822,334 times, goddammit!