Enabling 1366×768 resolution in Windows 10

I have been struggling for a while to set this up: enabling  Display Settings so that they would support the 1366×768 resolution of my TV screen, after I connected my laptop with Windows 10 installed to my TV.1) In Display Settings this resolution simply was not offered.

Until I figured out this setting in Display Settings –> Advanced Display Settings –> Display Adapter Properties –> Monitor:

Removing the check mark from this check box revealed the resolution I was looking for. Apparently Windows didn’t have much of a clue about the connected monitor. OK, I admit, I connected it via a simple VGA cable.

Smiley

1)I gave up on ubuntu, too many things didn’t work out of the box ( like sending laptop to sleep when closing the lid ), too much googling and obscure hacking needed, and then display driver started crashing when laptop woke up later on. I do complain about Windows a lot, but Linux systems can be worse, and with Windows 10 Microsoft made a great move towards good quality.

How to enable 1366×768 screen resolution in ubuntu 16-04

It took me a while and some hacking until I figured out how to enable 1366×768 screen resolution in ubuntu 16-04 for my secondary display, a Fujitsu-Siemens TV from pre-HD era, means: HD ready but not providing the full resolution, just 1366×768.

Anyway, here is the magic:

cvt 1366 768 60
xrandr –newmode "1368x768_60.00"   85.25  1368 1440 1576 1784  768 771 781 798 -hsync +vsync
xrandr –addmode VGA-0 "1368x768_60.00"
xrandr –output VGA-0 –mode "1368x768_60.00"

This is sort of what distinguishes a linux system from a Windows system. Often you have to do a lot of weird hacking to achieve certain things.

Nevertheless, I must say, when I had Fedora 25 installed on my computer beforehand it offered 1368×768 screen resolution out of the box, ubuntu didn’t. Well, that’s what makes linux so exciting for many: the need to tinker and learn interesting technical, sometimes magical secrets.

Thanks to this internet articles I finally solved my problem:

“Resolution” in wiki.ubuntu.com

How to get shared folder to work with a virtual ubuntu in Virtualbox

Getting shared folder to work with a virtual ubuntu in Virtualbox is a bit of a nightmare.
Initially they simply can’t be accessed, even after re-installing Virtualbox guest add-ons.
The reason and solution is described here, but adding root account to group vboxsf didn’t work as well because of this problem: "usermod: cannot lock /etc/passwd; try again later.".

Thus, to summarize this mess, to make it work
# you have to reboot into recovery mode
# run this: mount -o remount,rw /
# then that: usermod -a -G vboxsf adminuser
# resume booting into normal mode

Problem solved.
Shared folders BTW can be found under /media.

What Causes Side Pain When You Run (and How to Prevent It)

Interesting article on Lifehacker today for the runners among us: “What Causes Side Pain When You Run (and How to Prevent It)”.

According to the explanation provided this side pain has to do with some internal muscle strain and organs bumping around while running. How to deal with it ? Of course don’t run after heavy meals, and when it occurs take a break, and ensure your are sufficiently hydrated.

I usually don’t have that problem but I learned a different technique how to avoid and treat that problem, and I am not sure though how this is related to the explanations given in that article: breath in through your nose, and breath out through your mouth. It definitely works for me.

How to keep track of changes in multiple columns in a MS Excel spreadsheet

In a question to my blog article “How to keep track of changes in a MS Excel spreadsheet” I have been asked whether the code I showed there could be changed to monitor multiple columns in a spreadsheet.

Of course it can. The new code I am showing below handles an arbitrary number of columns, with the following assumptions / pre-requisites:

  • Column label in row 1
  • Row identifier (id) in column 1 of each row

I have changed my example from the previous article and added an additional column to my list of products: ‘Vendor’, here is an example:

Let’s change Price of Product C to $ 1301,00 and Vendor to ‘Company B’. Here is how the new Change History looks like:

Column B now shows which columns was changed and column C the new value, as usually together with a time stamp. Column A identifies for what product ( my ‘id’ column in this example ) the change occurred.

And here is the new code:

Private Sub Worksheet_Change(ByVal Target As Range)
 Dim AuditRecord As Range
 ' This is our change history ...
 Set AuditRecord = Worksheets("ChangeHistory").Range("A1:B65000")
 r = 0
 ' Now find the end of the Change History to start appending to ...
 Do
    r = r + 1
 Loop Until IsEmpty(AuditRecord.Cells(r, 1))
 ' For each cell modified ...
 For Each c In Target
   Row = c.Row
   Col = c.Column
   Value = c.Value
   ' ... update Change History with value and time stamp of modification
   AuditRecord.Cells(r, 1) = Worksheets("Products").Cells(1, 1) & " " & Worksheets("Products").Cells(Row, 1)
   AuditRecord.Cells(r, 2) = Worksheets("Products").Cells(1, Col)
   AuditRecord.Cells(r, 3) = Value
   AuditRecord.Cells(r, 4).NumberFormat = "dd mm yyyy hh:mm:ss"
   AuditRecord.Cells(r, 4).Value = Now
   r = r + 1
Next End Sub

How to write your own OpenOffice Calc Functions

Today I have been looking for a function in OpenOffice which I would call ( and know from many programming languages ) ‘substring’ and which would allow me to split a string into chunks using a pre-defined delimiter and then return one or more words from this collection of chunks. Did I explain this well ? If not, here is an example: from a string like ‘+   6.84%’ I just need the numeric part, the 6.84 so to speak – to then be able to convert that to a number.

Unfortunately such a function is not offered with OpenOffice. Or should I say … fortunately ? Because I actually started to figure out how to write my own functions in OpenOffice using Visual Basic For Applications, aka VBA. And at the end of the day I know how to do this and probably write many more functions in the future.

Here is my substring function in VBA:

Function substring(str As String, start As Integer, optional n As Integer, optional delim As String) As String
  If isMissing(n) Then
      n = 1
  EndIf
  If isMissing(delim) Then
      delim = " "
  EndIf  
  out_str = ""
  cnt = 0
  Dim arr() as String 
  arr = Split(str,delim)
  For i = 0 to UBound(arr)
      If (i+1) >= start Then
          If arr(i) <> "" Then
                    cnt = cnt + 1            ' Ignore empty values
          EndIf
          if cnt <= n Then
              if cnt = n Then
                  delim = ""                ' no more delimiter needed at the end
              EndIf
              out_str = out_str & arr(i) & delim
          EndIf
      EndIf
  Next
  substring = out_str
End Function

As you probably can see it takes a string and a starting position as parameter 1 and 2, the number of words to return and the delimiter to use as optional parameter 3 and 4. Parameter 3 will be 1 as default, parameter 4 a white space, if not specified.

Here is an example how I now can use this function to do my data tweaking together with two of the built-in functions SUBSTITUTE and VALUE to finally achieve what I described above:

=VALUE(SUBSTITUTE(SUBSTRING(SUBSTRING(A1;2;1;” “);1;1;”%”);”.”;”,”))

would get me 6,84 in numeric format if cell A1 contains ‘+   6.84%’.

So far, so good. How to get such a function into OpenOffice Calc ?

It starts with navigating to the Macro Organizer: Tools –> Macros –> Organize Macros –> OpenOffice.org Basic

From here I select “My Macros” –> “Standard” –> “Module1” and then click the Edit button. An IDE for VBA opens allowing me to paste in the code I have shown above. Done.

That IDE is quiet useful since it also allows me to do debugging, like setting breakpoints and inspecting the content of variables.

How to improve readability of some tag soup with Editplus

Today I discovered a simple trick to make very long lines of ( XML or HTML ) tags more readable using Editplus.

Here we go:

Note that the “Regular expression” feature needs to be turned on for this to work. This will add a newline to each tag closing bracket and thus convert long lines of tag soup into multiple lines where each tag has its own line of text.

I tried to achieve the same with Notepad++ but failed so far.