Skip to content

Instantly share code, notes, and snippets.

View balazsnemeth's full-sized avatar

Balázs Németh balazsnemeth

View GitHub Profile
@balazsnemeth
balazsnemeth / gist:cbdf3b352bb7a7df8661
Created March 30, 2015 21:59
iOS - Twitter upload image with SLRequest
/**
* Upload an image to twitter to get media_id for is
*
* @param img The image (UIImage or NSData) to be uploaded
* @param completion
*/
- (void)sendTweetWithImage:(id)img withCompletion:(void(^)(NSNumber *mediaID, NSError *error))completion {
NSURL *requestURL = [[NSURL alloc] initWithString:@"https://upload.twitter.com/1.1/media/upload.json"];
@balazsnemeth
balazsnemeth / IPad screenshot
Last active August 29, 2015 14:14
IPad screenshot
//Create an image about the screen of the iOS device
+ (UIImage *) screenshot{
UIWindow *mainWindow = [[[UIApplication sharedApplication] windows] firstObject];
if(UIGraphicsBeginImageContextWithOptions != NULL)
{
UIGraphicsBeginImageContextWithOptions(mainWindow.frame.size, NO, 0.0f);
} else {
UIGraphicsBeginImageContext(mainWindow.frame.size);
@balazsnemeth
balazsnemeth / UIImage+ImageFromPDF
Last active September 23, 2021 15:49
PDF to UIImage fitting a given size with file cache
//based on the solution of iamamused : https://gist.github.com/iamamused/1955318
@implementation UIImage (ImageFromPDF)
+ (UIImage *)imageLoadedFromPDF:(NSString *)filePath fitSize:(CGSize)fitSize shouldCacheAsAFile:(BOOL)storeInFile{
// Determine if the device is retina.
BOOL isRetina = [UIScreen instancesRespondToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0;
// Create a file manager so we can check if the image exists and store the image.
NSFileManager *fileManger = [NSFileManager defaultManager];