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
@interface UIImage (fixOrientation)
- (UIImage *)fixOrientation;
@end
@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]
@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 / respondsToSelector
Created August 26, 2015 03:46
判断方法是否可以被实现
if([self.delegate respondsToSelector:@selector(call:type:)]) {
[self.delegate call:sender type:type];
}
@warriorg
warriorg / golang_build
Created August 26, 2015 06:52
golang编译程序从后台运行,不出现dos窗口
go build -ldflags "-H windowsgui"
@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 / 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 / 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 / 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 / UIViewTouchStyle.m
Created November 7, 2015 05:11
UIView 增加触摸效果
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
[self setBackgroundColor:[UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1.0]];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
[self setBackgroundColor:[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesCancelled:touches withEvent:event];