-
使用Alcatraz管理Xcode插件
Alcatraz是一个帮你管理Xcode插件、模板以及颜色配置的工具。它可以直接集成到Xcode的图形界面中,让你感觉就像在使用Xcode自带的功能一样。安装mkdir -p ~/Libray/Application\ Support/Developer/Shared/Xcode/Plug-inscurl -L http://git.io/lOQWeA | tar xvz -C ~/Library/Application\ Support/Developer/Shared/Xcode/...…
-
git对象模型
SHA所有用来表示项目历史信息的文件,是通过一个40个字符的(40-digit)“对象名”来索引的,对象名看起来像这样: 78fesc4664981e4397625791c8ea3bbb5f2279a3你会在Git里到处看到这种“40个字符”字符串。每一个“对象名”都是对“对象”内容做SHA1哈希计算得来的,(SHA1是一种密码学的哈希算法)。这样就意味着两个不同内容的对象不可能有相同的“对象名”。这样做会有几个好处: Git只要比较对象名,就可以很快的判断两个对象是否相同。 因为在...…
-
Django实践:自定义用户系统
扩展Django的用户系统有几个方法: 1.在自定义Model中使用OneToOneField的方式来扩展,实现一个User Profile。这种方式在1.5之前是推荐的,在User也有一个默认的get_profile方法来获取这个profile。这种方式的好处是1.5以前的版本默认支持,并且对Django的影响最小,坏处主要是获取资料的时候需要一次join表。示例代码如下: class UserProfile(models.Model): user = models...…
-
自动布局
AutoLayout是一种基于约束的,描述性的布局系统。 item1.attribute1 = multiplier * item2.attribute2 + constant + (id)constraintWithItem:(id)item1 attribute:(NSLayoutAttribute)attribute1 relatedBy:(NsLayoutRelation)relation ...…
-
Eclipse工程导入到Android Studio
1、首先升级ADT到最新版本 2、选择需要从Eclipse导出的工程,右键选择Export并选择Android下的Generate Gradle Build Files 如图所示: 3、选择完毕后并不会导出到其他地方,而是在本地工程生成一个build.gradle文件,在Eclipse工程中也可以看到,这个文件是Android Studio识别的,如图所示: 4、随后进入Android Studio并选择Import Project,可以看到刚刚在Ecli...…
-
宏定义
对象宏#define M_PI 3.1415926535double r = 1.0;double circlePerimeter = 2 * M_PI * r;// => double circlePerimeter = 2 * 3.1415926535 * r ## 函数宏#define FUNC(x) xNSLog(@"Hello %@", FUNC("world");// => NSLog(@"Hello %@", "world");…
-
Swift---泛型(Generics)
泛型使您能够编写灵活的、可重用的功能和类型的代码。 例如要交换两个变量值的问题不用泛型//Int类型交换func swapTwoInts(inout a: Int, inout b: Int){ let temp = a a = b b = temp}var someInt = 3var anotherInt = 107swapTwoInts(&someInt, &anotherInt)println("someInt is now \(someInt), and ...…
-
Swift基础---Assertions
let age = -3assert(age >=0, "A person's age cannot be less than zero")// this causes the assertion to trigger, because age is not >= 0…
-
Swift基础---类型别名
如何定义typealias AudioSample = UInt16var maxAmplitudeFound = AudioSample.min //0…
-
Swift基础---Tuples
声明let http404Error = (404, "Not Found")// http404Error is of type (Int, String),// and equals (404, "Not Found") 使用let (statusCode, statusMessage) = http404Errorprintln("The status code is \(statusCode)")// prints "The status code is 404"printl...…