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 / UITableView-RowSelection.m
Created August 26, 2013 15:12
Selecting a row of a UITableView after it is loaded
// The performSelection: method is a "hack". The default row should be selected
// after the last row is selected in the table view
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self performSelector:@selector(selectDefaultTableRow) withObject:nil afterDelay:0.5];
}
@indyfromoz
indyfromoz / FontList.m
Created September 5, 2013 11:30
List all the fonts in an iOS app
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont)
BOOL PSPDFIsUIKitFlatMode(void) {
static BOOL isUIKitFlatMode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) {
PSPDFAssertIfNotMainThread();
// If your app is running in legacy mode, tintColor will be nil - else it must be set to some color.
if (UIApplication.sharedApplication.keyWindow) {
isUIKitFlatMode = [UIApplication.sharedApplication.delegate.window performSelector:@selector(tintColor)] != nil;
@indyfromoz
indyfromoz / Alter-Collation.sql
Created October 31, 2013 05:34
Alter the collation of a SQL database
USE master;
GO
ALTER DATABASE MyOptionsTest
COLLATE French_CI_AS ;
GO
--Verify the collation setting.
SELECT name, collation_name
FROM sys.databases
WHERE name = N'MyOptionsTest';
@indyfromoz
indyfromoz / UIImageView+DeviceOrientation.m
Last active January 1, 2016 08:19
Update background image of a view based on device orientation
/*
Add this in a view
*/
- (void)viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
// Update the background image if the device is an iPad and its orientation changed
- (void)orientationChanged:(NSNotification *)notification {
@indyfromoz
indyfromoz / node-file-watcher.js
Created December 25, 2013 06:09
Watches a file for any changes
fs.watch('any-folder-you-want', function (event, filename) {
console.log('event: ' + event);
if (filename) {
console.log('filename: ' + filename);
} else {
console.log('filename unknown');
}
});
@indyfromoz
indyfromoz / fade-in-subview.m
Created December 29, 2013 01:56
Fade in a newly added subview
[fadingView setAlpha:0.0];
[containerView addSubview:fadingView];
[UIView beginAnimations:nil context:nil];
[fadingView setAlpha:1.0];
[UIView commitAnimations];
// Remove from superView
[UIView animateWithDuration:0.2
animations:^{viewOut.alpha = 0.0;}
completion:^(BOOL finished){[viewOut removeFromSuperview];}];
@indyfromoz
indyfromoz / uinavigationbar-noshadown.m
Created January 15, 2014 14:01
Remove single pixel shadow from UINavigationBar
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc]init] forBarMetrics:UIBarMetricsDefault];
@indyfromoz
indyfromoz / Obsidian.xccolortheme
Created March 30, 2017 20:18
Obsidian Xcode theme tested with Xcode 8.3
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>1 1 1 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>SFMono-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@indyfromoz
indyfromoz / SolarizedDark.xccolortheme
Created July 23, 2017 08:28
Solarized Dark Theme for Xcode 8+
#Remove this line after copying the following to ~/Library/Developer/Xcode/UserData/FontAndColorThemes/SolarizedDark.xccolortheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.513725 0.580392 0.588235 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Regular - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>