Skip to content

Instantly share code, notes, and snippets.

@jianhu
jianhu / ObjcCodeBeautifier
Created July 20, 2012 09:05
Applescript to beautify Objc code in Xcode
tell application "Xcode"
if (frontmost of it = false) then
return
end if
set documentList to source document of it
set listLength to count of documentList
if listLength is less than 1 then
return --no opened source file in working space
end if
@jianhu
jianhu / objc.cfg
Created August 17, 2012 00:49
uncustify config file for objc project
# Uncrustify 0.58
newlines = auto
input_tab_size = 4
output_tab_size = 4
string_escape_char = 92
string_escape_char2 = 0
tok_split_gte = false
indent_columns = 4
indent_continue = 0
indent_with_tabs = 0
db := openDB()
defer closeDB(db)
stmt, err := db.Prepare("INSERT INTO book(title,author,content,createdtime) VALUES($1,$2,$3,$4)")
if err != nil {
return err
}
_, err = stmt.Exec(b.Title, b.Author, b.Content, b.CreatedTime)
if err != nil {
return err
}
UPDATE table SET field='C', field2='Z' WHERE id=3;
INSERT INTO table (id, field, field2)
SELECT 3, 'C', 'Z'
WHERE NOT EXISTS (SELECT 1 FROM table WHERE id=3);
@jianhu
jianhu / gist:81b5bb2cf036fd125969
Created July 6, 2015 03:22
alcatraz compatibility fix when overtime upgrading Xcode
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add `defaults read /Applications/Xcode.app/Contents/Info.plist DVTPlugInCompatibilityUUID`
@jianhu
jianhu / objc block
Created July 9, 2015 09:53
objc block syntax
How Do I Declare A Block in Objective-C?
As a local variable:
returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};
As a property:
@property (nonatomic, copy) returnType (^blockName)(parameterTypes);
As a method parameter: