Skip to content

Instantly share code, notes, and snippets.

View nathanclark's full-sized avatar

Nathan Clark nathanclark

View GitHub Profile
@nathanclark
nathanclark / iOSDocumentMigrator.m
Created February 21, 2012 20:43 — forked from naokits/iOSDocumentMigrator.m
Helps migrating documents between iOS <= 5.0 and >= 5.0.1 to comply with Apple's iCloud guidelines. Follow @steipete on Twitter for updates.
#include <sys/xattr.h>
/// Set a flag that the files shouldn't be backuped to iCloud.
+ (void)addSkipBackupAttributeToFile:(NSString *)filePath {
u_int8_t b = 1;
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
}
/// Returns the legacy storage path, used when the com.apple.MobileBackup file attribute is not available.
+ (NSString *)legacyStoragePath {
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
!function() {
var doc = document,
htm = doc.documentElement,
lct = null, // last click target
nearest = function(elm, tag) {
while (elm && elm.nodeName != tag) {
elm = elm.parentNode;
}
return elm;
};
# autotest your engine plugins together with your rails app
# put this .autotest file in your rails root
# see http://code.whatcould.com/2009/02/09/gentlemen-test-your-engines.html for details
# until/unless my changes are pulled into the main streams,
# there are a couple requirements:
# my autotest fork, http://github.com/whatcould/zentest/tree/master
# and for better fixture handling, my engines fork, http://github.com/whatcould/engines/tree/master
Autotest.add_hook :initialize do |at|
/*
* CodePress regular expressions for HTML syntax highlighting
*/
// HTML
Language.syntax = [
{ input : /(&lt;[^!]*?&gt;)/g, output : '<b>$1</b>' }, // all tags
{ input : /(&lt;a .*?&gt;|&lt;\/a&gt;)/g, output : '<a>$1</a>' }, // links
{ input : /(&lt;img .*?&gt;)/g, output : '<big>$1</big>' }, // images
{ input : /(&lt;\/?(button|textarea|form|input|select|option|label).*?&gt;)/g, output : '<u>$1</u>' }, // forms
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"