Skip to content

Instantly share code, notes, and snippets.

View nielswh's full-sized avatar

Niels Hansen nielswh

View GitHub Profile
@nielswh
nielswh / new_gist_file
Created October 30, 2013 18:03
How to capture specific portion of the screen
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect rect = CGRectMake(250,61 ,410, 255);
CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], rect);
@nielswh
nielswh / new_gist_file
Created October 28, 2013 23:47
Kill node.js Process on OSX
ps aux | grep node
kill -9 PID
(Replace PID with the process Id of the Node)
@nielswh
nielswh / new_gist_file
Created October 21, 2013 18:55
ios-7-uiview-frame-issue
self.edgesForExtendedLayout = UIRectEdgeNone;
@nielswh
nielswh / new_gist_file
Created October 19, 2013 04:33
Get Image from Library
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
[picker setDelegate:self];
[picker setAllowsEditing:YES];
[picker setSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum];
[picker setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:picker animated:YES completion:^{ NSLog(@"We got something back from picking an Image");}];
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissViewControllerAnimated:YES completion:nil];
@nielswh
nielswh / new_gist_file
Created October 19, 2013 04:29
Set the background of a UIView to an Image
UIImage *img = [UIImage imageNamed:@"background.png"];
UIGraphicsBeginImageContext(img.size);
[[UIImage imageNamed:@"background.png"] drawInRect:CGRectMake(0, 0, img.size.width, img.size.height)];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[self view] setBackgroundColor:[UIColor colorWithPatternImage:image]];
@nielswh
nielswh / new_gist_file
Created October 19, 2013 04:28
Create Rounded Images for Layers
[[[cell imageView] layer] setMasksToBounds:YES];
[[[cell imageView] layer] setCornerRadius:49.0];
[[[cell imageView] layer] setBorderColor: [[UIColor whiteColor] CGColor]];
[[[cell imageView] layer] setBorderWidth: 2.0];
This takes a image cell, creates a circle based on an image that is 98 points
Change [cell imageView] to be object of UIView.
radius changes how round the edges are
Width changes the thickness of the border. -exclude to have no border.
@nielswh
nielswh / new_gist_file
Created August 29, 2013 04:28
Rebase on origin
git rebase -i origin/master~4 master
git push origin +master //forces a push after doing a rebase
git push origin --delete <branch> //Removes branch from origin
git branch -d <branch> //Removes branch from local
@nielswh
nielswh / DropdownUtilityCell
Created December 4, 2012 23:29
Creating a dropdown Utility for TableViewCell
//
// TweetbotViewController.m
// testingTweetbotCell
//
// Created by Niels Hansen on 12-12-04.
// Copyright (c) 2012 Niels Hansen. All rights reserved.
//
#import "TweetbotViewController.h"
#import "TweetbotInfoCell.h"