2011-06-29

Note to self: codesigning for OS X and iOS on the command line

As a reminder for myself, here is how you can codesign an OS X application for the AppStore on the command line:

codesign -f -s "3rd Party Mac Developer Application: Your Company" -v YourApp.app
productbuild --component YourApp.app /Applications --sign "3rd Party Mac Developer Installer: Your Company" YourApp.pkg

There is a lot more to do, of course, like having the correct bundle ID set, but this speeds up codesigning, if you do not use XCode to build your application.

For iOS it is pretty similar, except you don't need the productbuild:

codesign -f -s "iPhone Distribution: Your Company" -v YourApp.app

2011-06-22

Fixing broken GNU texinfo dir file on MacPorts

Somehow, MacPorts does not seem to update the GNU texinfo dir file contained in /opt/local/share/info. But there is a nice script available in the ctan, which generates a new dir file. You can download it here.

2011-06-08

Saving matplotlib plots as PDF

I recently started using matplotlib together with PyQt, and I love it. It's awesome and has many more features compared to PyQWT. However, I needed to save the plots to a PDF file. Here is how you do that:
import matplotlib.backends.backend_pdf
...
   @QtCore.pyqtSlot()
   def printPlots(self):
      filename,_ = QtGui.QFileDialog.getSaveFileName(self, "Save plots as PDF file", "", "Portable Document File (*.pdf)")
      if filename == "":
         return
      pp = matplotlib.backends.backend_pdf.PdfPages(filename)
      pp.savefig(self.plotFigure)
      pp.close()

Assuming that your figure is called self.plotFigure. You can connect the above slot to a QAction and map it to some nice menu item or shortcut.

2011-05-19

Is "not None" maybe "Something"?

I just had a funny thought. In Python you can write:

if not someObject is None:
    someObject.doSomething()
else:
    print "someObject is None!"

This reads a bit strange. So what if you could alias "not ... is None" to "... is Something"?

if someObject is Something:
    someObject.doSomething()
else:
    print "someObject is None!"

It seems that this idea was thought of almost eight years ago already. This lead to some PEP 0326, which got rejected. If Python were a macro or functional language, you could probably hack something up to do the same thing, but it does not work like that:

>>> Something = not None
>>> Something
True
>>> A = [1,2,3]
>>> if A is Something:
...     print "This is something"
... else:
...     print "This is nothing"
... 
This is nothing
>>> 

The problem here being, that "non None" is immediately evaluated to "True", since "None" can be implicitly converted to "False" in a boolean sense. Was a funny thought, though.

Update: Turns out you can at least write "if someObject is not None:", which is more readable.

2011-05-02

Static Libraries in XCode 4

Someone at Carbon Five posted a nice article about XCode 4 and using external dependencies. For XCode 3, I already know how to use direct dependencies and static libraries. The above article seems pretty well explained, though I have not yet tested it. I will try to give some feedback once I have the time to try it myself.

2011-02-25

Direct Dependencies in iOS projects

I found a nice blog entry that explains how to build static libraries and dependent projects with XCode. This is quite nice for iOS development, and relatively elegant. The only thing that bothers me is that the search path for headers has to be augmented manually. I wonder if there is a nice solution...

2011-02-19

Controlling MPD with the iPhone

I just installed mpd on an OpenWRT router. It works great and I can recommend using MPoD for controlling it. The whole thing looks like this then: