Disclaimer

The content of this blog is my personal opinion only. Although I am an employee - currently of Nvidia, in the past of other companies such as Iagination Technologies, MIPS, Intellectual Ventures, Intel, AMD, Motorola, and Gould - I reveal this only so that the reader may account for any possible bias I may have towards my employer's products. The statements I make here in no way represent my employer's position, nor am I authorized to speak on behalf of my employer. In fact, this posting may not even represent my personal opinion, since occasionally I play devil's advocate.

See http://docs.google.com/View?id=dcxddbtr_23cg5thdfj for photo credits.

Saturday, May 19, 2012

X widgets bad sizes in twm RightTitleButton due to LANG=en_US.UTF-8 fixed by unsetting LANG or setting LANG=C

Since I got to my current employer last October, I have been suffering problems with my X setup.

First: admission: I still use twm. Or, rather: twm has been my fallback window manager for years, when other X setup breaks. As it so often does.

Instead of the widgets at the top of my windows being nice and compact:


They were "blown up":


This was particularly painful when working on my tablet PC, 1366x768.  Too much screen space lost. Got in the way of doing useful work.

I have avoided the problem all this time, 8 months, by not using my laptop except when plugged into external monitors with lots of pixels.

Well, this week I away from my external monitors.  So I figured out what the problem was.

By process of elimination:

The problem that was causing the twm RightTitleButtons to be too large was due to

LANG=en_US.UTF-8

When I unset LANG, or set LANG=C (as I have had to do elsewhere), twm works properly.

Why? I dunno.

Why do I have LANG set to en_US.UTF-8? I dunno - it was default.

--


glew@ubuntu-uarch:~$ uname -a
Linux ubuntu-uarch 2.6.32-33-generic #72-Ubuntu SMP Fri Jul 29 21:07:13 UTC 2011 x86_64 GNU/Linux

But also occurred on CentOS and RedHat.

--

I hate internationalization bugs.  Mainly because I worked on pre-POSIX internationalization, and *my* system never had such bugs. ;-}


--

Some text that might make it easier to find this bug and fix:

X widgets bad sizes
in twm RightTitleButton
due to LANG=en_US.UTF-8
fixed by unsetting LANG or setting LANG=C




Wednesday, May 16, 2012

Stupid Programming Bugs

I will start trying to cllect stupid programming bugs that I have wasted my time on. Especially if I did not google the answer the first time. http://wiki.andy.glew.ca/wiki/Stupid_Programming_Bugs http://wiki.andy.glew.ca/wiki/Forgetting_to_flush_stdout_and_stderr_before_fork Now I'll expose how stupid a programmer I can be. By recording stupid timewasting bugs that I should have known better about. So that, I hope, I will be able to google them if I repeat the bug Ditto others.

Thursday, May 10, 2012

Disambiguating names according to scopes in C++

Consider
int biff;
int var;
struct Var {
  int var;
  void foo(int var) {
      biff = var; 
  }
};
Which var is used in the assignment? Sure, a good C++ programmer knows the rules. But it can be hard to tell in a large program. You can disambiguate for the member
      biff = this->var; 
or the global
      biff = ::var; 
But so far as I know there is no syntax for arguments. I often use a naming convention
  void foo(int arg_var) {
      this->var = arg_var; 
  }
This is not unlike the widespread convention of saying
  void foo(int arg_var) {
      m_var = arg_var; 
  }
although I deprecate this because m_var for member names can lie - there may be a global of that name. Whereas this-> is not much bigger, and has the compiler check your meaning. Perhaps there should be sigils, like this-> and ::, for arguments and locals? -- Late addition, 5/25/2012: I dislike extra typing. Plus, occasionally I will do a refactoring where an arg or a global becomes a local or a member. Sometimes I want such refactorfings to show up in history diffs, sometimes not. Here's an interesting possibility: have the build or ODE system annotate the code with a hidden sigil (which I would suggest being XML, something like . Have the IDE warn if an edit would change the implicit sigil. Much as GCC warns if an inner scope hides an outer scope's name.

Wednesday, May 09, 2012

xpra

---+ rootless shareable and transportable X sessions.

For a long time I have been frustrated by VNC's putting all of the application windows in a big window for the X root.  It always seemed to me that you could have an X server that kept all of the windows separate - perhaps by having an infinitely resizable root - which then allows the windows to be forwarded to the user's display (I think of that as a client, but in X terms it is a display server), and treated independently there.

I'm not the only one. Googling finds many people looking for "screen for X". I guess I betray my age when I admit that my desire for this predates GNU screen and VNC.  I remember being happy when I encountered GNU screen's terminal multiplexer, since I had used similar tools elsewhere.  (By the way, while I am at it: I recently started trying to use GNU screen, after a long lapse.  One of my complaints is that GNU screen seems to be screen. I vaguely remember a terminal multiplexer that handled dumb terminals well enough, allowing you to connect separate terminal emulators, as well as other stuff.)

Anyway: screen for X...

I have looked at NX, xmove, etc., at various times, all with differing degrees of clunkiness. Nothing made mwe happy until...

---+ xpra

Hurrah for xpra! http://xpra.org/

xpra allows you to send applications from one display to another.  On an application by application basis. (Hmm, I wonder what happens to a multi-window application.)

I am happy that IT finally has a system on which they were willing to install xpra.

---+ Winswitch? not yet, maybe not ever

I am considering winswitch, http://winswitch.org/, which is layered on top of xpra or VNC or RDP or ssh -X or NX or ...

But I am not jumping at winswitch the way I am jumping at xpra, since (a) I don't want yet another insecure password system, and (b) it seems to depend on all sides running winswitch.

---+ xpra does NOT need to be installed on both sides

Typically xpra usage examples say
http://xpra.org/:

    On the machine which will export the application (xterm in this example):
    xpra start :100
    DISPLAY=:100 xterm
    
    For the simple case, we can then attach to this session from the same machine with:
    xpra attach :100
    
    If connecting from a remote machine, you would use something like:
    xpra attach ssh:serverhostname:100


or
https://help.ubuntu.com/community/Xpra:


    xpra start :7
    • Start an xpra server using display number :7.
    DISPLAY=:7 firefox
    • Start firefox running inside the xpra server. No window will appear.
    xpra list
    • Show a list of xpra servers you have running on the current host.
    xpra attach :7
    • Attach to the xpra server that is using local display number :7. Any apps running on that server will appear on your screen.
    xpra attach ssh:frodo:7
    • Use ssh to attach to the xpra server that is running on machine frodo and using display :7. Any apps running on that server will appear on your local screen.
    xpra start :7 && DISPLAY=:7 screen
    • Start an xpra server and a screen(1) session. If any of the applications inside screen attempt to use X, they will be directed to the xpra server.
    xpra stop :7
    • Stop the xpra server on display number :7.


I.e. they assume that xpra is installed both on the server and on the client.

(Urg, confusing terminology. There are 3 important systems here: (1) the system where the xpra proxy server runs, (2) the system where the application software runs, and (3) the system where the display runs.)

This was a worry, since I often want to move applications to a system that may have X, but which may not have xpra on.  E.g. Cygwin/X on my Windows PC.  (I considered Winswitch for this, but it requires itself to be installed in too many places.)

I am happy to say that you do NOT need to have xpra installed on the display system.  E.g.


    machine1:~$ xpra start :8
    Entering daemon mode; any further errors will be reported to:
      /home/glew/.xpra/:8.log
    machine1:~$
    machine1:~$ DISPLAY=:8 xterm

    [machine2 ~/.xpra]> ssh -X machine1 xpra attach :8



Monday, May 07, 2012

MS Outlook 2010 text selection bug - and "fix"

For quite some time now, I have been terribly frustrated using MS Outlook 2010.  It was not allowing me to select text in messages that I was reading, neither in a preview pane, now in a proper reading window.

I was only able to select text if I hit reply. In the reply email composition window I could select text.

This was frustrating.

Eventually I learned that if I hot ESCape (and possibly capslock toggle), them I could get to a mode where I could select text in a reading window.

The discussion at the following MS URL helped:


Helped.  Did not describe the fix precisely, although it seems that others may have followed the same path.  One poster kept asking "Does your cursor look like a hand?", and then suggested hitting ESCape.

Well, my cursor did not look like a hand. But hitting ESCape fixed the problem anyway.

--

Sheesh, when I think of all the time I have wasted hitting reply to select and copy text...

Wednesday, May 02, 2012

PDX recycling


New house, new trash and recycling service.  Since I try to be green, but often have trouble find where to recycle, recorded here:

Several different relevant websites:

Tuesday, May 01, 2012

Comments at beginning of line?

code; // we have comments at the end of a line
code /* and comments anywhere on a line, like in the middle */ code;
/* where "anywhere" can be at the beginning: */ code;

but it occurs to me that I often want comments at the beginning of a line, e.g.

foo(
     /* arg1= */ 111,
     /* arg2= */ 222,
)

and although /*...*/ can accomplish this, they are visually heavyweight.

I wonder if, in a hypothetical new language, we could have comments from the beginning of a line?

Now, ":" would be the most natural comment delimiter for this - if it were not already used for so much else:


foo(
     arg1:  111,
     arg2:  222,
)


Note that I have distinguished comments in a special color. One might say that such a special comment color is what we really want... I agree, and have discussed that elsewhere.  But it is certainly traditional to have program text read monocolor:


foo(
     arg1:  111,
     arg2:  222,
)


Now, you might also argue that keyword arguments subsume the example above.  Sure... but then I can create other examples that are not keyword arguments.

I can imagine comment from beginning of line delimiters other than colon, but none are quite so elegant:


foo(
     arg1>>>  111,
     arg2:>>> 222,
)



foo(
     arg1==>  111,
     arg2==> 222,
)



foo(
     arg1:::  111,
     arg2::: 222,
)


Again, we are limited by the ASCII, or UTF, character set.