Skip to content

Instantly share code, notes, and snippets.

View yaoxinghuo's full-sized avatar
🎯
Focusing

Terry Yao yaoxinghuo

🎯
Focusing
View GitHub Profile
@yaoxinghuo
yaoxinghuo / new_gist_file
Created December 8, 2013 09:44
判断NSString是否为数字
// 判断是否为整形:
- (BOOL)isPureInt:(NSString *)string {
NSScanner *scan = [NSScanner scannerWithString:string];
int val;
return [scan scanInt:&val] && [scan isAtEnd];
}
// 判断是否为浮点形:
- (BOOL)isPureFloat:(NSString *)string {
@yaoxinghuo
yaoxinghuo / new_gist_file
Created December 4, 2013 08:05
AFNetoworking HelloWorld
//依赖包CoreLocation.framework, MobileCoreServices.framework, SystemConfiguration.framework, Security.framework
#import "AFNetworking.h"
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
//默认是AFJSONRequestSerializer
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager GET:@"http://www.baidu.com" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSData *data = (NSData *)responseObject;
@yaoxinghuo
yaoxinghuo / new_gist_file
Created November 11, 2013 03:42
IOS Hash(MD5 SHA1)
#import "CommonCrypto/CommonDigest.h"
-(NSString*) sha1:(NSString*)input
{
const char *cstr = [input cStringUsingEncoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithBytes:cstr length:input.length];
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(data.bytes, data.length, digest);
@yaoxinghuo
yaoxinghuo / HashUtils.java
Created November 11, 2013 03:40
Java 的 Hash 工具类(MD5 SHA1)
package com.terrynow.common;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* Developer: Terry DateTime : 2007-12-18 下午03:36:22
*/
public class HashUtils {
@yaoxinghuo
yaoxinghuo / UIColor+PXExtensions.m
Created November 11, 2013 03:14
UIColor 从 Hex 的文本转成颜色
#import "UIColor+PXExtensions.h"
@implementation UIColor (UIColor_PXExtensions)
+ (UIColor*)pxColorWithHexValue:(NSString*)hexValue
{
//Default
UIColor *defaultResult = [UIColor blackColor];
//Strip prefixed # hash
@yaoxinghuo
yaoxinghuo / new_gist_file
Created November 11, 2013 03:00
常用代码块-调用
//1、调用 自带mail
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"mailto://[email protected]"]];
//2、调用 电话phone
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"tel://8008808888"]];
@yaoxinghuo
yaoxinghuo / new_gist_file.sql
Created November 8, 2013 07:50
MySQL 把所有表名改成大写
#upname.sql 脚本:
DELIMITER //
DROP PROCEDURE IF EXISTS uppercase //
CREATE PROCEDURE uppercase(IN dbname VARCHAR(200))
BEGIN
DECLARE done INT DEFAULT 0;
@yaoxinghuo
yaoxinghuo / new_gist_file
Created November 8, 2013 07:31
IOS 改变 View 的位置 (光设置 frame 不行,还要设置View 的 center 才行)
//http://blog.csdn.net/wilmer_wu/article/details/6974402
//谈谈iOS下视图、坐标、位置相关等基础概念
CGRect mainBounds = [UIScreen mainScreen].bounds;
int height = mainBounds.size.height;
self.btn.center = CGPointMake(mainBounds.size.width/2, mainBounds.size.height/2); // set center
CGRect frame = self.btn.frame;
self.btn.frame = CGRectMake( frame.origin.x, height-frame.size.height, frame.size.width, frame.size.height ); // set new position exactly
@yaoxinghuo
yaoxinghuo / new_gist_file.java
Created October 24, 2013 09:12
Android Bitmap 图片裁剪成圆形
/**
* 转换图片成圆形
*
* @param bitmap
* 传入Bitmap对象
* @return
*/
public static Bitmap toRoundBitmap(Bitmap bitmap) {
if (bitmap == null)
return null;
@yaoxinghuo
yaoxinghuo / new_gist_file
Created October 7, 2013 14:10
OC 创建单例
//
// UserConext.m
// HelloWorld
//
// Created by Terry on 2013-10-07.
// Copyright (c) 2013 Terry. All rights reserved.
//
#import "UserConext.h"