Wednesday 26 September 2007

OS X Terminal Keybindings

Here's my .inputrc in case I lose it again. Its from my linux setup and has way too much in it but te useful lines I need to isolate make Shift/Fn Uparrow do command completion from the history.

################################################################################
## /etc/inputrc
##
## Attempt to put different TERMs together in one readline init file.
## Copyright (c) 1997,2000,2002 SuSE Linux AG, Nuernberg, Germany.
##
## Author: Werner Fink,
##
################################################################################
#
# Eight bit compatible: Umlaute
#
set meta-flag on
set output-meta on
set convert-meta off
set term xy
#
# VI line editing
#
$if mode=vi
set editing-mode vi
set keymap vi
$endif
#
# Common standard keypad and cursor
#
"\e[1~": beginning-of-line
"\e[2~": yank
"\e[3~": delete-char
"\e[4~": end-of-line
"\e[5~": history-search-backward
"\e[6~": history-search-forward
$if term=xterm
"\e[2;2~": yank
"\e[3;2~": delete-char
"\e[5;2~": history-search-backward
"\e[6;2~": history-search-forward
"\e[2;5~": yank
"\e[3;5~": delete-char
"\e[5;5~": history-search-backward
"\e[6;5~": history-search-forward
$endif
"\e[C": forward-char
"\e[D": backward-char
"\e[A": previous-history
"\e[B": next-history
$if term=xterm
"\e[E": re-read-init-file
"\e[2C": forward-word
"\e[2D": backward-word
"\e[2A": history-search-backward
"\e[2B": history-search-forward
"\e[5C": forward-word
"\e[5D": backward-word
"\e[5A": history-search-backward
"\e[5B": history-search-forward
$else
"\e[G": re-read-init-file
$endif
#
# Avoid network problems
# ... \177 (ASCII-DEL) and \010 (ASCII-BS)
# do `backward-delete-char'
# Note: `delete-char' is maped to \033[3~
# Therefore xterm's responce on pressing
# key Delete or KP-Delete should be
# \033[3~ ... NOT \177
#
"\C-?": backward-delete-char
"\C-H": backward-delete-char
#
# Home and End
#
$if term=xterm
#
# Normal keypad and cursor of xterm
#
"\e[1~": history-search-backward
"\e[4~": set-mark
"\e[H": beginning-of-line
"\e[F": end-of-line
"\e[2H": beginning-of-line
"\e[2F": end-of-line
"\e[5H": beginning-of-line
"\e[5F": end-of-line
# Home and End of application keypad and cursor of xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
"\eO2H": beginning-of-line
"\eO2F": end-of-line
"\eO5H": beginning-of-line
"\eO5F": end-of-line
$else
$if term=kvt
"\e[1~": history-search-backward
"\e[4~": set-mark
"\eOH": beginning-of-line
"\eOF": end-of-line
$endif
#
# TERM=linux or console or gnome
#
"\e[1~": beginning-of-line
"\e[4~": end-of-line
$endif
#
# Application keypad and cursor of xterm
#
$if term=xterm
"\eOD": backward-char
"\eOC": forward-char
"\eOA": previous-history
"\eOB": next-history
"\eOE": re-read-init-file
"\eO2D": backward-word
"\eO2C": forward-word
"\eO2A": history-search-backward
"\eO2B": history-search-forward
"\eO5D": backward-word
"\eO5C": forward-word
"\eO5A": history-search-backward
"\eO5B": history-search-forward
# DEC keyboard KP_F1 - KP_F4 or
# XTerm of XFree86 in VT220 mode F1 - F4
"\eOP": prefix-meta
"\eOQ": undo
"\eOR": ""
"\eOS": kill-line
$endif
$if term=gnome
# or gnome terminal F1 - F4
"\eOP": prefix-meta
"\eOQ": undo
"\eOR": ""
"\eOS": kill-line
$endif
#
# Function keys F1 - F12
#
$if term=linux
#
# On console the first five function keys
#
"\e[[A": prefix-meta
"\e[[B": undo
"\e[[C": ""
"\e[[D": kill-line
"\e[[E": ""
$else
#
# The first five standard function keys
#
"\e[11~": prefix-meta
"\e[12~": undo
"\e[13~": ""
"\e[14~": kill-line
"\e[15~": ""
$endif
"\e[17~": ""
"\e[18~": ""
"\e[19~": ""
"\e[20~": ""
"\e[21~": ""
# Note: F11, F12 are identical with Shift_F1 and Shift_F2
"\e[23~": ""
"\e[24~": ""
#
# Shift Function keys F1 - F12
# identical with F11 - F22
#
#"\e[23~": ""
#"\e[24~": ""
"\e[25~": ""
"\e[26~": ""
# DEC keyboard: F15=\e[28~ is Help
"\e[28~": ""
# DEC keyboard: F16=\e[29~ is Menu
"\e[29~": ""
"\e[31~": ""
"\e[32~": ""
"\e[33~": ""
"\e[34~": ""
$if term=xterm
# Not common
"\e[35~": ""
"\e[36~": ""
$endif
#
$if term=xterm
#
# Application keypad and cursor of xterm
# with NumLock ON
#
# Operators
"\eOo": "/"
"\eOj": "*"
"\eOm": "-"
"\eOk": "+"
"\eOl": ","
"\eOM": accept-line
"\eOn": "."
# Numbers
"\eOp": "0"
"\eOq": "1"
"\eOr": "2"
"\eOs": "3"
"\eOt": "4"
"\eOu": "5"
"\eOv": "6"
"\eOw": "7"
"\eOx": "8"
"\eOy": "9"
$endif
#
# EMACS line editing
#
$if mode=emacs
#
# ... xterm application cursor
#
$if term=xterm
"\e\eOD": backward-word
"\e\eOC": forward-word
"\e\eOA": up-history
"\e\eOB": down-history
"\C-\eOD": backward-char
"\C-\eOC": forward-char
"\C-\eOA": up-history
"\C-\eOB": down-history
$endif
#
# Standard cursor
#
"\e\e[D": backward-word
"\e\e[C": forward-word
"\e\e[A": up-history
"\e\e[B": down-history
"\C-\e[D": backward-char
"\C-\e[C": forward-char
"\C-\e[A": up-history
"\C-\e[B": down-history
$endif
#
# end
#

Poser 7, Carrara 6 Pro, and many many silly purchases.

So I've been doing some artwork and for whatever reason felt that the upgrade of Carrara was a good idea and then Poser 7 seemed a good idea too.

Then I realised I hadnt got time to learn this stuff properly. so I bought some content from http://contentparadise.com and http://daz3d.com.
Well, I still had to spend time figuring it all out. And then once I created some stuff with it, I realised it wasnt what I wanted to do at all. dang!!
So I need to rethink my concept. I wish I knew more about these programs, I hate not knowing how to do stuff.

Mind you its handy having multiple undo in Poser. But sheesh, that interface needs sorting out.

xml bindings

So it occurs to me that after looking at some of the cocoa xml examples, I can bind the pulldown options for the search filters, directly into my xml document request.



I'm not totally clear how to do this but it looks like more interesting fun.

Background tasks

I did my first threads. Suddenly no more bouncng beach ball. Is this one of the cool features of cocoa, because I'm sure threads shouldnt have been that easy.

Praps I did something wrong.

Sunday 16 September 2007

irc macchat and guru's

Having started spending some time learning cocoa, you find yourself drawn to the a cocoa dev channel on freenode. Suddenly your back 20 years in time..

Of course you read the faq, you know you should ask a clear question and that you should include any relevant information. You know that you should google your error.
so your error is ... a generic error

You've seen this type of error before, on lots of different things. ( well you think you have and you have been reading google solid for the last 2 weeks on stuff, surely someone could just answer yes or no to the question )

So you ask..

Bad move

Read the Faq !!!!!!!

You read it, hmm nothing about this there ( you have read it before )

You post the error message which you didnt want to post before as it was a really simple "can I do this question". you didnt want to know anything more

Your question is useless

You reply in the negative, had you asked a similar question elsewhere, you know there are compatibility reasons why this might not work. Should you waste 15 minutes trawling google for the correct phrase or just ask?

Flaming continues. Google is quoted. Ah yes so there is the answer.

But all I wanted was yes or no. not a diatribe.

At times like this I wonder what the point of these channels is.
Is it
  • Here's a bunch of people who know stuff and dont mind people learning and sadly yes they will make goofy questions now and then.

  • Only ask a question if you have spent all your energy exhausting every other possibility

  • Me and my friends have a really great time and please dont ask us a question unless you know the answer already.

I'm not an irc noob. I'm not a cocoa genius. Do I need to find another channel, #cocoahelp or something because what is the point of a channel called #macdev. Is there somewhere else I should ask questions because I dont know.

and yes I should have googled. but spending 10 lines to flame someone well.. its a good job we have the manuals. and yes I have rtfm but there are quite a lot and I've been wading through them.

NB. I've been on irc years. I've been flamed, I've flamed, but I just think some people enjoy feeling superior more than being superior. I remember some channels where people just bullied others and the sad thing was other people had great stuff to say and when they weren't there it was fascinating.

This isnt a moan, its just a ... omg this is still normal!?


funnily someone didnt mind explaining what their nick meant for the 3rd time that day. perhaps it should also be in the faq

Actually the final result was very helpful, but I wonder who else might ask a 'stupid' question another time that might help me, but wouldn't. I've also had some real help in there too.

Addendum
Interestingly someone went on to ask a question that I really wanted to know the answer to, however no response. Was this because they asked if they asked the question against the FAQ rules. Noone answered, but it was really good question. I still want to know the answer.

Saturday 15 September 2007

I Trawl the Megahz

Having had a break for a long time, I pulled out my favourite album Steve McQueen, then I cant remember how but I ended up looking up to see what the Sprouts were doing. I think maybe itunes store opened by itself and I was curious to know what the new mastered version of the album was like.
I was saddened to read that Paddy McAloon had suffered a serious sight illness which resonated with myself and off I went on a google journey.

It seems I had missed about 3 albums, Andromeda Heights, plus a newer one and then the Paddy solo album.

I've bought the new version of Steve McQueen but I'm not interested in the remastered main side. The acoustic versions are great though.

Andromeda Heights, hmmm, this just seems whimsy but I might grow to like it. but I think this is what made me grow cold on the band.. not enough of the early northern edge.

I trawl the Megahz, I didnt really get this too well either but I think after a few long listens it might be a grower.


Steve McQueen remains one of my most loved albums of all time, it seems to be timeless.


I'm quite pleased to listen to Protest songs again, but its more of an addendum that it always felt like.


So one more album to try. I'm not holding out massive hope but who knows

Retain Release Revolt - Bring Me Leopard Objective c2.0

So I ripped out the Ruby and got my new project running and have been writing the methods that were done in Rubycocoa

The only trouble is.... You do an ebay search and it produces the right results. Try again and it produces nothing. Open a web address, it works. Try again it crashes.

I now have to wrap my head around memory management properly. I understand what I'm supposed to be doing but I need to go into my code and start working out where to retain/release/autorelease. Having come back from Ruby, I find myself longing for Objective C2.0.

The bit that I need to take on board is where objects are retained automatically by adding to collections and when to release the collections and create a fresh object.

It's not rocket science, but I'd prefer not to have to do that kind of thing.

Garbage Collection I <3 you.

I went to an Apple Leopard Dev event last Winter and the stuff on Objc2.0 was cool, I can't believe I'm under NDA. actually I'm not because they forgot to ask anyone to sign it, but everything I know is already on Apple's website anyway.

October can't come soon enough.

Things I'd like to see in Leopard for dev's
Easier syntax for arrays and dictionaries.
Yes its not that bad now, but Ruby is so much clearer ( like most languages )
howabout
NSArray* myarray = @( obj1, obj2, obj3 )
or
NSDictionary *mydict = @{ obj1, @"obj1", obj2, @"obj2 }

That would be nice and fast

  • CoreData connecting easily to mysql

  • Set/Get creation syntax.

  • Set/Get that works with keypaths. Then I wouldnt need to type


    [ myobject valueForKeyPath:@"path.path" ], instead I could use [ myobject.path.path ]




Stuff that we know is coming from Apple's website


  • Easier array iterators. Thats welcome. I love Rubys Array.each{| element | code }

  • Garbage Collection - yay

  • Easier accessors - yourobject.value really those []'s get a bit of a mouthful sometimes

  • Better error hiliting in xcode, yay. I love textmate, wish xcode was a bit more like that.

  • Core animation I want to do a spinner, praps this will be the best way




Update, how easy was a spinner, duh!

Thursday 13 September 2007

import xml into NSDictionary

I've spent the last few days fiddling on an NSXMLNode category that creates a method called

xmlToDictionary

+(NSDictionary) xmlToDictionary:node


You just give it an xml node and it returns a dictionary that you can query like this...


xmlDictionary = [ XMLNode xmlToDictionary:rootNode ];


value = [ xmlDictionary valueForKeyPath:@"SearchResultArray.SearchResultItem" ]



I thought when the documentation said that NSXMLNode was kvc compliant that it would do this, but it didnt mean that it meant stuff like [ rootNode valueForKey:@"children" ] which is obvious really.

I also thought there must be a way to do the above, and there still might be, but I didnt find it.

I looked at using XPath and that is a solution. I also looked at applying an XSLT sheet against the XMLDoc and using that to convert to plist format and then reading that into NSDictionary. But I dont know XSLT and thought this was an interesting method to write.

I also wrote another category method nodeForPath:(NSString*)path that does a similar job but simply parses a path like "SearchResultItemArray.SearchResultItem" and produces the value on the fly. Actually its probably better to do it like that.

I'm experimenting with native NSXMLNode methods and my own ones to see which is easier and clearer to read.

Reuse/import coredata model

So I've finished learning how to interrogate ebay using cocoa/objc and can now read the data without having to resort to ruby

So now I have my tools on how to get the data and can stop using Ruby for that side, which I wasnt too bothered about except the current rubycocoa version can't use webkit as I have installed Safari 3 and its not compatible. This is why I've been changing to writing a pure cocoa app, that and wanting to know how things work..

So now I have my cocoa ebayapi, and my original rubycocoa app, and I was trying to figure out how to take the original main menu.nib and also the original xcode coredata model, and add them to a new project. I couldnt seem to find any direct info on that, although I do get the documentation, I just wasnt sure what steps I needed.

This is what I came up with
  • 1. Create new coredata project

  • 2. Copy mainmenu.nib over the new projects mainmenu.nib

  • 3. Add File to Project and select the previous projects xcode datamodel (xcdatamodel )

  • 4. For testing, copy the xml data file from ~/Library/ApplicationSupport/oldproject/oldproject.xml to samepath/newproject/oldproject.xml

  • 5. alter project_Appdelegate.m to use the new(old) xml filename, not the default one for the new project name

  • 6. Go into the mainmenu.nib in interface builder and pull in the header file from xcode for the appdelegate, and delete the old app delegate.

  • 7. reconnect files owner to new app delegate

  • 8. change the arraycontrollers to use the new managed object context from teh app delegatge ( in their bindings )


That seems to work at the moment

I wonder if theres anything I'm missing.

And now I remember how much recursion makes my head spin.

Tuesday 4 September 2007

ebay xml ruby cocoa

So I've been trying to figure out how to take out the ruby xml stuff I've been using for ebay and change it to pure Cocoa/ObjC.
Whats nice about the api I was using is the syntax...
search_response.search_items.item.price etc

I'm trying to duplicate this in cocoa

I think the easiest way may simply be to load the xml into a nested NSDictionary
Then I can use..

search_items = [ search_response valueForKeyPath:@"search_items"]

But I also wondered about looking at soap and wdsl. Its a shame I dont have the leopard dev kit, there might be stuff in there that would be nicer.

Im pretty new to xml, and erm cocoa so its all err new..