Skip to content

Instantly share code, notes, and snippets.

caojianhua caojianhua

Block or report user

Report or block caojianhua

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@caojianhua
caojianhua / rename.sh
Created Dec 24, 2019
Rename file to create date from exif info
View rename.sh
#! /usr/bin/env bash
for filename in ./*
do
tmp="$(echo "$filename" | tr '[A-Z]' '[a-z]')"
case "$filename" in
*.PNG|*.JPG|*.MOV|*.MP4|*.jpg|*.mov|*.mp4|*.AAE)
newname="$(exiftool -filemodifydate "$filename" | grep "File Modification Date/Time" | awk -F ': ' '{print $2}' | sed -e 's/\-[0-9][0-9]\:00//g' -e 's/\+[0-9][0-9]\:00//g' -e 's/:/-/g' -e 's/ /_/g').${filename##*.}"
echo "mv $filename to $newname"
mv "$filename" $newname
;;
@caojianhua
caojianhua / jarmethod.sh
Last active Nov 7, 2019
计算jar包文件中的方法总数
View jarmethod.sh
#! /bin/sh
# 获得输入的jar文件
JAR_FILE=$1;
# 这里直接使用dx命令,是因为我已经提前配置好了环境变量,dx目录位于:
# $ANDROID_HOME/sdk/build-tools/android-4.3.1/dx
dx --dex --verbose --no-strict --output=temp.dex $JAR_FILE > /dev/null
# 计算jar包中的方法数
@caojianhua
caojianhua / OpenGLToCVPixelBuffer.m
Created Jan 27, 2016
Create CVPixelBufferRef from OpenGL
View OpenGLToCVPixelBuffer.m
@interface SREAGLContext : NSObject
+ (EAGLContext*)sharedContext;
+ (EAGLContext*)newContext: (EAGLRenderingAPI) api;
@end
@implementation SREAGLContext
@caojianhua
caojianhua / ImageToCVPixelBuffer.m
Last active Jun 10, 2017
Create CVPixelBufferRef from an UIImage
View ImageToCVPixelBuffer.m
+ (CVPixelBufferRef)pixelBufferFromImage:(UIImage *)image {
NSData * rawImageData = [UIImage RawRepresentation:image pixelFormat:SVPixelFormat_BGRA];
NSDictionary * attributes = @{
(NSString *)kCVPixelBufferIOSurfacePropertiesKey : @{},
(NSString *)kCVPixelBufferCGImageCompatibilityKey : @(YES),
(NSString *)kCVPixelBufferOpenGLESCompatibilityKey : @(YES),
(NSString *)kCVPixelBufferCGBitmapContextCompatibilityKey : @(YES),
};
@caojianhua
caojianhua / MemoryToCVPixelBuffer.m
Created Dec 28, 2015
Create CVPixelBuffer from memory
View MemoryToCVPixelBuffer.m
CVPixelBufferRef pxbuffer = NULL;
CVPixelBufferCreateWithBytes(kCFAllocatorDefault,width,height,kCVPixelFormatType_32ARGB,data,4 * width, NULL, NULL, NULL, &pxbuffer);
CIImage* tmpImage = [CIImage imageWithCVPixelBuffer:pxbuffer];
UIImage* newImage = [UIImage imageWithCIImage:tmpImage];
NSLog(@"imageSize:%@",NSStringFromCGSize(newImage.size));
dispatch_async(dispatch_get_main_queue(), ^{
imageView.image = newImage;
You can’t perform that action at this time.