Apple Developer Program improvements

Apple has made some big changes to their developer programs, which I think are a big improvement:

1) You can now apparently develop and deploy to your own iOS device without a program membership. (Possibly only with Xcode 7, I’m not perfectly clear yet). This is a big win for casual developers and people just getting started.

2) There is now a single developer program combining iOS and OS X which is much simpler and cuts the price in half if you subscribe to both

3) The safari extension program is being merged in. This possibly isn’t so great if you were solely doing safari extensions, because now you may need to pay. But if you are doing other development anyway, then it’s a simplified approach (only one program to deal with and remember to renew)

Overall big changes and a strong improvement in most areas.

I’m also hopeful about the new OS versions too.

 

Posted in General, Macintosh, Writing Software | Leave a comment

New Bujold Book!

Wonderful news: Lois McMaster Bujold, one of my favourite authors, has announced a new novel, due sometime in 2016.

If you haven’t read Bujold, I strongly recommend going out, getting a copy of one of them and reading it right now (or you know, when the bookstore or library are next open)

The title will apparently be Gentleman Jole and the Red Queen.

Author Blog Link

Posted in books | Leave a comment

Updating wordpress plugins via svn:externals

WordPress usually needs plugins for things, but it’s a pain keeping them updated, unless you want to use the built in auto-updating (which I don’t use for various reasons)

That was until I discovered this method of using svn:externals to update them.[kovshenin.com]

cd public_html/wp-content/
svn propedit svn:externals plugins
<edit as required>
svn update

By adding third party plugins to the plugins directory svn:externals list, they all get updated at the same time as I update the wordpress install, which I already use subversion for anyway. The akismet plugin already gets updated by this method. It also allows changes to the version of the akismet plugin, which is good if it gets updated between major WordPress releases.

Posted in General | Leave a comment

MOD releasing open source stuff

MoD releases code to GitHub

Well done to the Defence Science and Technology Laboratory at the UK ministry of Defence. They’ve started to release code on github.

I can’t imagine that getting approval for this was easy, and it probably required a fair amount of negotiation to get this far; but it’s a good sign for openness in government and hopefully it will be a good thing for both the government and the wider community.

Given that governments aren’t trying to make money selling software, open source seems an excellent fit. Hopefully we’ll see more stuff from them. (I imagine not the classified things though!)

Posted in General | Leave a comment

Prison Architect

I’ve been playing Prison Architect recently, having picked it up in a Humble Bundle deal.

Interesting idea and great fun. Plus not so lifelike that I would be uncomfortable playing.

 

Posted in General | Leave a comment

Is Yosemite going to be released today?

October 16th has arrived, the Apple event is scheduled. Will this be the official release date of Yosemite? Enquiring minds want to know…

update: yes it looks like it will be

Posted in Macintosh | Leave a comment

Google XSS game

http://xss-game.appspot.com/

It teaches a bit about Cross-site scripting (XSS) bugs that, as the page helpfully describes, are one of the most common and dangerous types of vulnerabilities in web apps.

Worth checking, even if you think you know the material.

Posted in General | Leave a comment

Webkit Javascript Optimizing JIT compiler(s)

Is your JIT compiled javascript function running too slow?
No worries, just wait and the javascript engine will recompile it and then replace the function with a faster version!

But that’s not fast enough either?
Webkit will compile another version using more optimizations, using code from LLVM.

Is the function still executing some long running loop?
No problem! The javascript engine will copy all of the current state and build a new compiled function that starts at the beginning of that loop, then replace the old slower function with the new one, while it is still running!
It gets flipped over at the beginning of the next run through the loop.
(see the Hot-Loop Transfer section of the original article)

Just from the description, this sounds stupendously complicated. But the performance improvements are apparently quite considerable.

I’m truly impressed by the effort that goes in and the work that’s been done on this.

🙂

Read the original post for the full details:
https://www.webkit.org/blog/3362/introducing-the-webkit-ftl-jit/

 

Posted in Internet Stuff, Macintosh, Writing Software | Leave a comment

SQLEditor 2.7 – the customizable object palette

The newest and latest feature to arrive in SQLEditor 2.7 [55MB Zip] is a customizable object palette.

For a long time, the object palette in SQLEditor has looked like this:

Old Palette (pre 2.7)

There were three fixed objects, that could be dragged from the palette into the document. The images have changed, but the basic functionality is little changed from v1.0, which also had a three object palette that worked like this.

In version 2.7 though, there is a new palette, that initially looks like this:

New palette in default mode

It doesn’t look that much different at first, however it’s much more than it used to be.
The biggest change is that you can now add your own items to the palette.
To add an object, you can hold option (alt) and drag it to the palette.

alt+drag

SQLEditor create a new palette item, with a small preview of the objects. You can rename the item by double clicking on the label. Or delete it by right clicking and choosing delete.

You can also add palette items from the clipboard. Add items to the clipboard using the normal cut or copy commands, then click on the small gear icon in the bottom left to see a menu. The New from clipboard command adds the contents of the clipboard as a new palette item.

Or use the gear icon menu to add from the clipboard

You can the use the new palette item just like the default ones. The palette item contains a copy of the original objects, so you don’t need the original document they came from.

There are lots of possible uses for this, the obvious one is templates for tables. If you frequently create the same kinds of databases, you’re probably also creating the same kinds of tables.

For example, there always seems to be a “user” table, with a fairly similar set of columns. In the above example the user table has been added and now we can instantly create a user table in a single action that contains the four important columns in every user table: unique id, first name, surname and shoe size. You can also set things like table type=INNODB, or set colors and styles (although not yet object labels).
SQLEditor will save the objects and bring it out ready for use.

You can also add groups of objects, including any relationships between them.

This feature has been on the wish-list for some time, I’m glad it’s now finished and I hope that people will like it.

SQLEditor 2.7 is available now via the in-app update system or from the website:

SQLEditor 2.7 [55MB zip, 10.6.8+]

Posted in Macintosh, SQLEditor | Leave a comment

Teddy the Guardian – a smart toy and medical sensor device

I just saw details of this new stuffed/plush toy bear that contains medical sensors, which seems absolutely wonderful as an idea.

The idea is that instead of having to persuade a child patient to put up with various medical devices and sensors (like thermometers or heart rate sensors), the child just hugs a small toy bear, which contains the sensors. The data is sent wirelessly to a computer device that the doctor can then view.

It’s a brilliant idea and I would think that anything that makes the time children spend in hospitals a little easier is a good thing.

[Via CNet Interview]

Posted in General | Leave a comment

The Journal of Cartoon Overanalyzations

For all of your cartoon analysis needs:

http://cartoonoveranalyzations.com/

Posted in General | Leave a comment

SQLEditor 2.5 – now with native database drivers and process separation

I’m really happy to say that SQLEditor 2.5 [60MB zip] has just been released. This has some interesting new features that have been in development for some time. Native database drivers have been something I’ve been hoping to support for ages, while process separation should improve stability and performance.

Native database drivers

SQLEditor 2.5 now includes native database support bundled with the app.
Native drivers are bundled for SQLite (using standard sqlite), MySQL/Drizzle (using the Drizzle driver library) and Postgres (using Postgres client libraries).

The native drivers don’t use Java at all, which gives a marginal performance improvement. Although if you’re using SQLEditor in standard, graphical mode you probably won’t notice.

Native driver support means that SQLEditor should now be zero configuration for many users. Just install the app and start using it. This should be a big win, as opposed to finding, downloading and installing the JDBC drivers. It also gives a predictable and standard configuration to test, which should reduce bugs.

SQLEditor still supports JDBC drivers as before, but if you definitely don’t require them, the JDBC driver loading can be turned off entirely.
(Preferences->Database->Database Options->Enable Java (JDBC) Driver Support)

Database process separation

SQLEditor 2.5 now splits off database operations and anything involving Java into a separate process. This was primarily to provide more protection with native drivers, if they crash. However it also means that there is no Java VM running in the main process at all, which should make SQLEditor open an editable document faster from cold start. The worker thread is started, but can then load java separately, you don’t need to wait for this to happen.There is also better stability should JDBC driver discovery hang or crash, because this is running in a third process.

Overall there are more processes, but it doesn’t seem to make that much difference memory wise. Plus Chrome does something similar, so SQLEditor is in good company (or so I’m hoping).

The new version is available to download today:

SQLEditor 2.5 [60MB zip, 10.6+]

Alternatively the in-app updater should be offering the upgrade right now.

Upgrading via the in-app updater also reduces the download size, because, in many cases, it only downloads the changes between versions, rather than the whole app.
(thanks Sparkle)

I hope that you like the new release, if you have comments or wish to report a bug please do email at support@malcolmhardie.com 

Posted in General, SQLEditor | Leave a comment

Corporation must maximise profits (?)

I’ve had this post sitting in my drafts collection for ages, but after reading yet another person make this claim about corporations, I’ve decided to post it. I believe that my sources are correct and accurate, note that the main source now links to the internet archive, rather than the original paper, because the congressional committee site has been rearranged. Please comment or email if you have any questions or concerns.


This is something that pops up fairly frequently, the idea that corporations are required as their sole duty to maximise profits to shareholders.

While a handy tool to create a nice documentary, this statement has been described [pdf] by Professor Margaret Blair of Vanderbilt University Law School as

“… [A]t best, a misleading overstatement”. “At worst, this claim is simply false”… “There is no statutory requirement in the U.S. that corporations must maximize profits, or that directors are responsible for maximizing share value.”

“Case law ” … “also does not require share value maximization, except in one very narrow circumstance: When, in the course of buyout negotiations it becomes inevitable that a corporation will be sold” … “directors’ duties then change” … “to auctioneers charged with getting the best price for stockholders at a sale of the company”

And in other places like the UK?

“In Britain, for example, the British Companies Act 2006 explicitly codified what lawmakers believed to be the rule under their case law, which provides that directors have duties to multiple stakeholders”

So what makes directors focus on profit maximisation? Prof. Blair offers the following:

“… pressure comes from the media, from shareholder advocates and financial institutions in whose direct interest it is for the company to get its share price to go up, and from the self-imposed pressure created by compensation packages that provide enormous potential rewards for directors and managers if stock prices go up.”

NOTE: The above has been slightly edited for length. Hopefully without affecting original meaning and intention.

(Original Testimony to US House Of Representatives Committee [PDF])

Originally I found much of this from [Economic Populist: Corporate Citizen – An Oxymoron”]

This doesn’t in any sense excuse companies that behave badly. In fact it adds criticism to them; if they are NOT legally required to behave badly, why do they still continue to do so?

Posted in General | Leave a comment

Exporting SVG from Cocoa

Following from my previous post about SVG exporting in cocoa, here are some details on how this is done in SQLEditor. The example code is extracted from the live SQLEditor code base, but it’s been altered to simplify in a few places. Hopefully it doesn’t contain any bugs, but please point them out if you see them.

In addition, I don’t offer this up particularly as a tutorial, this is just the way that I did it, so there are possibly (probably?) better ways of doing this. Feel free to reuse any of it, in any way, if you wish using either BSD or Attribution 3.0 Unported . I’ll try and put a complete working example of it up on github soon. Update: Source code now on github

The key point is that SVG is just a dialect of XML. This means that we can use NSXMLDocument and friends to generate the SVG, which makes life much easier than it would be otherwise.

We use a standard NSXMLDocument

- (NSXMLDocument*)xmlDocument
{
id rootNode = [self exportToXMLNode];
id xmlDocument = [[[NSXMLDocument alloc] initWithRootElement:rootNode] autorelease];
[xmlDocument setVersion:@"1.0"];
[xmlDocument setCharacterEncoding:@"UTF-8"];
return xmlDocument;
}

The code to generate the root node looks like this:

- (NSXMLNode*)exportToXMLNode
{
    id exportNode = [NSXMLElement elementWithName:@"svg"];

	id viewBoxString = [NSString stringWithFormat:@"%.0f %.0f %.0f %.0f",imageBounds.origin.x,imageBounds.origin.y,imageBounds.size.width,imageBounds.size.height];

    [exportNode addAttribute:[NSXMLNode attributeWithName:@"viewBox" stringValue:viewBoxString]];
    [exportNode addAttribute:[NSXMLNode attributeWithName:@"width"
                                              stringValue:[NSString stringWithFormat:@"%.0f",imageBounds.size.width]]];
    [exportNode addAttribute:[NSXMLNode attributeWithName:@"height"
                                              stringValue:[NSString stringWithFormat:@"%.0f",imageBounds.size.height]]];

    id namespace = [NSXMLNode namespaceWithName:@"" stringValue:@"http://www.w3.org/2000/svg"];
    [exportNode setNamespaces:[NSArray arrayWithObject:namespace]];

    id transformGroup = [NSXMLNode elementWithName:@"g"];
    [transformGroup addAttribute:[NSXMLNode attributeWithName:@"transform" stringValue:@"translate(0.5,0.5)"]];

    [exportNode addChild:transformGroup];

    for (id entry in [self.container objectListByZOrder]) {

        if (![entry getPropertyAsBoolean:@"hidden"]) {
                id newNode = [self exportObjectToSVG:entry];

                if (newNode) {
                    [transformGroup addChild:newNode];
                }
            }

    }

	return exportNode;
}

objectListByZOrder returns an array of objects, ordered by zOrder, from back to front.

We use a transform group with an offset of (0.5,0.5) to align the image to the screen pixels. (The alternative would be to draw everything at 0.5 pixel offsets, but this is annoying)

We also use a viewBox, which is set to the value of imageBounds, a variable which contains the bounding rectangle of the objects in the document. This is already set up by the time this code is called.

getPropertyAsBoolean is part of the SQLEditor object properties system and in this case, its used to determine whether the object being drawn is hidden or not. Obviously if it’s hidden, then it doesn’t get drawn. At least one beta version of SQLEditor overlooked this fairly obvious point.  🙂

Now finally, an example object exporting section:

- (id)textElement:(NSString *)text atPoint:(NSPoint)textLocation
{
    id titleText = [MHSVGElement elementWithName:@"text"];
    id titleAttributes = [NSMutableDictionary dictionaryWithCapacity:1];
    [titleAttributes addEntriesFromDictionary:[self dictionaryForLocation:textLocation]];
    [titleAttributes setObject:@"10" forKey:@"dx"];
    [titleAttributes setObject:@"14" forKey:@"dy"];
    [titleAttributes setObject:@"black" forKey:@"fill"];
    [titleAttributes setObject:@"13" forKey:@"font-size"];
    [titleAttributes setObject:@"Lucida Grande" forKey:@"font-family"];
    [titleAttributes setObject:@"optimizeLegibility" forKey:@"text-rendering"];

    [titleText setAttributesWithDictionary:titleAttributes];

    [titleText setStringValue:text];
    return titleText;
}

- (id)rectangleElement:(NSRect)objectRect
             fillColor:(NSColor*)color
           strokeColor:(NSColor*)strokeColor
          cornerRadius:(NSUInteger)radius
{
    id mainFrame = [MHSVGElement elementWithName:@"rect"];

    id attributes = [NSMutableDictionary dictionaryWithCapacity:1];

    [attributes addEntriesFromDictionary:[self dictionaryForLocation:objectRect.origin]];
    [attributes addEntriesFromDictionary:[self dictionaryForSize:objectRect.size]];
    [attributes setObject:[NSNumber numberWithInteger:radius] forKey:@"rx"];
    [attributes setObject:[NSNumber numberWithInteger:radius] forKey:@"ry"];

    id strokeColorString = @"none";

    if (strokeColor) {
        strokeColorString = [self svgColor:strokeColor];
        [attributes setObject:@"1" forKey:@"stroke-width"];
        [attributes setObject:strokeColorString forKey:@"stroke"];
    }

    NSString* fillColorString = [self svgColor:color];

    [attributes setObject:fillColorString forKey:@"fill"];
    [attributes setObject:[NSString stringWithFormat:@"%f",[color alphaComponent]] forKey:@"fill-opacity"];

    [mainFrame setAttributesWithDictionary:attributes];

    return mainFrame;
}

- (NSXMLNode*)exportSQLCanvasAreaToSVG:(SQLCanvasArea*)object
{

    id commentGroup = [MHSVGElement elementWithName:@"g"];

    [commentGroup addAttribute:[NSXMLNode attributeWithName:@"class" stringValue:@"SQLCanvasArea"]];

    NSRect areaRect;
    areaRect.origin = [object location];
    areaRect.size = [object size];

    id mainFrame = [self rectangleElement:areaRect
                                fillColor:[self labelColorForObject:object]
                              strokeColor:[NSColor blackColor]
                             cornerRadius:5];

    [commentGroup addChild:mainFrame];

    id titleText = [self textElement:[object getName] atPoint:[object location]];
    [titleText addAttribute:[NSXMLElement attributeWithName:@"font-family" stringValue:@"Lucida Grande"]];
    [titleText addAttribute:[NSXMLElement attributeWithName:@"font-weight" stringValue:@"bold"]];

    [commentGroup addChild:titleText];

    return commentGroup;
}

Each object has a specific export<objectClass>ToSVG method, in this caseexportSQLCanvasAreaToSVG. It sets up a new group, draws the background and the title, then returns the xml element back, so it can be added to the main image.

At minimum, splitting up the drawing by object type is a good idea, probably better to have separate classes for drawing each type (possibly with some inheritance or composition)

As you can see, the text drawing section makes a number of hard coded assumptions right now. Those were chosen to match the SQLEditor default drawing styles as closely as possible. It’s not a perfect match though, due to the variation between drawing in a cocoa NSView/NSWindow vs drawing in a SVG context (usually in a browser). Fonts are something of an issue and there are issues with rendering across platforms.

Overall though, I’m quite pleased, the first phase of SVG export didn’t prove too troublesome to implement and added a useful feature to SQLEditor without either too much coding, or any extra dependencies.

Update
Example code (with minor changes) now on github: https://github.com/AngusHardie/cocoasvgexperiment

Posted in General | 2 Comments

A memorial to lab mice

Statue of a mouse knitting dna (imgur)- apparently a memorial to laboratory mice.

Regardless of opinions about lab use of animals, I think a statue remembering them is correct and proper.

Posted in General | Leave a comment

New SQLEditor database connection panel

The database connection setup panel in SQLEditor has been something I’ve been hoping to improve for a while.

This is the first attempt at a redesign:

sqleditor-new-db

 

The connections are now listed in a collapsable sidebar and can be both added and removed. You can also edit the connection in the main area. Changes are automatically saved.

It’s not ready yet, but it may appear sometime soon.

Posted in General | Leave a comment

SQLEditor, SVG and Cocoa

One of the new features in the latest SQLEditor 2.1 beta release  (v2.1.0b2, about 5.7MB) is SVG export. This allows you to create a diagram in SQLEditor and then export it to SVG format.

SVG format is a vector diagram format that can be rendered by many web browsers or edited in vector drawing programs like Inkscape.

Here is an embedded svg file:

viewbox

 

The neat thing is that if the image gets scaled it should scale fairly cleanly.
(The lines get a bit fuzzy due to the anti-aliasing)

viewbox

 

Click on the image and you should see the file displayed full size (no separate preview image!)

This should work in Chrome, Safari and Firefox. There are currently some issues with Opera which doesn’t draw the text. I think this is an error in the SQLEditor export code somewhere because I have some early test versions that do work in Opera.

I haven’t tested this with Internet Explorer, but SVG is apparently supported in v9.

I’m still fine tuning the details on this, the examples on this page were tweaked to include a defined view port so that they clip properly and don’t include a lot of white space. This should get done during the export in the next release.

I’m hoping to write another post about how SQLEditor is doing this, it proved to be fairly easy, except for the difficult bits.

 

Posted in SQLEditor | Leave a comment

Using NSDockTile for debug info

Often when I’m working on an app or something I end up running several different versions of it in a short period of time. There’s usually some bug that I’m trying to fix and I want to make sure that the bug occurs in the old version and doesn’t occur in the new version.

Sometimes though I get confused which version I’m running. Is the app in the dock the old version, or the new version or something else?

So today I had an idea: Why not put the version number on the dock tile?

Here’s the code to do it:

if (DEBUG) {
  id badgeText = [NSString stringWithFormat:@"D-%@",[[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleVersion"]];
  [[NSApp dockTile] setBadgeLabel:badgeText];
}

This assumes that you’ve got DEBUG defined somehow and that you have an infoDictionary with the relevant keys and values set.

And here’s what it looks like in the dock:

Regular version on the left, development version on the right.

I’m not sure how useful this will actually be, but it seemed a handy trick for development.

Posted in Macintosh, SQLEditor, Writing Software | Leave a comment

Xbox 360 and Playstation 3 were released before first iPhone

Xbox 360 released November 16, 2005 in USA
Playstation 3 released November 11, 2006, in Japan
Original iPhone released June 29, 2007, in USA - superseded 5 times

The consoles are still competitive platforms. Nothing in the phone world lasts that well.

This is not a criticism of the iPhone, which is a brilliant device, instead a thought about the longevity of the consoles.

Posted in General | Leave a comment

Is “Maximising Shareholder value” required – no it’s not

http://www.guardian.co.uk/sustainable-business/blog/maximising-shareholder-value-irony

The idea only dates from about 1976, it doesn’t seem to be in any law and it probably doesn’t lead to the best outcomes anyway.

Posted in General | Leave a comment