Skip to content

Instantly share code, notes, and snippets.

@revolc
revolc / delete_at_2x_resource.py
Last active December 17, 2015 05:39
python script that keep @2x file with the name of low definition file
#!/usr/bin/env python
import os
image_file_types = ['.jpg', '.png']
def is_image_file(file_name):
fileName, fileExt = os.path.splitext(file_name)
for type in image_file_types:
@revolc
revolc / UIView_rotate_method
Created March 28, 2014 10:51
rotate a UIView
- (void)rotateView:(UIView*)view ToAngle:(CGFloat)angle animated:(BOOL)animated
{
NSParameterAssert(angle <= 360 && angle >= 0);
CGFloat radians = atan2f(view.transform.b, view.transform.a);
CGFloat degrees = radians * (180 / M_PI);
if ( fabs( degrees - angle ) < FLT_MIN) {
return;
}
NSMutableString *pinyin = [name mutableCopy];
if (!CFStringTransform((__bridge CFMutableStringRef)pinyin, 0, kCFStringTransformMandarinLatin, NO)) {
DDLogWarn(@"拼音转换[步骤1]失败: %@ -> %@", name, pinyin);
}
if (!CFStringTransform((__bridge CFMutableStringRef)pinyin, 0, kCFStringTransformStripDiacritics, NO)) {
DDLogWarn(@"拼音转换[步骤2]失败: %@ -> %@", name, pinyin);
}