1. Install “Virtual Machine Manager” (VMM)
2. Create an ubuntu VM in it
3. Bash in ubuntu, mount a share from NAS share folder:

//192.168.1.200/backups /backups        cifs    username=<backup_user_name>,password=<backup_user_password>,iocharset=utf8,sec=ntlm,vers=1.0  0  0

Make sure your mount point (/backups in this case) exists before you do it.

4. Setup rsync command:
Since NAS share folder has different permission model with Linux, this command will work:

rsync -rvh --size-only --progress --delete --password-file=<path_to_password_file> <username>@<server_host>::<folder> ./<folder> --port <port> --exclude-from=exclude.txt

5. Add rsync command into crontab to run it automatically.

Enjoy.


perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

Solution:

vim /etc/environment

Append:

LC_ALL=en_US.UTF8
LANG=en_US.UTF8

And reboot your machine.

Symptoms:

Traceback (most recent call last):
File "./gitinspector.py", line 25, in
localization.init()

File "/Users/nocoo/Downloads/gitinspector-0.3.2/gitinspector/localization.py", line 43, in init
lang = locale.getlocale()

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 530, in getlocale
return _parse_localename(localename)

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 443, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename

Solution:
unset LANG
env | grep LC_
export LC_CTYPE="UTF-8"
env | grep LC_

Document:

// Adds a photo to the saved photos album.  The optional completionSelector should have the form:
//  - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;
func UIImageWriteToSavedPhotosAlbum(image: UIImage!, completionTarget: AnyObject!, completionSelector: Selector, contextInfo: UnsafeMutablePointer<()>)

But what you need to do like this:

@IBAction func onSave(sender: AnyObject) {
    UIImageWriteToSavedPhotosAlbum(self.image.image, self, Selector("image:didFinishSavingWithError:contextInfo:"), nil)
}

func image(image: UIImage, didFinishSavingWithError error: NSErrorPointer, contextInfo: UnsafePointer<()>) {
    dispatch_async(dispatch_get_main_queue(), {
        UIAlertView(title: "Success", message: "This image has been saved to your Camera Roll successfully", delegate: nil, cancelButtonTitle: "Close").show()
    })
}

String+md5.swift

import Foundation

extension String {
    func MD5() -> String {
        let data = (self as NSString).dataUsingEncoding(NSUTF8StringEncoding)
        let result = NSMutableData(length: Int(CC_MD5_DIGEST_LENGTH))
        let resultBytes = UnsafeMutablePointer(result.mutableBytes)
        CC_MD5(data.bytes, CC_LONG(data.length), resultBytes)

        let a = UnsafeBufferPointer(start: resultBytes, length: result.length)
        let hash = NSMutableString()

        for i in a {
            hash.appendFormat("%02x", i)
        }

        return hash
    }
}

Bridge.h

#import