Slider 2.1 Released!

I’m happy to announce the release of Slider 2.1. The first major upgrade to Slider 2 represents a vast array of bugfixes and tweaks. The GUI has been re-worked, and a major feature has been added: the Slidebrary.

The Slidebrary allows one to save your favourite Slider 2 settings for use in other pages and projects. More than this, it allows one to import and export these settings. Start sharing!

Read on for a more comprehensive list of fixes and upgrades that have made it into this release:

Comments (3) | Trackback

Doxygen Graph Generation Issue “Error: dot: can’t open {dot file}”

Running Doxygen (1.7.4, Ubuntu 11.10) over one of the larger PHP applications we use at PANmedia, I ran into this error:

Error: dot: can't open /var/workspace/app/documentation/html/class_a_d_o_d_b___data_dict_a4ad217393b4e364e233cc70336d93ae8_cgraph.dot

Experimentation led to the following solution: switch DOT_CLEAN off, either via the Doxygen GUI (pictured) or directly in the Doxygen configuration file.

DOT_CLEANUP = NO

What does this do?

DOT_CLEANUP
If the DOT_CLEANUP tag is set to YES (the default) Doxygen will remove the intermediate dot files that are used to generate the various graphs.

I recall running into this error over a year ago (last time I used Doxygen), and it wasn’t until I stumbled onto the solution that I remembered solving it in the same way last time.

Documenting the solution here means that next time I use Doxygen after a long time away, I won’t have to repeat the process.

Comments (7) | Trackback

Facebook “Like” Button Proxy Error

While attempting to embed the Facebook “Like” button in this blog, I ran into the following error:

uncaught exception: Error: Permission denied for to get property Proxy.InstallTrigger

This was due to my failure to include meta information regarding the Facebook administrators of this site. For me, the simplest way was to insert this meta tag into the head, with USER_ID being my Facebook id.

<meta property="fb:admins" content="USER_ID"/>

To get my Facebook ID, I visited my Facebook profile page and copied the ID from the URL.

I also used Open Graph plugin for the wordpress portions of this site.

To set the og:url meta content I used

<meta property="og:url" content="http://pagesofinterest.net<?php echo $_SERVER['REQUEST_URI']; ?>"/>

And to make sure that Google+ properly handles the site, I added the following

<link rel="canonical" href="http://pagesofinterest.net<?php echo $_SERVER['REQUEST_URI']; ?>">
Comments (1) | Trackback

Excellent Online Markdown Editor

When writing readme files for Github repositories, one must use Markdown. Until I found this excellent online markdown editor with a live preview, I failed at quickly putting together basic readme files.

It’s based on WMD, the editor from the Stack Exchange sites.

Online Markdown Editor

I’ve found it very helpful, allowing me to create and update Github readme files much more quickly and with less hassle.

Comments (4) | Trackback

Extracting hex value from NSColor

Example project available on GitHub –

NSColor+Hex category available on GitHub –

This category on NSColor allows one to get or set an NSColor’s colour using hex values. Intitialising an NSColor with a hexadecimal colour:
1
2
3
4
5
6
7
8
@try {
    // Both shorthand and full forms of hexadecimal colours are accepted
    [colorWell setColor:[NSColor colorWithHex:@"#F00"]];
    [colorWell setColor:[NSColor colorWithHex:@"#Ff0000"]];
}
@catch (NSException *exception) {
    NSLog(@"%@", [exception description]);
}
It’ll throw an exception if one attempts to use a string that is not 3 or 6 characters in length, excluding the hash. Getting the hexadecimal representation of a given NSColor:
1
NSString *hexColor = [color hexColor]
This being my first Cocoa category, I’m sure it must have rough edges. Nevertheless, I have found it very useful. Below is the header for NSColor+Hex:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//
//  NSColor+Hex.h
//  CINSColor+Hex
//
//  Created by Michael Robinson on 4/12/11.
//  Copyright 2011 Code of Interest. All rights reserved.
//
 
#import <AppKit/AppKit.h>
 
@interface NSColor (Hex)
 
+ (NSColor *) colorWithHex:(NSString *)hexColor;
- (NSString *) hexColor;
 
@end
And the implementation, more verbose than I’d like but it does the job. If anyone improves on it, I’ll be happy to update this page & accept your pull request on GitHub:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
//  NSColor+Hex.m
//  CINSColor+Hex
//
//  Created by Michael Robinson on 4/12/11.
//  Copyright 2011 Code of Interest. All rights reserved.
//
 
#import "NSColor+Hex.h"
 
@implementation NSColor (Hex)
 
 
+ (NSColor *) colorWithHex:(NSString *)hexColor {
 
    // Remove the hash if it exists
    hexColor = [hexColor stringByReplacingOccurrencesOfString:@"#" withString:@""];
    int length = (int)[hexColor length];
    bool triple = (length == 3);
 
    NSMutableArray *rgb = [[NSMutableArray alloc] init];
 
    // Make sure the string is three or six characters long
    if (triple || length == 6) {
 
        CFIndex i = 0;
        UniChar character = 0;
        NSString *segment = @"";
        CFStringInlineBuffer buffer;
        CFStringInitInlineBuffer((CFStringRef)hexColor, &buffer, CFRangeMake(0, length));
 
 
        while ((character = CFStringGetCharacterFromInlineBuffer(&buffer, i)) != 0 ) {
            if (triple) segment = [segment stringByAppendingFormat:@"%c%c", character, character];
            else segment = [segment stringByAppendingFormat:@"%c", character];
 
            if ((int)[segment length] == 2) {
                NSScanner *scanner = [[NSScanner alloc] initWithString:segment];
 
                unsigned number;
 
                while([scanner scanHexInt:&number]){
                    [rgb addObject:[NSNumber numberWithFloat:(float)(number / (float)255)]];
                }
                segment = @"";
            }
 
            i++;
        }
 
        // Pad the array out (for cases where we're given invalid input)
        while ([rgb count] != 3) [rgb addObject:[NSNumber numberWithFloat:0.0]];
 
        return [NSColor colorWithCalibratedRed:[[rgb objectAtIndex:0] floatValue] 
                                         green:[[rgb objectAtIndex:1] floatValue] 
                                          blue:[[rgb objectAtIndex:2] floatValue] 
                                         alpha:1];
    }
    else {
        NSException* invalidHexException = [NSException exceptionWithName:@"InvalidHexException"
                                                                   reason:@"Hex color not three or six characters excluding hash"                                    
                                                                 userInfo:nil];
        @throw invalidHexException;
 
    }
 
}
 
- (NSString *) hexColor {
     if ([[self colorSpaceName] isEqualToString:NSCalibratedWhiteColorSpace]) {
        return [NSString stringWithFormat:@"#%0.2X%0.2X%0.2X",
            (int)(r * [self whiteComponent]),
            (int)(g * [self whiteComponent]),
            (int)(b * [self whiteComponent])];
    }
    else if ([[self colorSpaceName] isEqualToString:NSCalibratedBlackColorSpace]) {
        return [NSString stringWithFormat:@"#%0.2X%0.2X%0.2X",
            (int)(r * [self blackComponent]),
            (int)(g * [self blackComponent]),
            (int)(b * [self blackComponent])];
    }
    else if ([[self colorSpaceName] isEqualToString:NSCalibratedRGBColorSpace]
             || [[self colorSpaceName] isEqualToString:NSDeviceRGBColorSpace]) {
        return [NSString stringWithFormat:@"#%0.2X%0.2X%0.2X",
            (int)(r * [self redComponent]),
            (int)(g * [self blueComponent]),
            (int)(b * [self greenComponent])];
    }
    return @"transparent";
}
 
@end
Comments (3) | Trackback