Skip to content

Instantly share code, notes, and snippets.

Avatar

XcqRomance XcqRomance

View GitHub Profile
@XcqRomance
XcqRomance / oclint shell.yaml
Created Jun 8, 2019
oclint 结合xcode进行代码静态检测的shell脚本
View oclint shell.yaml
# Type a script or drag a script file from your workspace to insert its path.
export LC_CTYPE=en_US.UTF-8
set -euo pipefail # 脚本只要发生错误,就终止执行
# 删除DerivedData的build文件
#echo $(dirname ${BUILD_DIR})
rm -rf $(dirname ${BUILD_DIR})
# 1. 环境配置,判断是否安装oclint,没有则安装
if which oclint 2>/dev/null; then
@XcqRomance
XcqRomance / oclint.yaml
Created Jun 8, 2019
.oclint oclint进行codereview的规则配置文件
View oclint.yaml
rule-configurations:
- key: CYCLOMATIC_COMPLEXITY # Cyclomatic complexity of a method 10
value: 30
- key: LONG_LINE
value: 110
- key: NCSS_METHOD # Number of non-commenting source statements of a method 30
value: 50
- key: LONG_VARIABLE_NAME
value: 40
- key: NESTED_BLOCK_DEPTH
@XcqRomance
XcqRomance / clang-format.yaml
Created Jun 8, 2019
clang-format代码工程格式化配置
View clang-format.yaml
---
# Language: ObjC
BasedOnStyle: Google
AccessModifierOffset: 0
ConstructorInitializerIndentWidth: 4
SortIncludes: false
# 连续赋值时,对齐所有等号
# AlignConsecutiveAssignments: true
AlignAfterOpenBracket: true
@XcqRomance
XcqRomance / UIImage Category.m
Created Dec 3, 2018
1、绘制UIImage的圆角,并且不出现离屏渲染; 2、获取启动图片
View UIImage Category.m
@implementation UIImage (CornerRadius)
- (UIImage*)cornerWithRadius:(CGFloat)radius andSize:(CGSize)size{
CGRect rect = CGRectMake(0, 0, size.width, size.height);
UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
CGContextRef ctx = UIGraphicsGetCurrentContext();
UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(radius, radius)];
CGContextAddPath(ctx,path.CGPath);
CGContextClip(ctx);
@XcqRomance
XcqRomance / removeDuplicates.c
Created Dec 3, 2018
1.从排序数组中删除重复项
View removeDuplicates.c
int removeDuplicates(int* nums, int numsSize) {
if (numsSize <= 0) {
return 0;
}
int j = 0;
for (int i = 1; i < numsSize; i++) {
if (nums[j] == nums[i])
continue;
nums[++j] = nums[i];
}
@XcqRomance
XcqRomance / maxProfit.c
Created Dec 3, 2018
2.买卖股票的最佳时机 II
View maxProfit.c
int maxProfit(int* prices, int pricesSize) {
if (pricesSize <= 0) {
return 0;
}
int profit = 0;
for (int i = 0; i < pricesSize-1; i ++) {
if (prices[i+1] > prices[i]) {
profit += prices[i+1] - prices[i];
}
View rotate.c
void rotate(int* nums, int numsSize, int k) {
if (k <= 0 || numsSize <= 0) {
return;
}
for (int i = 0; i < k; i++) {
int temp = nums[numsSize - 1];
for (int j = numsSize - 1; j >= 1; j --) {
nums[j] = nums[j-1];
}
nums[0] = temp;
View containsDuplicate.c
// 4.存在重复 方法一暴力方法
bool containsDuplicate(int* nums, int numsSize) {
if (numsSize <= 1) {
return false;
}
for (int i = 0; i < numsSize; i ++) {
for (int j = i+1; j < numsSize; j++) {
if (nums[i] == nums[j]) {
return true;
}
View singleNumber.c
// 5.只出现一次的数字
int singleNumber(int* nums, int numsSize) {
if (numsSize <= 0) {
return 0;
}
qsort(nums, numsSize, sizeof(nums[0]), cmp);
for (int i = 0; i < numsSize; i++) {
if (i == 0 && nums[i] != nums[i+1]) {
return nums[i];
} else if (i == numsSize - 1 && nums[i-1] != nums[i]) {
View plusOne.c
// 6.加一
int* plusOne(int* digits, int digitsSize, int* returnSize) {
if (digitsSize<=0) {
return digits;
}
int* ree =(int*)malloc((digitsSize)*sizeof(digits[0]));
for (int i = digitsSize-1; i >= 0; i--) {
if (digits[i] == 9) {
digits[i] = 0;
} else {