Tuesday, July 10, 2018

Thank You WSJ for Putting $$ In My Pocket

Now, don't miss out on the Sonos IPO.

These guys hit it big during the .com boom with software.com --> openWave.

Now they already have a billion a year in sales. Nice.

Also get in on Spotify. Scandinavians never disappoint. Ja?

How to Have a Happy CDE (Session)

Don't use xterm. Don't use Terminal (ddterm?)

Use gnome-terminal - if you're lucky enough that it's been installed.

Why?

Easy font adjustment with CTRL-+/-

Once you've gotten this far, you can easily set the colours to be what you want. Plus, ..

Edit > Keyboard Shortcuts > Check the box that says "Disable all menu access keys"

And now you get back ALT-f and ALT-b to edit your command on the command line :)

Sunday, July 08, 2018

Autohotkey Hotkey Pass Through

An excellent explanation (how the H are you supposed to know this without going through the documentation with a fine toothed comb? Really, the annoying 71 hotkeys received in the last 1152 ms should tell you what to do!!) by the master Johnny - of KDE drag fame..

^a::
    IfWinActive, whatever
    { 
         Send ^a
    }
    else 
    {
         Do something else
    }

Will not work. Solution, add a $ before the ^a::

That's all you have to do.

Wednesday, July 04, 2018

The Art of Pithiness by Andreas Olofsson (DARPA) - IDEA, POSH

https://www.darpa.mil/attachments/eri_design_proposers_day.pdf


IDEA does NOT seek proposals for:
Investigatory research that does not deliver useful software
• New manufacturing processes and technologies
• Architectures that simply reduce or remove the need for physical layout
• Development of high level languages, compilers, and generators for Boolean logic design

Monday, July 02, 2018

What You Want to Watch For to Ensure SOLID Code

SOLID Principles Gone Wrong

This post helps you spot bad software patterns—specifically, violations of the SOLID principles in Python code.

S — Single Responsibility Principle

One class should do one thing, and do it well.

class Report:
    def generate(self):
        return "Report content"

    def save_to_file(self, filename):
        with open(filename, 'w') as f:
            f.write(self.generate())

O — Open/Closed Principle

Software should be extendable, not modifiable, for new behavior.

class DiscountCalculator:
    def calculate(self, customer_type, total):
        if customer_type == "Regular":
            return total * 0.9
        elif customer_type == "VIP":
            return total * 0.8

L — Liskov Substitution Principle

Subtypes must be substitutable without breaking the program.

class Bird:
    def fly(self):
        print("Flying high!")

class Ostrich(Bird):
    def fly(self):
        raise Exception("Ostriches can't fly!")

I — Interface Segregation Principle

Don't force classes to implement unused methods or interfaces.

class Worker:
    def work(self):
        pass
    def eat(self):
        pass

class Robot(Worker):
    def work(self):
        print("Robot working")
    def eat(self):
        pass  # makes no sense for a robot

D — Dependency Inversion Principle

Depend on abstractions, not on concrete implementations.

class LightBulb:
    def turn_on(self):
        print("Bulb on")

    def turn_off(self):
        print("Bulb off")

class Switch:
    def __init__(self, bulb: LightBulb):
        self.bulb = bulb

    def operate(self):
        self.bulb.turn_on()

Sunday, July 01, 2018

No One Tells You What to Do.... Until Now..

Problem.. your shell bindkeys aren't working and your sys admin would rather be looking at the secretary..

Root cause - using csh - which the dinosaurs *also* deprecated in favour of bash..

So, what's a man to do?

Easy - use the "bindkey" command (csh and tcsh only)

Example, you want ALT-F to do something... instead, it prints a weird character.

So, do :

$ bindkey <now-press-ALT-F-to-get-the-weird-character> forward-word

And you're done..

Same for things like Delete key, etc..

Not helpful enough :

https://www.linuxquestions.org/questions/linux-general-1/insert-and-delete-key-returns-~-in-a-terminal-876401/

https://unix.stackexchange.com/questions/81256/tilde-when-clicking-del-key

Okay, what I've told you so far, gets you to a point - you'll find that, in an xterm session, you can do this and it'll work, but, when you try putting that in a .cshrc, you'll be in for a surprise..

bad key spec

territory :( And stackoverflow ain't much help. That's why you come here..

And the answer? Look up that funny character in the ASCII table - for example, if it's the small a with a  hat on top, take that code, get the octal representation (just go to a new tab and type 226 to octal and let google do the work :)

Then, in your .cshrc

bindkey "\342" forward-word

And you're through.  You're welcome!

csh Is the Curse of Modern Existence. Go With bash!

bash, easy :

function medit() { nedit -xrm "nedit.wordDelimiters: ,\\\`\'\!@#%^&*()-=+{}[]\":;<>?" "$@" ;}

csh, hard :  (define qq, bq, q using : setenv qq '"'  (that's single q, double q and then single q. Yes, csh sucks :)

alias medit nedit -xrm ${qq}'nedit.wordDelimiters:' ,\\\$q\\\$bq!\\@\#%\^\&\(\)=-+{}\[\]\\\$\{qq\}:\\\;\<\>\?$qq !\*

And, while you're at it, might as well thrown in the command to tell it to use bash for sub-shells that execute commands (ALT-x) :) (For those times when you'd like to do stuff like this (insert date with specific format)

alias medit nedit -xrm ${qq}'nedit.wordDelimiters:' ,\\\$q\\\$bq!\\@\#%\^\&\(\)=-+{}\[\]\\\$\{qq\}:\\\;\<\>\?$qq -xrm 'nedit.shell: bash' !\*