Skip to content

Instantly share code, notes, and snippets.

View warriorg's full-sized avatar
🏠
Working from home

warriorg warriorg

🏠
Working from home
View GitHub Profile
@warriorg
warriorg / podforceupdate.sh
Last active September 12, 2015 18:25 — forked from mbinna/podforceupdate.sh
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
@warriorg
warriorg / lineSpacing
Created September 6, 2015 03:44
UILabel UITextField调整行间距
// 设置行间距
- (void)setLineSpacing:(CGFloat)spacing label:(UILabel *)label
{
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:label.text];
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:spacing];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [label.text length])];
[label setAttributedText:attributedString];
[label sizeToFit];
}
@warriorg
warriorg / Macros.swift
Last active September 5, 2015 13:39 — forked from xmzio/Macros.swift
My aLog and dLog macros in Swift (to abbreviate NSLog)
//
// Macros.swift
//
// Created by Xavier Muñiz on 6/12/14.
import Foundation
// dLog and aLog macros to abbreviate NSLog.
// Use like this:
@warriorg
warriorg / android_image_compress.java
Created August 31, 2015 03:37
Android 图片压缩
private Bitmap decodeFile(File f) {
try {
// Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f), null, o);
// The new size we want to scale to
final int REQUIRED_SIZE=70;
@warriorg
warriorg / golang_build
Created August 26, 2015 06:52
golang编译程序从后台运行,不出现dos窗口
go build -ldflags "-H windowsgui"
@warriorg
warriorg / respondsToSelector
Created August 26, 2015 03:46
判断方法是否可以被实现
if([self.delegate respondsToSelector:@selector(call:type:)]) {
[self.delegate call:sender type:type];
}
@warriorg
warriorg / bottom_corner
Created August 20, 2015 02:27
底部加圆角
UIBezierPath * bezierPath = [UIBezierPath bezierPathWithRoundedRect:topicView.bounds
byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
cornerRadii:CGSizeMake(5, 5)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = topicView.bounds;
maskLayer.path = bezierPath.CGPath;
topicView.layer.mask = maskLayer;
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, ScreenWidth - 10, 44)
@warriorg
warriorg / sql_with_tree.sql
Last active August 29, 2015 14:27
[sql]with tree
WITH x AS (
SELECT [TYPE_SID]
,[CATEGORY_SID]
,[APARTMENT_SID]
,[TYPE_NAME]
,[REMARK]
,[PARENT_SID]
,[CREATEDBY]
,[CREATED_ON]
@interface UIImage (fixOrientation)
- (UIImage *)fixOrientation;
@end
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software