Skip to content

Instantly share code, notes, and snippets.

@paolonl
paolonl / UIImage+Rotation
Last active July 3, 2018 14:16
Rotate UIImage/CGImageRef
- (UIImage *)rotateImage:(UIImage *)image ofAngle:(CGFloat)degrees {
CGImageRef imgRef = image.CGImage;
CGFloat angleInRadians = degrees * (M_PI / 180);
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);
CGRect imgRect = CGRectMake(0, 0, width, height);
CGAffineTransform transform = CGAffineTransformMakeRotation(angleInRadians);
CGRect rotatedRect = CGRectApplyAffineTransform(imgRect, transform);
@mralexgray
mralexgray / logProperties.m
Last active September 3, 2019 09:02
A concise category on NSObject to log all declared properties, pretty-like, using minimal SLOC.
#import <objc/message.h>
#define DECORATE printf("\n\n+*%%$%%*+-+*%%$%%*+-+*%%$-+*%%$%%*+-+*%%$%%*+-+*%%$-+*%%$%%*+-+*%%$%%*+-\n\n")
@implementation NSObject (logProperties) - (void) logProperties { DECORATE; @autoreleasepool { unsigned int propCt = 0;
const char * myName = [self.description substringWithRange:
(NSRange){1,[self.description rangeOfString:@":"].location-1}].UTF8String;
objc_property_t *pA = class_copyPropertyList(self.class, &propCt);
for (int i = 0; i < propCt; i++) { NSString *name; printf("%s [%s] = %s\n", myName,
(name = [NSString.alloc initWithUTF8String:property_getName(pA[i])]).UTF8String,
[objc_msgSend(self,NSSelectorFromString(name)) description].UTF8String);
} free(pA); } DECORATE; }
@hezi
hezi / HZClassUsingEnum.h
Created July 12, 2012 14:06
Objective-C Enum-TO-NSString and Vice versa.
// Declare enums like so:
#define IMAGE_STATUS(XX) \
XX(kDOImageStatusOK, = 0) \
XX(kDOImageStatusCached, )\
XX(kDOImageStatusRetry, )
DECLARE_ENUM(DOImageStatus, IMAGE_STATUS)
@subchen
subchen / git-stash.md
Created October 31, 2014 08:56
Git Stash 用法

git stash用于保存和恢复工作进度

  • git stash

    保存当前的工作进度。会分别对暂存区和工作区的状态进行保存

  • git stash save "message..."

这条命令实际上是第一条 git stash 命令的完整版

@steipete
steipete / gist:3713233
Created September 13, 2012 09:39
I often use dispatch queues for locking, and this function just makes life SO MUCH EASIER. Accidental deadlocks in more complex code paths are a PITA otherwise. But Apple deprecated dispatch_get_current_queue with iOS6?
nline void pspdf_dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_block_t block) {
dispatch_get_current_queue() == queue ? block() : dispatch_sync(queue, block);
}
@kharmabum
kharmabum / ocmock-cheatsheet.m
Last active October 8, 2022 07:55
OCMock cheatsheet
/*----------------------------------------------------*/
#pragma mark - XCTAsserts
/*----------------------------------------------------*/
XCTAssert(expression, format...);
XCTAssertTrue(expression, format...);
XCTAssertFalse(expression, format...);
XCTAssertEqual(expression1, expression2, format...);
XCTAssertNotEqual(expression1, expression2, format...);
XCTAssertNil(expression, format...);
@Tomasvrba
Tomasvrba / 360TimelapseTutorial.md
Last active December 17, 2022 22:18
HD 360° Timelapse and FFmpeg tutorial

How to capture, stitch and publish a 360° timelapse

Consumer ready 360° cameras are becoming ever more accessible and many people are experimenting with a variety of 360° content. Out of the many cameras on the market the Ricoh Theta S is one of the most user-friendly, turn-key solutions with lots of built-in features. However, the camera's videos are limited 1920x960 resolution and the Theta+ app only lets you create a timelapse with up to 300 or 400 images. The workaround is to use interval shooting to capture as many images as you'd like at the 5376x2688 to full resolution and then stitch them together manually into an HD video. There are few GUI solutions (especially open-source/free) which let you do this with ease. Here's how you do it:

Set up interval shooting on your Ricoh Theta S

@emrahgunduz
emrahgunduz / WebImageDownloader.cpp
Last active January 25, 2023 21:15
Web Image Downloader For Unreal Engine 4 -- Do not forget to change the include and API key in your own classs, if you simply copy-pasting this.
// (c) 2016 Markakod
#include "HitMe.h"
#include "WebImageDownloader.h"
UWebImageDownloader* UWebImageDownloader::GetWebImageDownloader(FString WebImageName, FString URL, bool& IsValid)
{
IsValid = false;
UWebImageDownloader *Object = NewObject<UWebImageDownloader>();
//
// ViewController.m
// AVPlayerCaching
//
// Created by Anurag Mishra on 5/19/14.
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer
//
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@atdrendel
atdrendel / debug.xcconfig
Last active May 11, 2023 11:50
Xcode configuration for iOS, macOS, watchOS, and tvOS framework
// -*- SHARED -*-
SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator
COMBINE_HIDPI_IMAGES = YES
INSTALL_PATH = $(LOCAL_LIBRARY_DIR)/Frameworks
SKIP_INSTALL = YES
COPY_PHASE_STRIP = NO
IPHONEOS_DEPLOYMENT_TARGET = 14.0
MACOSX_DEPLOYMENT_TARGET = 10.15
TVOS_DEPLOYMENT_TARGET = 14.0