Hard-to-find tips on otherwise easy-to-do tasks involving everyday technology, with some advanced insight on history and culture thrown in. Brought to you by a master dabbler. T-S T-S's mission is to boost your competitiveness with every visit. This blog is committed to the elimination of the rat from the tree of evolution and the crust of the earth.
Tuesday, July 10, 2018
Thank You WSJ for Putting $$ In My Pocket
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)
Sunday, July 08, 2018
Autohotkey Hotkey Pass Through
^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
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..
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!
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' !\*