Weather in terminal

For years, I had wanted to see something like the following screenshot:

https://lh5.googleusercontent.com/-hso9qZeeVyM/VPMDcOu93EI/AAAAAAAAG7k/UvlNZ1XHw8M/s800/ww.py%25202015-03-01--19%253A39%253A08.png

Before I finally wrote ww.py, Google was the place for the weather information, I even had special bookmark, so I could quickly get to the page. Google’s weather information is nice, but in my eyes, it’s not efficient even it only takes a second or a few to be rendered. There always is search results in the page with the weather, but I know I am not interested in those.

I waited for something to come up and postponed my own attempt until now, but nothing close ever came up. Frankly, mine isn’t exactly what I want, the colors are a bit of weird. Originally, it didn’t use any colors, but I thought I should add some before put the script out in the wild, then, before I realized, it got too long, too messy, and it’s too late.

Still, something is better than nothing.

Listing Gentoo packages with ambiguous names

Back in August, 2013, someone was expressing the annoyances of having packages with same short names, which may result in the following messages from emerge:

!!! The short ebuild name "foobar" is ambiguous. Please specify
!!! one of the above fully-qualified ebuild names instead.

After reading it, I could feel the groan and probably the reason why I sometimes tried to write the full name if I was absolutely the category name. You must understand that writing the full name isn’t always easy if you ain’t dealing with the package often, you might quite easily to guess wrong.

However, at least, you wouldn’t be getting wrong package just because you are lazy. You will be prompted, asking to write the full name, so emerge can do the action to the correct package.

At the time, I wrote a very long one-liner, 423-character, to list those packages. For some reason, I didn’t feel wanting to post it until now. So the following is the code and the output at the time of writing. It’s a very long list as you will see.

find /usr/portage/ -mindepth 2 -maxdepth 2 -type d | grep -v \/virtual\/ | cut -d \/ -f 4- | python -c 'import itertools as it; import sys; pkgs = [p.strip().split("/") for p in sys.stdin.readlines()]; kf = lambda p: p[1]; print("\n".join(["%3d %s\n%s\n" % (len(lst), k, "\n".join(lst)) for k, lst in ((k, ["    %s/%s" % (p[0], k) for p in list(g)]) for k, g in it.groupby(sorted(pkgs, key=kf), key=kf)) if len(lst) > 1]))'
2 ace
  dev-libs/ace
  games-board/ace

2 amap
  net-analyzer/amap
  sci-biology/amap

2 analog
  app-admin/analog
  app-emacs/analog

2 apel
  app-emacs/apel
  app-xemacs/apel

2 arrows
  games-puzzle/arrows
  dev-haskell/arrows

3 async
  dev-haskell/async
  dev-python/async
  dev-ml/async

2 attica
  kde-frameworks/attica
  kde-base/attica

2 auctex
  app-emacs/auctex
  app-xemacs/auctex

2 axiom
  dev-python/axiom
  sci-mathematics/axiom

2 balsa
  mail-client/balsa
  sci-electronics/balsa

2 barcode
  app-officeext/barcode
  app-text/barcode

2 bbdb
  app-emacs/bbdb
  app-xemacs/bbdb

2 bcrypt
  dev-python/bcrypt
  app-crypt/bcrypt

2 bfm
  app-misc/bfm
  x11-plugins/bfm

2 binclock
  app-misc/binclock
  app-emacs/binclock

2 boxes
  app-misc/boxes
  dev-haskell/boxes

2 build
  dev-util/build
  app-xemacs/build

2 bunny
  dev-util/bunny
  dev-ruby/bunny

2 c-support
  app-xemacs/c-support
  app-vim/c-support

2 cairo
  dev-haskell/cairo
  x11-libs/cairo

2 calc
  sci-mathematics/calc
  app-xemacs/calc

4 calendar
  app-misc/calendar
  app-xemacs/calendar
  app-vim/calendar
  dev-ml/calendar

2 cdcover
  app-cdr/cdcover
  dev-tex/cdcover

2 charm
  sys-cluster/charm
  net-misc/charm

2 color
  app-misc/color
  dev-ruby/color

2 columnize
  dev-python/columnize
  dev-ruby/columnize

2 cookie
  dev-haskell/cookie
  app-xemacs/cookie

2 crystal
  x11-themes/crystal
  games-mud/crystal

2 csv
  app-vim/csv
  dev-ml/csv

2 curl
  dev-haskell/curl
  net-misc/curl

2 dav
  app-editors/dav
  dev-haskell/dav

2 dbus
  sys-apps/dbus
  dev-haskell/dbus

2 dictionary
  app-emacs/dictionary
  app-xemacs/dictionary

2 diff
  rox-extra/diff
  dev-haskell/diff

2 dirdiff
  dev-util/dirdiff
  app-vim/dirdiff

2 docker
  app-emulation/docker
  x11-plugins/docker

2 dolphin
  kde-base/dolphin
  games-emulation/dolphin

2 ebuild-mode
  app-emacs/ebuild-mode
  app-xemacs/ebuild-mode

2 ecb
  app-emacs/ecb
  app-xemacs/ecb

2 elib
  app-emacs/elib
  app-xemacs/elib

2 entropy
  sys-apps/entropy
  dev-haskell/entropy

2 enum
  app-misc/enum
  dev-perl/enum

2 ess
  app-emacs/ess
  app-xemacs/ess

2 extlib
  dev-ruby/extlib
  dev-ml/extlib

2 falcon
  dev-lang/falcon
  dev-python/falcon

2 fcgi
  dev-libs/fcgi
  dev-ruby/fcgi

2 fetch
  rox-extra/fetch
  www-client/fetch

2 fuse
  app-emulation/fuse
  sys-fs/fuse

2 gambit
  dev-scheme/gambit
  games-board/gambit

2 gdl
  dev-libs/gdl
  dev-lang/gdl

2 git
  dev-vcs/git
  dev-ruby/git

3 glade
  dev-util/glade
  dev-ada/glade
  dev-haskell/glade

2 glib
  dev-libs/glib
  dev-haskell/glib

2 gnupg
  app-vim/gnupg
  app-crypt/gnupg

2 gnuplot
  sci-visualization/gnuplot
  dev-ruby/gnuplot

2 gnutls
  dev-haskell/gnutls
  net-libs/gnutls

2 gom
  dev-libs/gom
  media-sound/gom

2 gsasl
  dev-haskell/gsasl
  net-misc/gsasl

2 haskell-mode
  app-emacs/haskell-mode
  app-xemacs/haskell-mode

2 highline
  app-emacs/highline
  dev-ruby/highline

2 hiredis
  dev-libs/hiredis
  dev-python/hiredis

2 hourglass
  app-office/hourglass
  dev-haskell/hourglass

2 html2text
  app-text/html2text
  dev-python/html2text

2 http
  dev-haskell/http
  dev-ruby/http

2 http-parser
  dev-python/http-parser
  net-libs/http-parser

2 icecream
  sys-devel/icecream
  media-sound/icecream

2 igrep
  app-emacs/igrep
  app-xemacs/igrep

2 ipcalc
  dev-python/ipcalc
  net-misc/ipcalc

2 jal
  dev-embedded/jal
  dev-java/jal

2 jama
  sci-libs/jama
  dev-java/jama

2 jde
  app-emacs/jde
  app-xemacs/jde

3 json
  dev-haskell/json
  app-vim/json
  dev-ruby/json

2 kactivities
  kde-frameworks/kactivities
  kde-base/kactivities

2 kdesu
  kde-frameworks/kdesu
  kde-base/kdesu

2 kglobalaccel
  kde-frameworks/kglobalaccel
  kde-base/kglobalaccel

2 knewstuff
  kde-frameworks/knewstuff
  kde-base/knewstuff

2 krunner
  kde-frameworks/krunner
  kde-base/krunner

2 kstart
  kde-base/kstart
  app-crypt/kstart

2 launchy
  x11-misc/launchy
  dev-ruby/launchy

2 layman
  app-portage/layman
  local/layman

2 lemon
  sci-libs/lemon
  dev-ruby/lemon

2 libmimedir
  gpe-base/libmimedir
  dev-libs/libmimedir

2 libmpd
  media-libs/libmpd
  dev-haskell/libmpd

2 libnatpmp
  dev-python/libnatpmp
  net-libs/libnatpmp

2 libnet
  perl-core/libnet
  net-libs/libnet

2 libxml
  dev-haskell/libxml
  dev-ruby/libxml

2 listen
  dev-ruby/listen
  media-sound/listen

2 locale
  app-xemacs/locale
  dev-ruby/locale

2 lockfile
  dev-python/lockfile
  dev-ruby/lockfile

2 lookup
  app-emacs/lookup
  app-xemacs/lookup

2 lz4
  app-arch/lz4
  dev-python/lz4

2 lzma
  app-arch/lzma
  dev-java/lzma

2 magic
  sci-electronics/magic
  dev-ruby/magic

2 mailcrypt
  app-emacs/mailcrypt
  app-xemacs/mailcrypt

2 mars
  sci-chemistry/mars
  sys-libs/mars

2 mash
  media-libs/mash
  dev-ruby/mash

2 mc
  app-misc/mc
  sci-libs/mc

2 mechanize
  dev-python/mechanize
  dev-ruby/mechanize

2 mediawiki
  app-emacs/mediawiki
  www-apps/mediawiki

2 mew
  app-emacs/mew
  app-xemacs/mew

3 mime-types
  app-misc/mime-types
  dev-haskell/mime-types
  dev-ruby/mime-types

2 miniupnpc
  dev-python/miniupnpc
  net-libs/miniupnpc

2 mldonkey
  app-emacs/mldonkey
  net-p2p/mldonkey

2 mmix
  dev-lang/mmix
  media-sound/mmix

2 mmm-mode
  app-emacs/mmm-mode
  app-xemacs/mmm-mode

2 mock
  dev-util/mock
  dev-python/mock

2 mpc
  dev-libs/mpc
  media-sound/mpc

3 msgpack
  dev-libs/msgpack
  dev-python/msgpack
  dev-ruby/msgpack

2 muse
  app-emacs/muse
  media-sound/muse

2 nagios
  net-analyzer/nagios
  dev-ruby/nagios

2 nemesis
  sci-libs/nemesis
  net-misc/nemesis

2 net-sftp
  dev-ruby/net-sftp
  dev-perl/net-sftp

2 ninja
  net-irc/ninja
  dev-util/ninja

2 nitrogen
  x11-misc/nitrogen
  x11-themes/nitrogen

2 nut
  app-misc/nut
  sys-power/nut

2 oasis
  sci-chemistry/oasis
  dev-ml/oasis

2 oauth
  dev-python/oauth
  dev-ruby/oauth

2 oauth2
  dev-python/oauth2
  dev-ruby/oauth2

2 ocaml
  dev-lang/ocaml
  app-xemacs/ocaml

2 openal
  media-libs/openal
  dev-haskell/openal

2 openmsx
  games-emulation/openmsx
  games-misc/openmsx

2 otter
  www-client/otter
  sci-mathematics/otter

2 pango
  dev-haskell/pango
  x11-libs/pango

3 par
  app-arch/par
  dev-util/par
  app-text/par

2 parallel
  sys-process/parallel
  dev-haskell/parallel

2 pdv
  app-arch/pdv
  app-vim/pdv

2 pgpdump
  dev-python/pgpdump
  app-crypt/pgpdump

2 picard
  sci-biology/picard
  media-sound/picard

2 pip
  app-misc/pip
  dev-python/pip

2 planner
  app-office/planner
  app-emacs/planner

2 pms
  app-doc/pms
  media-sound/pms

2 psgml
  app-emacs/psgml
  app-xemacs/psgml

2 psi
  sci-chemistry/psi
  net-im/psi

2 python-mode
  app-emacs/python-mode
  app-vim/python-mode

2 qct
  dev-vcs/qct
  games-simulation/qct

2 rails
  app-vim/rails
  dev-ruby/rails

2 re2
  dev-libs/re2
  dev-ml/re2

2 readline
  sys-libs/readline
  dev-haskell/readline

2 redis
  dev-db/redis
  dev-ruby/redis

2 reduce
  sci-chemistry/reduce
  sci-mathematics/reduce

2 rename
  sys-apps/rename
  dev-perl/rename

2 riece
  app-emacs/riece
  app-xemacs/riece

2 rply
  media-libs/rply
  dev-python/rply

2 rust-mode
  app-emacs/rust-mode
  app-vim/rust-mode

2 scala
  sci-chemistry/scala
  dev-lang/scala

2 screen
  app-misc/screen
  app-vim/screen

2 sendfile
  dev-haskell/sendfile
  net-misc/sendfile

3 session
  app-emacs/session
  app-vim/session
  dev-ruby/session

2 silo
  sci-libs/silo
  sys-boot/silo

2 six
  dev-python/six
  dev-ruby/six

2 ski
  app-emulation/ski
  games-sports/ski

2 slim
  x11-misc/slim
  dev-ruby/slim

2 slurm
  sys-cluster/slurm
  net-analyzer/slurm

2 smack
  dev-libs/smack
  dev-java/smack

2 sml-mode
  app-emacs/sml-mode
  app-xemacs/sml-mode

4 snappy
  app-arch/snappy
  media-video/snappy
  dev-python/snappy
  dev-java/snappy

2 sphinx
  app-misc/sphinx
  dev-python/sphinx

2 spice
  sci-electronics/spice
  app-emulation/spice

2 spin
  sci-mathematics/spin
  dev-java/spin

2 splat
  sci-electronics/splat
  app-portage/splat

2 splice
  games-puzzle/splice
  app-vim/splice

2 ssh
  app-emacs/ssh
  dev-python/ssh

2 surf
  sci-chemistry/surf
  www-client/surf

2 tagsoup
  dev-haskell/tagsoup
  dev-java/tagsoup

2 tar
  app-arch/tar
  dev-haskell/tar

2 teco
  app-editors/teco
  app-emacs/teco

2 termcolor
  dev-python/termcolor
  dev-ruby/termcolor

2 texinfo
  sys-apps/texinfo
  app-xemacs/texinfo

2 text
  dev-haskell/text
  dev-ruby/text

2 threads
  perl-core/threads
  dev-haskell/threads

2 thumbs
  app-emacs/thumbs
  rox-base/thumbs

2 time
  sys-process/time
  app-xemacs/time

2 tls
  dev-tcltk/tls
  dev-haskell/tls

2 tokyocabinet
  dev-db/tokyocabinet
  dev-ruby/tokyocabinet

2 tornado
  games-strategy/tornado
  www-servers/tornado

2 torrent
  games-puzzle/torrent
  dev-haskell/torrent

2 tree
  dev-cpp/tree
  app-text/tree

2 twitter
  dev-python/twitter
  dev-ruby/twitter

2 uclibc
  profiles/uclibc
  sys-libs/uclibc

2 uulib
  dev-libs/uulib
  dev-haskell/uulib

2 vc
  dev-libs/vc
  app-xemacs/vc

2 vm
  app-emacs/vm
  app-xemacs/vm

2 volume
  app-emacs/volume
  rox-base/volume

2 watchdog
  sys-apps/watchdog
  dev-python/watchdog

2 xclip
  x11-misc/xclip
  app-emacs/xclip

2 xslide
  app-emacs/xslide
  app-xemacs/xslide

2 yaml
  dev-haskell/yaml
  dev-perl/yaml

2 zenirc
  app-emacs/zenirc
  app-xemacs/zenirc

2 zlib
  sys-libs/zlib
  dev-haskell/zlib

Plotting number of installed Gentoo packages over time

In about two months, that will be the sixth anniversary as Gentoo user for me, but I just realized that I could plot the number of installed packages over time since the first package was installed.

Gentoo Portage maintains /var/log/emerge.log, everything is written in it since Gentoo was first installed, I wrote gentoo-numbers-packages.py to plot the following chart using that log file:

https://lh4.googleusercontent.com/-A4ru38qLmiE/VNrZiRJk0vI/AAAAAAAAG6Y/iRLlqcEn8UE/s640/gentoo-numbers-packages.png

There is a big issue, there are 31 entries in my log causing KeyError and ValueError. They mean either the package or the version has not been merged before a unmerge success log entry. I don’t know how that happens, but I think they could be installed via the stage tarball, they were copied onto the system, not installed via emerge, therefore the log doesn’t contain any merging logs.

If you know what’s going on and have a correct fix, please do let me know. I might extract the script from the Gist, so you could fork it cleaner.

The other thing is, the numbers since quite different as shown below.

command packages by versions
equery l '*' | wc -l 975  
EIX_LIMIT_COMPACT=1 eix -Ic 960  
gentoo-numbers-packages.py 1016 1226

I am not sure how equery and eix counts the packages, but I believe eix doesn’t count each version into the number of packages. It seems to merge all versions and slots into one count, and maybe also not count the obsolete packages.

If I ran eix -ic, it reported only 12 packages had more than one version installed, I have no idea where the 1226-1016=210 extra versions come from. Anyway, I don’t really mind the issue, all I want to see a graph, even it’s not completely accurate, a line indicating the installed packages, and I do have one now.

The script works on both Python 2 and 3. Beside the counting part, the most interesting is the package Names and Versions specification, I didn’t write the regular expression, I just copied from Package Manager Specification (eapi-5-approved-2012-09-20), and pieced them together with slight modifications.

I wouldn’t know about Package Manager Specification if I didn’t stumble on a forum post, glad I still remember it or I might not ever work out a correct regular expression by myself.

Overlay bar is bad and a bad bar is a bad bar

At the end of December, 2012, that was little more than two years ago, I’d noticed “The Bar Thing,” which I would described as epidemic. Actually, it had been going on longer than that, just I finally put a note down.

I believed it’s when the Flickr brought Navigate and Explore online, which has been replaced with a bigger overlay bar, that made things worst. Flickr was not the only one, Meebo, StumbleUpon, and probably much more were doing the same.

1   topbar and overlay

There are a lot of websites uses bars, topbar and overlay bar mostly. topbar usually contains more important functions, such as top-level navigation links as well as the search box. Overlay bar usually, from my experience, is stuff trying to get your attention, hoping to get you to visit more pages. In other words, it’s a spam to me.

Google used to have a topbar that had links to some major services, but some time after August, 2013, it was removed and replaced with an “Apps” button next to your name. Ever since the bar was added, I saw more websites trying to mimic, not sure if Yahoo was one of them, but it still has a topbar, and an overlay bar.

2   Overlay is bad

I am okay with topbar as long as it doesn’t become overlay as you scroll down, and it’s fixed in page. Why overlay is bad? I have two good reasons:

  1. It blocks content underneath it.

    If it’s at top and about 2 lines, when you scroll down using PageDown, you will find two lines that hasn’t been display are being buried under the bar. That is if you want to use keyboard to read page by page, you are risking missing some contents if you don’t go scroll back up two lines every time you go down a page.

    It’s a fundamental design flaw and nowhere to go around it, however, if it’s not an overlay but a real topbar which doesn’t stay on top of the content, then there would be no such problem.

    Yes, mouse wheel to scroll wouldn’t have this problem since it’s slowly bit by bit, but if you are really reading and you want to minimize finger use, you would use keyboard. PageDown requires much less than rolling mouse wheel.

  2. Search hit underneath it.

    As I use Pentadactyl / search, I often find the hits being blocked by overlay bar which is a bottom overlay bar, when I press n to jump to next hit result.

    With Firefox Ctrl+F, the hit would be brought into middle of screen. But since I use Pentadactyl, I’d not want to bring up Firefox’s UI, would I?

    This is the most annoying issue when I am searching something in a page.

3   Final words

A workaround I am using is to hide the overlay bar, but if it contains site search box, that would be a problem.

I have a confession to make, very little of making the overlay bars might have been contributed by me. The most visited page of this blog, Stick div at top after scrolling definitely is for that purpose, and it’s got quite some views. I guess that I could blame myself for a little bit.

I hope people stop to really use their websites, not just to design them to make them look fancy. Maybe it’s just me, but I feel more an more people really don’t care what’s on page, they just scroll and close the page.

It’s the small thing counts the most, but we probably have too many small things these days, and nobody cares to give a thought about them, let alone actually use or read them.

Bar you inside the website.