Skip to content

Instantly share code, notes, and snippets.

@akinLiu
akinLiu / ubuntu-maven-3
Created March 28, 2017 03:56 — forked from stephanetimmermans/ubuntu-maven-3
Install Maven3 on Unbuntu 14.04
#sudo apt-get remove maven2
sudo add-apt-repository "deb http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main"
sudo apt-get update
sudo apt-get install maven3
#If you encounter this:
#The program 'mvn' can be found in the following packages:
# * maven
# * maven2
@akinLiu
akinLiu / city.json
Created February 23, 2016 02:34
城市商圈,地铁
{
"request_id": "2220913894196",
"errno": 0,
"error": "",
"data": {
"info": [
{
"city_id": 110000,
"city_name": "北京",
"subway_line": [
@akinLiu
akinLiu / expression
Created November 10, 2014 10:32
最新手机正则
expression = @"^((13[0-9])|(14[57])|(15[^4,\\D])|(17[678])|(18[0-9]))\\d{8}$";
- (UIImageView *)findHairlineImageViewUnder:(UIView *)view {
if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) {
return (UIImageView *)view;
}
for (UIView *subview in view.subviews) {
UIImageView *imageView = [self findHairlineImageViewUnder:subview];
if (imageView) {
return imageView;
}
}
@akinLiu
akinLiu / sorted
Created June 9, 2014 15:40
多条件排序
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSSortDescriptor *descriptor1 = [[NSSortDescriptor alloc] initWithKey:@"endCalYear" ascending:YES];
NSSortDescriptor *descriptor2 = [[NSSortDescriptor alloc] initWithKey:@"endMonth" ascending:YES];
NSSortDescriptor *descriptor3 = [[NSSortDescriptor alloc] initWithKey:@"periodLength" ascending:YES];
NSArray *sortDescriptors = @[descriptor1, descriptor2, descriptor3];
[fetchRequest setSortDescriptors:sortDescriptors];
@akinLiu
akinLiu / checkRecordPermission
Created May 20, 2014 15:26
检测麦克风可用状态
if ([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission:)]) {
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
if (!granted) {
//检测到不可用
dispatch_async(dispatch_get_main_queue(), ^{
//回到主线程做出相应提示
});
}
}];
}
// Photoshop Script to Create iPhone Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
// Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com
@akinLiu
akinLiu / UIViewToImage
Created July 13, 2013 03:12
UIView to UIImage
- (UIImage*)toImage
{
UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0.0);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
<?php
/**
* img.ly class for Kohana v3.0.x
*
* @author icyleaf <icyleaf.cn@gmail.com>
* @link http://icyleaf.com
* @version 0.1
* @license http://www.opensource.org/licenses/bsd-license.php
*/
class imgly {
@akinLiu
akinLiu / IS_IPHONE5
Created March 18, 2013 08:43
判断iphone 5
#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)