Skip to content

Instantly share code, notes, and snippets.

View srgtuszy's full-sized avatar

Michał Tuszyński srgtuszy

View GitHub Profile
@srgtuszy
srgtuszy / CGImageCropping.m
Created March 28, 2011 14:41
Easy image cropping with core graphics
//The image to be cropped
UIImage *image;
//The rect to which the image is going to be cropped
CGRect croppedRect = CGRectMake(0, 0, 40, 40);
//A simple call to Core Graphics function
CGImageRef img = CGImageCreateWithImageInRect(image.CGImage, croppedRect);
//There goes the cropped image
UIImage *result = [[UIImage alloc] initWithCGImage:img] autorelease];
@srgtuszy
srgtuszy / WebViewContent
Created May 5, 2011 11:07
UIWebView content size without javascript
CGRect webViewFrame = [self.webView frame];
webViewFrame.size.height = 1;
[self.webView setFrame:webViewFrame];
CGSize fittingSize = [self.webView sizeThatFits:CGSizeZero];
webViewFrame.size = fittingSize;
[self.webView setFrame:webViewFrame];
@srgtuszy
srgtuszy / IAMultipartRequestGenerator.h
Created May 8, 2011 18:42
Easy and lightweight Multipart form data requests with CFNetwork. You can use it freely in free and commercial projects.
//IAMultipartRequestGenerator.h
//
//Author: Michal Tuszynski
//
//Easy Multipart Request Generator
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
@srgtuszy
srgtuszy / urlcache.m
Created June 26, 2011 21:57
NSURLCache
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
+(UIView *)fetchViewFromNib:(NSString *)nibName withClass:(Class)viewClass {
NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:nibName owner:nil options:nil];
UIView *view = nil;
for (id object in nibObjects) {
if ([object isKindOfClass:viewClass]) {
view = object;
+(UIView *)fetchViewFromNib:(NSString *)nibName withClass:(Class)viewClass {
NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:nibName owner:nil options:nil];
UIView *view = nil;
for (id object in nibObjects) {
if ([object isKindOfClass:viewClass]) {
view = object;
@srgtuszy
srgtuszy / UIView+ParentViewController.h
Created January 22, 2012 19:07
Parent UIViewController from UIView
#import <UIKit/UIKit.h>
@interface UIView (Utils)
-(UIViewController *)parentViewController;
@end
@srgtuszy
srgtuszy / gist:4086991
Created November 16, 2012 12:35
A script for resizing retina images for regular screens
#! /usr/bin/env ruby
require 'RMagick'
def resize_image (image_path, write_path)
image = Magick::Image.read(image_path).first
new_image = image.scale(0.5)
puts "Writing image #{write_path}..."
new_image.write(write_path)
end
@srgtuszy
srgtuszy / .emacs
Created June 28, 2013 07:57 — forked from anonymous/.emacs
(add-to-list 'load-path "~/.emacs.d")
(require 'cc-mode)
(require 'autopair)
(autopair-global-mode)
(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
(global-linum-mode t)
(setq-default c-basic-offset 4
tab-width 8
indent-tabs-mode t)
@srgtuszy
srgtuszy / gist:6371749
Last active May 18, 2022 03:16
Gradle task for uploading builds to TestFlight using HTTPBuilder
task uploadTf(dependsOn: assembleRelease) << {
def teamToken = '<TestFlight team token here>'
def apiToken = '<TestFlight api token here>'
def lists = '<TestFlight distribution lists here>'
def apk = file("build/apk/$project.name-release.apk")
def notes = new File(file('changelog.mdown')).getText("UTF-8")
def http = new HTTPBuilder('http://testflightapp.com')
println('Uploading build to TestFlight...')
http.request(POST, JSON) { req ->
uri.path = '/api/builds.json'