Skip to content

Instantly share code, notes, and snippets.

View shahdhiren's full-sized avatar

Dhiren Shah shahdhiren

View GitHub Profile
@shahdhiren
shahdhiren / ZIP Cross Platform
Created February 2, 2014 13:03
ZIP Cross Platform
#################### ZIP Cross Platform ######################
#Link : http://www.coolestguyplanettech.com/how-to-compress-and-uncompress-files-and-folders-in-os-x-lion-10-7-using-terminal/
#First up is ZIP one of the most commonly used compression techniques used across all platforms
#To compress
zip -r archive_name.zip <folder_to_compress>
#To extract
unzip archive_name.zip
#In Terminal Pass this command
#FOR ALL FILES :
#-------------
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
#FOR PARTICULAR FILE :
#---------------------
@shahdhiren
shahdhiren / Create Plist File Programmatically
Last active August 29, 2015 14:01
Create Plist File Programmatically
NSMutableDictionary *rootObj = [NSMutableDictionary dictionaryWithCapacity:1];
NSString *stringFormat = @"My String stored in plist"; // Here any object can be pass NSNumber, NSArray, NSString, BOOL, NSDictionary.
[rootObj setObject:stringFormat forKey:@"commsEncodingFormat"];
NSString *error = nil;
id plist = [NSPropertyListSerialization dataFromPropertyList:(id)rootObj format:NSPropertyListXMLFormat_v1_0 errorDescription:&error];
@shahdhiren
shahdhiren / How to prevent the Screen from Locking
Last active August 29, 2015 14:03
How to prevent the Screen from Locking
By default, iOS will lock the screen and disable the touch sensor if there are no touch events for a specified period of time. Depending on your application, there may be times that you need to keep the screen from locking. For example, if your application is primarily accelerometer driven (such as a game), there may be minimal touch events to keep the screen from reseting its internal timer.
You can disable the idle timer through the idleTimerDisabled property of the shared UIApplication object:
// Disable the idle timer
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
// Or for those who prefer dot syntax:
[UIApplication sharedApplication].idleTimerDisabled = YES;
@shahdhiren
shahdhiren / UIView+PrintSubviews
Last active August 29, 2015 14:16
Inspect subview's hierarchy of any UIView (with Indentation)
// Create UIView category called UIView+printSubviews.h
#import <Foundation/Foundation.h>
@interface UIView (PrintSubviews)
- (void)printSubviewsWithIndentation:(int)indentation;
@end
@shahdhiren
shahdhiren / Slow_Motion_iPhone-iPad_Simulator.txt
Last active August 29, 2015 14:25
Slow Motion iPhone/iPad Simulator
For Xcode 6 & 7 :
---------------
If you are trying to develop a particular complex animation, use this trick to turn on “Slow Motion Mode” in the simulator.
It’ll be much easier to see what’s going on.
1. Start the simulator as normal.
2. Next, make sure you enable “Connect Hardware Keyboard” in the simulator’s hardware menu.
3. Press your Mac’s Command key (⌘) + T in succession to toggle it on/off. You’ll see in the debugger that slow motion mode has been activated.
Problem:
--------
Sometimes it happens that "Show in Finder" does not work to open in new window.
Also, in Xcode when you right click any file and try to "Show in Finder" it does not show up.
Solution:
---------
As an alternative to this bug's solution, try to run below terminal command:
sudo killall -KILL appleeventsd
@shahdhiren
shahdhiren / Create iOS Simulators
Last active January 9, 2016 21:37
Create iOS Simulators if it is deleted from ~/Library/Developer/CoreSimulator/Devices locations
# To add iPhone 4s device with iOS 8.3 SDK
MacBook-Pro:~ dhirenshah$ xcrun simctl create "iPhone 4s" com.apple.CoreSimulator.SimDeviceType.iPhone-4s com.apple.CoreSimulator.SimRuntime.iOS-8-3
#output: C787348F-9A0F-40F5-9766-F0C76CE12616
# To add iPad Air device with iOS 8.3 SDK
MacBook-Pro:~ dhirenshah$ xcrun simctl create "iPad Air" com.apple.CoreSimulator.SimDeviceType.iPad-Air com.apple.CoreSimulator.SimRuntime.iOS-8-3
#output: 664212E9-9596-40E3-A130-28F52C2DD30B
@shahdhiren
shahdhiren / Change a User Default Login Shell
Created February 8, 2016 13:12
Change the Shell in Mac OS X Terminal
Change the user login default shell to zsh:
chsh -s /bin/zsh
ksh:
chsh -s /bin/ksh
tcsh:
chsh -s /bin/tcsh
bash (default):
@shahdhiren
shahdhiren / Print all fonts in iOS - Swift
Created January 20, 2017 09:47
Print all fonts in iOS - Swift
func printFonts() {
let fontFamilyNames = UIFont.familyNames
for familyName in fontFamilyNames {
print("------------------------------")
print("Font Family Name = [\(familyName)]")
let names = UIFont.fontNames(forFamilyName: familyName )
print("Font Names = [\(names)]")
}
}