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!!
My thoughts on food, technology, politics, running and... nope, those are the only thoughts I've got!
Monday, June 20, 2016
Saturday, April 23, 2016
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
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
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 |
| 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.
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)))'"
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!
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
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"))
)
)
)
;; 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:
Instructions:
- 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
Instructions:
- Mix up the matzo ball ingredients and put them in the refrigerator.
- Cut up the scallion(s) and put them, along with the mushrooms, into the broth.
- Bring the broth and vegetables to a boil.
- Add the matzo balls to the boily broth.
- 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
M-x set-frame-name
th! Stack Overflow
Wednesday, April 23, 2014
New cron job
Welcome to my crontab, new cron job!
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.
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"??
Why say "infinite number of monkeys" when you can just say "infinite monkeys"??
Tuesday, January 28, 2014
Solaris TAR with Excluded Directories
It's been a long time since I had to use Solaris, and tar is bad enough without the differences between Linux and my previously favorite Unix!
$ tar cfX - /tmp/excludes . | gzip > ~/excluded.tgz
where /tmp/excludes looks like this:
./sub1
./sub2
./sub3
So it's not just a list of what's excluded, it's starting with the dot!
hattip: thank you, My Couple Of Cents!!
$ tar cfX - /tmp/excludes . | gzip > ~/excluded.tgz
where /tmp/excludes looks like this:
./sub1
./sub2
./sub3
So it's not just a list of what's excluded, it's starting with the dot!
hattip: thank you, My Couple Of Cents!!
Saturday, November 02, 2013
Android SQLite queries and numeric predicates
The typical code for making an Android SQLite query goes something like this:
Uri uri = MyProvider.URI;
String[] projection = ...;
String where = COLUMN_NAME + "=?";
String[] whereArgs = new String[] { someValue };
String sortOrder = SORT_COL + " " + sortDir;
Cursor c = getContentResolver().query(uri, projection,
where, whereArgs, sortOrder);
Uri uri = MyProvider.URI;
String[] projection = ...;
String where = COLUMN_NAME + "=?";
String[] whereArgs = new String[] { someValue };
String sortOrder = SORT_COL + " " + sortDir;
Cursor c = getContentResolver().query(uri, projection,
where, whereArgs, sortOrder);
But what if someValue isn't a String? What if you want to query your database on a numeric column? I was bashing my head against this and getting wrong results until I stumbled onto the suggestion that the "?" argument needs to be converted to a number. How to do it? Just add zero.
long someValue = ...;
Uri uri = MyProvider.URI;
String[] projection = ...;
String where = COLUMN_NAME + "=(?+0)";
String[] whereArgs = new String[] { Long.toString(someValue) };
String sortOrder = SORT_COL + " " + sortDir;
Cursor c = getContentResolver().query(uri, projection,
where, whereArgs, sortOrder);
String[] projection = ...;
String where = COLUMN_NAME + "=(?+0)";
String[] whereArgs = new String[] { Long.toString(someValue) };
String sortOrder = SORT_COL + " " + sortDir;
Cursor c = getContentResolver().query(uri, projection,
where, whereArgs, sortOrder);
You have to pass your selection arguments as an array of strings, so you'll use toString for that. But the query itself can use an addition operation to convert the string argument to a number. See the "+0" in the where string? That's it.
Maybe there's another, even better way, but this solved my problem - my queries now return just what they're supposed to. All you need is plus.
Subscribe to:
Posts (Atom)








