Sometimes we need extra logic from code using Objective-C Category, but Category doesn’t support adding attributes.

Objective-C Associative References is a recure.

let’s see a example

AFHTTPClient.h
1
2
3
4
5
@interface AFHTTPClient (Logging)

@property (readonly, nonatomic) AFHTTPClientLogger *logger;

@end
AFHTTPClient.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#import "<objc/runtime.h>"

@implementation AFHTTPClient (Logging)

static char AFHTTPClientLoggerObject;

- (AFHTTPClientLogger *)logger {
    AFHTTPClientLogger *logger = objc_getAssociatedObject(self, &AFHTTPClientLoggerObject);
    if (logger == nil) {
        logger = [[AFHTTPClientLogger alloc] initWithBaseURL:self.baseURL];
        objc_setAssociatedObject(self, &AFHTTPClientLoggerObject, logger, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    }

    return logger;
}

@end

This code is copied from https://github.com/jparise/AFHTTPClientLogger

  1. define property in header file
  2. add #import "<objc/runtime.h>" at top of implement file
  3. define a getter method in implement file using objc_getAssociatedObject
  4. define a setter method in implement file using objc_setAssociatedObject

1
2
3
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;

If you want SimpleCov group coverage results, you can use

1
2
3
4
5
6
7
8
9
  SimpleCov.start do
    add_group 'Controllers', 'app/controllers'
    add_group 'Helpers', 'app/helpers'
    add_group 'Mailers', 'app/mailers'
    add_group 'Models', 'app/models'
    add_group 'Views', 'app/views'
    add_group 'Libraries', 'lib'
  end

which will helpful if your project structure is not normal.

It will looks like:

SimpleCov coverage report

I used to use wordpress, which is easy to setup, easy to use, has lot’s theme, plugins.

But as a Ruby Developer, I think I need try write blog using Ruby way or Geek way.

  1. install postfix
  2. write email content in mail.txt
1
2
3
4
5
to: SEND_TO
from: SEND_FROM
subject: SUBJECT

BODY
  1. test it out
1
sendmail -t < mail.txt
  1. then put above command at end of your command, like
1
YOUR COMMAND && sendmail -t < mail.txt
  1. if you want to the task continue after you logout remember use nohup
1
nohup YOUR COMMAND && sendmail -t < mail.txt &

First, you need download all your s3 files onto the disk we can use a tool named s3cmd

1
apt-get install s3cmd

Then you need configure it.

1
s3cmd --configure

filling you s3 credentials

sync all files

1
s3cmd -r -v sync s3://BUCK_NAME/ LOCAL_FOLDER

After done with sync, you should have all your files on the disk

Next you need mount cloudfiles to your system using cloudfures

In backspace document there is a good document telling how to do it http://www.rackspace.com/knowledge_center/article/mounting-rackspace-cloud-files-to-linux-using-cloudfuse

After mount cloudfiles to the system, the onlything left is copy all yours s3 files to this mount point.

1
cp -R S3_FOLDER CLOUDFILES_MOUNT_POINT