Skip to content

Instantly share code, notes, and snippets.

View premedios's full-sized avatar

Pedro Remedios premedios

  • Oeiras, Portugal
View GitHub Profile
@premedios
premedios / SongTitle
Created September 13, 2012 16:43
Listing the name of a song title
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Music Cell"];
NSLog(@"%@", [[self.songsList objectAtIndex:indexPath.row] valueForProperty:MPMediaItemPropertyTitle]);
cell.textLabel.text = [[self.songsList objectAtIndex:indexPath.row] valueForProperty:MPMediaItemPropertyTitle];
return cell;
}
//
// TFHppleElement.h
// Hpple
//
// Created by Geoffrey Grosenbach on 1/31/09.
//
// Copyright (c) 2009 Topfunky Corporation, http://topfunky.com
//
// MIT LICENSE
//
#import <UIKit/UIKit.h>
@interface UIView (SMFrameAdditions)
@property (nonatomic, assign) CGPoint $origin;
@property (nonatomic, assign) CGSize $size;
@property (nonatomic, assign) CGFloat $x, $y, $width, $height; // normal rect properties
@property (nonatomic, assign) CGFloat $left, $top, $right, $bottom; // these will stretch the rect
@end
@premedios
premedios / gist:d1d68c97589aab8ea66d
Created May 14, 2014 13:06
Table header with UILabel
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.bounds.size.width, 50.0f)];
headerView.backgroundColor = [UIColor colorWithRed:0.31f green:0.77f blue:0.83f alpha:1.0f];
[self.navigationController setNavigationBarHidden:YES];
self.view.backgroundColor = [UIColor colorWithRed:0.31f green:0.77f blue:0.83f alpha:1.0f];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.bounds.size.width, 44.0f)];
titleLabel.textColor = [UIColor whiteColor];
[headerView addSubview:titleLabel];
self.tableView.tableHeaderView = headerView;
UIImage *backButtonImage = [UIImage imageNamed:@"left"];
[backButtonImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIButton *backBarButton = [UIButton buttonWithType:UIButtonTypeCustom];
backBarButton.frame = CGRectMake(0.0f, 0.0f, backButtonImage.size.width, backButtonImage.size.height);
//[backBarButton setBackgroundImage:backButtonImage forState:UIControlStateNormal];
[backBarButton setImage:backButtonImage forState:UIControlStateNormal];
[backBarButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
backBarButton.layer.borderColor = [[UIColor whiteColor] CGColor];
backBarButton.layer.borderWidth = 1.0f;
backBarButton.tintColor = [UIColor whiteColor];
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds)
let splitViewController = UISplitViewController()
let searchBoxViewController = SearchBoxViewController()
let searchResultDetailViewController = SearchResultDetailViewController()
let navigationController = UINavigationController(rootViewController: searchBoxViewController)
splitViewController.viewControllers = [navigationController, searchResultDetailViewController]
splitViewController.delegate = self
NSLog("%@", splitViewController.viewControllers)
@premedios
premedios / gist:2d85562457933315aabe
Created June 28, 2014 14:41
MainViewController.swift
class MainViewController: UIViewController {
var viewController : UIViewController {
didSet {
addChildViewController(viewController)
}
}
init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
viewController = UIViewController()
Operating System: OS X Mavericks
Ruby: 2.1.2
Rails: 4.1.4
Rspec result:
Peter in ~/developer/rails/sample_app on master*
⚡ autotest
loading autotest/rails_rspec
"/Users/Peter/.rbenv/versions/2.1.2/bin/ruby" -rrubygems -S "/Users/Peter/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.3/exe/rspec" --tty "/Users/Peter/Developer/rails/sample_app/spec/requests/static_pages_spec.rb"
@premedios
premedios / LoginViewController.m
Created September 1, 2014 22:37
performSegueWithIdentifier not doing anything
- (IBAction)twitterLogin:(UIButton *)sender {
STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerKey:@"kQIEDlgYpejDPcB9a6xJ9Aqjg" consumerSecret:@"5MNUJcqyTBRZriHv7dCFyGP1BZSh3tf3A4vZYeFOTK7GU5KnKB"];
[twitter postTokenRequest:^(NSURL *url, NSString *oauthToken) {
[[UIApplication sharedApplication] openURL:url];
//[self performSegueWithIdentifier:@"User Info" sender:self];
// The above line works but the segue happens before switching to Safari to open the URL.
} authenticateInsteadOfAuthorize:NO forceLogin:@YES screenName:nil oauthCallback:@"tweepy://twitter_oauth" errorBlock:^(NSError *error) {
NSLog(@"Error!");
}];
}
Ld /Users/Peter/Library/Developer/Xcode/DerivedData/SearchBox-dpxojbceltozthdhaniikkmuimvy/Build/Products/Debug-iphonesimulator/SearchBoxTests.xctest/SearchBoxTests normal x86_64
cd /Users/Peter/Developer/iOS/SearchBox
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/usr/local/opt/rbenv/shims:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -L/Users/Peter/Library/Developer/Xcode/DerivedData/SearchBox-dpxojbceltozthdhaniikkmuimvy/Build/Products/Debug-iphonesimulator -F/Users/Peter/Library/Developer/Xcode/DerivedData/SearchBox-dpxojbceltozthdhaniikkmuimvy/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Deve