Saturday, December 24, 2016

#selector vs Selector

TLDR: In Swift 3, use #selector instead of Selector (see here).

The warning (No method declared with Objective-C selector 'swipedLeft:') should be your first clue that there's a problem...



If you use this code in Swift 3, the left-swipe will result in an error like this:

2016-12-24 08:15:12.645 SpriteSimpleGame[65853:2987246] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SpriteSimpleGame.GameScene swipedLeft:]: unrecognized selector sent to instance 0x7fb99e4101f0'

Worst of all, examples like this are all over the place because leaving out the colon results in a similar error.

Thanks to this answer I learned that what you want instead is this:

let swipeLeft = UISwipeGestureRecognizer(
    target: self,
    action: #selector(swipedLeft(sender:))
)

Thanks, internets!!

Friday, September 09, 2016

VNC black screen of sadness

Did you connect to your VNC server only to be greeted by a black screen of sadness? 

It happened to me not long ago and I don't know what made me try this, but here's what fixed it:

$ vncpasswd

As always, you're welcome.

Monday, June 20, 2016

Old code, new Xcode

When you download some old code from the Interwebs with such like:

[self.window addSubview:self.viewController.view];

and it runs just fine... and later you update Xcode and start getting runtime errors:

Applications are expected to have a root view controller at the end of application launch

Fortunately the fix is easy:

[self.window setRootViewController:self.viewController];

Thanks, Interwebs!!

Saturday, April 23, 2016

LED Dice!

They cost me all of my diamonds, but I think it was worth it!


Thursday, April 07, 2016

Major accomplishment

I did it!! I beat the Cheshire Cat in Yahtzee Buddies!! 


The dice are cool and all, but pretty hard to read...


I'll stick to my favorite bronze dice.

Sunday, January 10, 2016

Beach Ball!!!

I finally got my beach ball dice! Yes, I had to beat 25 different opponents in 24 hours, but it was totally worth it, right? Right? 



But here's the thing. There's a bug - at least on iOS - where the progress of your wins against different opponents isn't getting updated. So if you want to earn the beach ball dice, KEEP A LIST OF THE PLAYERS YOU BEAT (and when) and then paste that information into a help request so customer service can give you credit for your achievement, as they did do for me. Thanks, Yahtzee! 

Now here's my whole lineup of dice. I do expect this will be my final update, since the remaining locked dice involve tournaments and dice masters that are impossible to beat without spending moneys on bonus rolls. C'est la vie! 


Saturday, January 02, 2016

Yahtzee!!

My dice. Don't judge me. :-)

Friday, January 01, 2016

Swift selector argument - yes you can!

Selectors are an Objective C thing, but sometimes you have to use them in Swift.

For example, if you are calling performSelectorOnMainThread to work around the problem between GCD and UIWebView that causes hangs in stringByEvaluatingJavaScriptFromString (see here) you don't have a choice.

But how to pass an argument? I defined my selector function to take AnyObject? just as I assumed I should since withObject:AnyObject?

So tl;dr - here's what I was doing wrong. The colon at the end of the selector DOES MATTER. Well duh, of course it does, because it indicates there's an argument. Here's an example of everything working correctly...

  private func caller() {
    let arg = 42
    performSelectorOnMainThread("myfunc:", withObject: arg, waitUntilDone: false)
  }

  func myfunc(arg: AnyObject?) {
    guard let n = arg as? Int else {
      print("how did we get in this cornfield?")
      return
    }
    print("and here we are with our arg n: \(n)")
  }

...and the proof of the pudding - my, how tasty!

and here we are with our arg n: 42

I hope this saves somebody else a few hours of struggle!

Thursday, December 10, 2015

What To Wear

Because I never ever remember...
°F Just Right Too Much Not Enough
56
  • warm wicking T
  • tech long sleeve T
  • shorts
  • didn't need the hat or gloves or extra LST n/a

    Wednesday, November 25, 2015

    Handy howmany commandy

    Here's a handy little bit of... well it isn't really SQL, is it? Shell scripting and SQL*Plus, more like.

    tcsh & csh


    alias howmany "echo 'select count(*) from table;' | sqlplus -s 'xxxxxx/xxxxxx@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxxxx)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xxxxxx)))'"


    sh & bash


    alias howmany="echo 'select count(*) from table;' | sqlplus -s 'xxxxxx/xxxxxx@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxxxx)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xxxxxx)))'"

    (for ksh use either) - and then...

    $ howmany

    Enjoy!

    p.s. I'd love to add a pipe to

    sed -e '/^$/ d; s/^\s-*//g'

    but the dollar sign screws things up, at least in tcsh. Oh well!

    Wednesday, November 18, 2015

    Sunday, November 15, 2015

    Hard-to-read Podcasts

    If you use the iOS Podcasts app, you've probably had occasion to swear at the producers of a podcast for their graphics and how they translate into dark text on a dark background. It's even worse in low light.


    Well swear no more! At least not about this. It turns out there's a setting for that! Unfortunately, because this is iOS, you have to open the Settings app. Go there and choose Podcasts. And there aren't that many settings, so find this one, Custom Colors, and turn it off


    And enjoy more podcasts!

    Saturday, November 14, 2015

    Don't take checks from strangers

    I don't tend to be alarmist, but this article has an important warning... when you deposit a check, everything you write on it can go back to whoever issued it - your account number, social security number... huge identity theft problem. 

    http://www.westernjournalism.com/alert-people-are-getting-checks-in-the-mail-from-walmart-when-they-deposit-them/


    Wednesday, October 07, 2015

    Emacs cleanup

    Because I'm always needing this between tasks...
     
    ;; kill buffers visiting /scratch or /tmp files
    (defun cleanup ()
      (interactive)
      (let* (
             (n)
             (list)
             (file)
             )
        (setq list (buffer-list))
        (setq n 0)
        (save-excursion
          (dolist (elt list)
            (setq file (buffer-file-name (get-buffer elt)))
            (if (and
                 file
                 (or
                  (string-match "^/scratch/" file)
                  (string-match "^/tmp/" file)
                  )
                 )
                (progn
                  (if (kill-buffer elt)
                      (setq n (+ n 1))
                    )
                  )
              )
            )
          (message "Delete %d buffer%s." n (if (= n 1) "" "s"))
          )
        )
      )

    Wednesday, August 26, 2015

    I Repeat...

    I'm always forgetting how to repeat a command. Here's how in tcsh:

    $ repeat 9999 sh -c 'now=`date +%s` ; date > /tmp/tmp ; then=`date +%s` ; diff=`expr ${then} - ${now}` ; echo xxxxx ${diff} xxxxx ; if [ ${diff} -gt 0 ] ; then date ; fi ; sleep 15'

    (The inner command is /bin/sh, of course)

    Saturday, January 03, 2015

    Hot and Sour Matzo Ball Soup

    Ingredients:

    • Swanson Chinese hot and sour broth 
    • more broth (h&s or vegetable, optional)
    • a can or two of mushrooms
    • a scallion or two, chopped like you do
    • matzo balls, prepared as directed on the back of a can of Manischewitz matzo meal
    Note: you can use one or two boxes/cans of broth, depending on your desired broth/ball ratio. The amount of scallions & mushrooms would then tend to follow the broth.

    Instructions:

    1. Mix up the matzo ball ingredients and put them in the refrigerator.
    2. Cut up the scallion(s) and put them, along with the mushrooms, into the broth.
    3. Bring the broth and vegetables to a boil.
    4. Add the matzo balls to the boily broth.
    5. Lower the heat and simmer per the Manischewitz directions, about 30 minutes or so.

    Monday, August 04, 2014

    Listening Ports

    Here's a handy command to find out which ports are listening:

    /usr/sbin/lsof -P | sed -e '/(LISTEN)/ ! d; s/.* TCP .*:\([0-9][0-9]*\) .*/\1/' | sort -n | uniq

    And ymmv, but sudo is probably a good way to run that.

    Saturday, April 26, 2014

    Emacs Window Title

    One of those things I'll forget if I don't write it down - how to change the title of an Emacs window.

    M-x set-frame-name

    th! Stack Overflow

    Wednesday, April 23, 2014

    New cron job

    Welcome to my crontab, new cron job!

    18 * * * * ps -feww | grep -v grep | grep python | wc -l | sed -e '/^[0-4]$/ d; s/$/ pythons are running/g'

    Why? If you've ever run into the problem where python cron jobs start piling up because of abrtd, and you've restarted abrtd, this will help you keep an eye on things. Every hour on the 18 (so as not to run into one of my running python scripts) I'm counting python processes and if there are more than four, I'll hear about it.

    Friday, January 31, 2014

    Pet Peeve: "infinite number of"

    Welcome to my long list of pet peeves, "infinite number of"!!

    Why say "infinite number of monkeys" when you can just say "infinite monkeys"??