Skip to content

Instantly share code, notes, and snippets.

View indyfromoz's full-sized avatar
🏠
Working from home

Indrajit Chakrabarty indyfromoz

🏠
Working from home
View GitHub Profile
@indyfromoz
indyfromoz / gist:3802974
Created September 29, 2012 02:41 — forked from jeffwilcox/gist:2432351
WinRT IsInstanceOfType, IsAssignableFrom
/// <summary>
/// Determines whether the specified object is an instance of the current Type.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="o">The object to compare with the current type.</param>
/// <returns>true if the current Type is in the inheritance hierarchy of the
/// object represented by o, or if the current Type is an interface that o
/// supports. false if neither of these conditions is the case, or if o is
/// null, or if the current Type is an open generic type (that is,
/// ContainsGenericParameters returns true).</returns>
@indyfromoz
indyfromoz / xcode.gitignore
Created October 24, 2012 06:47
Gitignore for Xcode projects
# Exclude the build directory
build/*
# Exclude temp nibs and swap files
*~.nib
*.swp
# Exclude OS X folder attributes
.DS_Store
@indyfromoz
indyfromoz / aspnet-mvc.gitignore
Created November 19, 2012 06:44
.Gitignore for ASP.NET MVC
###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
@indyfromoz
indyfromoz / aspnet-mvc.gitattributes
Created November 19, 2012 07:07
.Gitattributes for ASP.NET MVC
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
@indyfromoz
indyfromoz / winstore.gitignore
Created November 20, 2012 22:10
.Gitignore for Windows Store projects
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.gitignore
*.gitattributes
# Build results
@indyfromoz
indyfromoz / winstore.gitattributes
Created November 20, 2012 22:10
.Gitattributes for Windows Store Projects
# Auto detect text files and perform LF normalization
[attr]utf16 diff merge -crlf
* text=auto
*.ico binary
*.snk binary
*.xls binary
@indyfromoz
indyfromoz / iPhone5-Storyboard
Created May 26, 2013 22:41
Separate storyboard for iPhone 5
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if (iOSDeviceScreenSize.height == 480){
UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"Storyboard_iPhone4" bundle:nil];
UIViewController *initialViewController = [iPhone35Storyboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = initialViewController;
}
if (iOSDeviceScreenSize.height == 568){ // iPhone 5
UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"Storyboard_iPhone5" bundle:nil];
@indyfromoz
indyfromoz / WalkthroughViewController.m
Created August 14, 2013 02:46
Objective-C sample that illustrates how a walkthrough VC can be created and presented with a fade-in animation
// Code from Wordpress iOS App [File: SidebarViewController.m, - (void)showWelcomeScreenIfNeeded; ]
GeneralWalkthroughViewController *welcomeViewController = [[GeneralWalkthroughViewController alloc] init];
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:welcomeViewController];
aNavigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
aNavigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self.panelNavigationController presentModalViewController:aNavigationController animated:YES];
@indyfromoz
indyfromoz / CollectionSnippets.m
Created August 17, 2013 12:03
Snippets of Objective-C code handy for working with collections (Should go in a category, one day...)
// Check if an item is in a NSMutableArray
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"pubDate = %@", tumblrPost.pubDate];
NSArray *filteredArray = [favoriteItems filteredArrayUsingPredicate:predicate];
if (filteredArray.count > 0) {
// item found!
}
// Remove an item from a NSMutableArray
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"createdAt = %@", facebookPost.createdAt];
@indyfromoz
indyfromoz / ResizeUIImageViewForScreenSize
Created August 24, 2013 23:21
Resize UIImageView based on the size of the screen
// From http://stackoverflow.com/questions/12648129/uiimageview-programmilly-manage-for-iphone5-and-iphone4/12774544#12774544
[self resizeImageView:self.backgroundImageView intoFrame:self.view.frame];
- (void)resizeImageView:(UIImageView *)imageView intoFrame:(CGRect)frame {
// resizing is not needed if the height is already the same
if (frame.size.height == imageView.frame.size.height) {
return;
}