a-bronx
a-bronx

This is why your Internet is slow. And it’ll get worse. Unless you take 1 min to do this, now.

a-bronx

TMI

"Too Much Information" actually means "My Brain Is Too Small For it".

a-bronx

Christmas song

a-bronx
a-bronx

Craaaaazy

a-bronx
I just took the 2012 election quiz and found that I side the most with Libertarian presidential candidate Gary Johnson. Who do you side with?
Zoom picture

I just took the 2012 election quiz and found that I side the most with Libertarian presidential candidate Gary Johnson. Who do you side with?

a-bronx

Code indentation and alignment

There are 4 code tabulation styles widely known (and this topic still generates flames):

1) no TABs, only SPACEs. Pros: code layout does not depend on a chosen TAB size. Cons: it is easy to screw proper indentation with a BACKSPACE; it is annoying to hit BACKSPACE 4 times instead of once (given tabsize = 4)

2) TABs are everywhere. Pros: easy and strict; you cannot screw indentation because it is always aligned to a grid Cons: changing tab size may produce weird result when TABs are used for alignment in a middle of a line

3) random mix of SPACEs and TABs. Pros: none. Cons: this approach is a pure evil.

4) TABS are for indentation level only, SPACEs are for alignment. Pros: same as in styles 1 and 2 — no dependence on tab size, easy, strict. Cons: unfortunately, code editors usually supports either style 1, or style 2, so you cannot just use TAB key everywhere and expect that your editor will be smart enought to replace TABs to SPACEs in proper places. At least, in VisualStudio it is so. May be other code editors are smarter?

I personally prefer TABS over SPACES, and, when coding alone, I just use the style 2. The “tab size problem” does not bother me because I just never use garbage editors/viewer which are not capable to configure the tab size.

In a team, I have to adapt to those members who still use the shitty Notepad and suffer from the “tab size problem”. On the other hand, I don’t want to lose all benefits of TABs, so I’d prefer to use style 4: TABs for indentation, SPACEs for mid-line alignments. Code editors are the only stoppers here.

So, what can we do at least for a VisualStudio Code Editor? Fortunately, there is a trick: you can use a combination of three commands:


>Edit.SelectAll
>Edit.ConvertTabsToSpaces
>Edit.TabifySelectedLines

So, you can use TABs for editing everywhere, and then, before committing the file, just run there 3 command in the VS Command Window. Command names are almost self-describing:

  1. Edit.SelectAll selects the whole code text
  2. Edit.ConvertTabsToSpaces converts all TABs to SPACEs
  3. Edit.TabifySelectedLines converts SPACEs back to TABs, but works only on leading SPACEs! That’s the trick.

Unfortunately, the solution is not ideal: it replaces all leading SPACEs to TABs, though there are cases when you should not do it. For example, if you break a long function parameter list into several lines, you’re actually staying on the same indentation level and want the parameter list be adjusted, not indented. Improving the algorithm will require source code parsing to find cases when a new line does not introduce a new indentation level.

Anyway, we still have a quite decent solution. But typing these commands again and again is unproductive. If you find yourself repeating — write a script. So it is better to translate these commands to a macro:


Public Module Editor
    Sub TabifyAll()
        Dim curPoint As VirtualPoint
        curPoint = DTE.ActiveDocument.Selection.ActivePoint
        DTE.ActiveDocument.Selection.SelectAll()
        DTE.ExecuteCommand("Edit.ConvertTabsToSpaces")
        DTE.ActiveDocument.Selection.Tabify()
        DTE.ActiveDocument.Selection.MoveToPoint(curPoint)
    End Sub
End Module

Now we can add the macro as a menu command, assign a keyboard shortcut for it, etc. I’ve put this command into “Edit” menu as a “&Tabify” menu item, so I can use “Alt-E,Alt-T” shortcut.

Also it is possible to write a similar macro which will “tabify” only a text selection instead of the whole file, but actually I don’t think it makes a lot of sense: you usually want to keep style consistent over the whole document (and even over a whole project/solution/workspace), not just a small selection. I’d prefer a script which performs this action automatically upon a file save. May be someone will write a VS extension for this, someday…

a-bronx

First Orbit - the movie (by firstorbit)

a-bronx
calamitiesofnature:

People have been stealing my artwork from this comic for their own purposes. To fight this I’m trying to share my original as widely as possible. In the spirit of the season, based on the number of page views I can get, I will be donating to Doctors Without Borders (see my site for more details). So please help me by sharing this comic, thanks!
Zoom picture

calamitiesofnature:

People have been stealing my artwork from this comic for their own purposes. To fight this I’m trying to share my original as widely as possible. In the spirit of the season, based on the number of page views I can get, I will be donating to Doctors Without Borders (see my site for more details). So please help me by sharing this comic, thanks!

a-bronx
iwdrm:

“Mr. President, I’m not saying we wouldn’t get our hair mussed. But I do say no more than ten to twenty million killed, tops.”

Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb (1964)

iwdrm:

“Mr. President, I’m not saying we wouldn’t get our hair mussed. But I do say no more than ten to twenty million killed, tops.”

Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb (1964)

9,888 notes Reblogged from iwdrm
a-bronx
iwdrm:

“Viddy well, little brother. Viddy well.”

A Clockwork Orange (1971)

iwdrm:

“Viddy well, little brother. Viddy well.”

A Clockwork Orange (1971)

11,811 notes Reblogged from iwdrm
a-bronx
iwdrm:

“Micro-changes in air density, my ass.”

Alien (1979)

iwdrm:

“Micro-changes in air density, my ass.”

Alien (1979)

3,544 notes Reblogged from iwdrm
a-bronx
“Tau day …! Time to eat TWICE as much Pi! :)” Top commenter on http://youtu.be/jG7vhMMXagQ
a-bronx

Happy Tau Day!

What is it?

What it sounds like?

What it tastes like?