Wednesday, October 29, 2014

ComPtr for Visual Studio 2010

If you aren't using Visual Studio 2010, then you might like to use this class if your doing C++ and COM:

template <typename T>
class AutoPtr {
private:
    T* FData;
    
public:
    AutoPtr(T* Value) {
        FInterface = Value;
    }
    
    ~AutoPtr() {
        if (FData != NULL) {
            FInterface->Release();
        }
    }
    
    operator T* () const {
        return FInterface;
    }
    
    T&amp; operator* () const {
        return *FInterface;
    }
    
    T* operator->() const {
        return FInterface;
    }
    
    T** operator&() {
        return &FInterface;
    }
    
    T* operator=(const T * rhs) {
        FInterface = rhs;
        return FInterface;
    }
    
    T* operator=(const IUnknown * rhs) {
        FInterface = rhs;
        return FInterface;
    }
};

Tuesday, October 28, 2014

Kaizen

Constantly improving, kaizen, is something keep on the tip of my brain. And I think you should too.

Monday, October 27, 2014

Strip Invalid Identifier Characters

I don't do much Delphi anymore (any really) but this has been hanging around in my inbox for a while so I cleaned it up. This is a simple function that is a modification of IsValidIdent to strip invalid characters from a string.

function StripInvalidCharacters(const Ident: string): string;

  function Alpha(C: Char): Boolean; inline;
  begin
    Result := TCharacter.IsLetter(C) or (C = '_');
  end;

  function AlphaNumeric(C: Char): Boolean; inline;
  begin
    Result := TCharacter.IsLetterOrDigit(C) or (C = '_');
  end;

var
  I, L: Integer;
begin
  L := Length(Ident);
  if (L > 0) and Alpha(Ident[1]) then
    Result := Ident[1];

  for I := 2 to L do
    if AlphaNumeric(Ident[I]) then

  Result := Result + Ident[I];
end;

var
  LocalVal: string;
  LocalHash: Integer;
begin
  if IsValidIdent(Value) then
  LocalVal := StripInvalidCharacters(Value)
else

Wednesday, October 22, 2014

Hamster Wheel



http://www.huffingtonpost.com/2014/09/18/hamster-wheel-standing-de_n_5837086.html

Since I'm into ergonomics a number of friends have sent me this link on the hamster wheel desk. I think it's very funny and I thought I'd share with everyone here.

In my opinion however, this is not very ergonomic. Studies have shown that holding onto the handle bars of a treadmill forces your upper body to be very static and not dynamic as you normally would when walking. This influences the dynamics of your walking in such a way that isn't natural and puts your posture in a position that you don't want. That can be applied to typing while you are walking as well. So while I think this is hilarious and I would love to actually have one I wouldn't recommend using one for long periods of time. In fact just get up and take a walk every 50 minutes for 10 minutes and you will be way better off. Also use a standing desk.

Tuesday, October 21, 2014

Simplicity

A simple design always takes less time to finish than a complex one. Maybe not always. But it should. So always do the simplest thing that could possibly work. If you find something that is complex replace it with something simple. It's always faster and cheaper to replace complex code now, before you waste a lot more time on it. Keep things as simple as possible as long as possible by never adding functionality before it is scheduled. Beware though, keeping a design simple is hard work.

Simplicity!

Monday, October 20, 2014

iBank Sucks!

Really, don't bother.

Thursday, October 16, 2014

GDB

Oh GDB. I have not much to say. You are there.

The most useful GDB command is printing a string:

(gdb)p /c *str@20

http://www.yolinux.com/TUTORIALS/GDB-Commands.html

Wednesday, October 15, 2014

Warren Buffet quotes

Warren Buffet quotes:

"It's better to hang out with people better than you. Pick out associates whose behavior is better than yours and you'll drift in that direction."

"Your premium brand had better be delivering something special, or it's not going to get the business."

Tuesday, October 14, 2014

MacBook Power Button

Do you know what's really awesome? A power button that isn't part of the keyboard. In all MacBooks without a CD the standard nice round power button has moved to where the eject key used to be. I understand the reasons, but I don't like it and I find myself pressing it when a disk is mounted and needs to be ejected. It's too easy to press besides. I would like to see Apple bring back to old round power button and add TouchID to it! Imagine, no passwords! One can hope...

Monday, October 13, 2014

Recordable Sound Modules

I love those greeting cards that make sounds. Despite the environmental impact and their expense. They're just a lot of fun. I wanted to make my own greeting card, so I started looking into it. And I ran across these recordable greeting card modules on Amazon. I put links to them at the end of this post if you're interested.



It was quite a bit of work getting one of these to work however so I figured I would give back to global intelligence and provide the list of steps that work for me (since I found almost nothing out there).

First step is a created a Windows XP VM. I used Windows XP because that is what I had. I would expect Windows 7 to work just as well if not better. Obviously you don't have to use a VM if you already have a Windows installation that you'd rather use.

I then installed the .NET runtime. Unfortunately there was one step here that I can't quite remember. I think a DLL needed to be copied.

Then I downloaded the software that comes with this card. It's called LXSoundLoader. I put it in a folder named LXSoundLoader. Here is where I think I had an issue with the .NET framework. I think a DLL needed to be in the LXSoundLoader directory. Here is a listing of the files I have in that directory:

comm.dll
Csnd.dll
dotnetfx.exe
icemsg.dll
LX_Sound_Loader.exe
MelodyConverter.dll
W55U01HidDriver.dll

Next, I got ffmpeg which is a free utility to convert mp3 files to the sampling rate the recordable sound modules requires.

Then I created a readme.txt located on the desktop of the VM with the following steps:

1. Edit file in Garage Band or Soundtrack Pro
2. Share | Export song to disk
3. Save as mp3
4. copy to vm c:\temp\file.mp3
5. open ffmpeg folder on desktop
6. run ft-prompt (this is a console for ff-prompt)
7. run:

ffmpeg -i c:\temp\in.mp3 -ar 8000 c:\temp\out.mp3

8. Open LXSoundLoader
9. run LX
10. Add file (choose output.mp3)
11. click write button

There you go. For just a little more cost than to buy a pre-recorded greeting card you can make your very own to say whatever you want. I've used them for my kids school projects, to scare people when they open a door in the house, and more recently to make a talking teapot for Halloween. It's a little tricky hooking up the module to trigger off a different switch but it is possible.

Note that below I provided two links to two different sound modules with different prices. The one that comes in a pack of three for $27 comes with one sound module programmer and three sound modules. These are meant for greeting cards with a switch that slides. It's actually quite difficult to get the card to work right and turn on when it is opened. I prefer the other one that is $9.99 for one module and one programmer, but it is more expensive. This one comes with a pushbutton and is a little easier to add your own button to trigger it another way. Enjoy!

 

Thursday, October 9, 2014

Are You Ready for Halloween

I've done some elaborate costumes in the past but last years took the cake. This is our trick-or-treat party last year. I converted our garage into the Mos Eisley Cantina from Star Wars!



We got about 30 friends to dress in the theme which made it totally awesome. This year our theme is Alice in Wonderland. Time to start your costumes since time is running out!

Wednesday, October 8, 2014

Low Cost Wireless Carriers

I used to use Verizon. They had the best coverage. It's still arguably the best with regards to coverage. Before the iPhone 4 I had a flip phone. Yup, I was a tech less tech junkie when it came to cell phones. I still use paper and pencil to balance my checkbook so maybe calling me a tech junkie is a bit of an overstatement. Anyway, I digress. After my contract expired, Verizon had decided unlimited data customers weren't something they wanted, can't blame them I suppose, and I couldn't get a subsidized upgrade. In fact, buying an out of contract Verizon iPhone wasn't possible unless it was used. We went round and round Verizon and I. Verizon iPhones also don't resell for as much as GSM phones. So I switched. Good riddance. After analyzing how much I really call or how much mobile data I really use a low cost carrier was looking real good. So I started using Consumer Cellular. They sit on the AT&T network, have LTE, you are in no contract, pay for what you use, bump up or down the plan as needed. Anyway, that's what I use, and they now have the iPhone 6!

Tuesday, October 7, 2014

Are Computers Making Us Dumb?

Interesting article on Yahoo about a new book that I have nothing to do with but is a subject that I've often thought of. I remember my Father and Grandfather teaching me to use a slide rule but I thought a calculator was way easier. In calculus and other higher maths many students would be fumbling with their graphic calculators trying to figure things out hoping the calculator being a TI 92 would somehow make them smarter. I think I'll be picking up this book. That is, I'll probably buy the Kindel version! Oh the irony.

http://finance.yahoo.com/news/computers-are-making-us-dumb--nicholas-carr-140449209.html?.tsrc=applewf

Monday, October 6, 2014

iOS Feature Requests

1. I Would like to be able to print an envelope from Address Book / Contacts. I use a 3rd kart app, but it isn't the same.

2. I would like to be able to see the date and time of the last time I edited the Contact.


3. I want to be able to email a voice mail.

4. I want the option for dictation to translate a voice mail to text so I can see at a glance what the message is about. It might be horribly wrong, but it'd still be nice rather than a list of numbers and names.

5. The changes to the keyboard with the addition of the emoticon button being added I guess is cool, but I don't use it. I'd like an option to remove it. The emoticon button is also larger than the mic button when they should be the same size.

I figured out how to remove the emoticon keyboard. Go to settings, general, and then you have to remove the emoticon keyboard.

6. Voice Dictation on iOS 8 has a few bugs since they changed to the convert to text as you dictate.

I have more but this is my short list. Maybe I'll keep updating it as time goes on.