Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
Ctrl+C | copy current line (if no selection) |
Ctrl+X | cut current line (if no selection) |
Ctrl+⇧+K | delete line |
Ctrl+↩ | insert line after |
Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
Ctrl+C | copy current line (if no selection) |
Ctrl+X | cut current line (if no selection) |
Ctrl+⇧+K | delete line |
Ctrl+↩ | insert line after |
public class Main { | |
public static void main(String[] args) { | |
System.out.print("Hello Gist!"); | |
} | |
} |
label.text = @"some text"; | |
[label sizeToFit]; |
NSError *error = nil; | |
id jsonObject = [NSJSONSerialization | |
JSONObjectWithData:[string dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:&error]; | |
if (jsonObject != nil && error == nil) { | |
NSLog(@"Successfully deserialized..."); | |
if ([jsonObject isKindOfClass:[NSDictionary class]]) { | |
NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject; | |
NSLog(@"Deserialized JSON Dictionary = %@", deserializedDictionary); | |
} else if ([jsonObject isKindOfClass:[NSArray class]]) { |
// Portrait | |
- (NSUInteger)supportedInterfaceOrientations { | |
return UIInterfaceOrientationMaskPortrait; | |
} | |
// Landscape | |
- (NSUInteger)supportedInterfaceOrientations { | |
return UIInterfaceOrientationMaskLandscape; | |
} |
// Open | |
UIViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerStoryboardID"]; | |
// Or (but no use Storyboard) | |
CustomViewController *viewController = [[CustomViewController alloc] init] | |
[self.navigationController pushViewController:viewController animated:YES]; | |
// Close | |
[self.navigationController popViewControllerAnimated:NO]; |
// Read | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *session = [defaults stringForKey:@"session"]; | |
// Write | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
[defaults setObject:session forKey:@"session"]; |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" | |
message:@"Message" | |
delegate:nil // o self | |
cancelButtonTitle:@"OK" | |
otherButtonTitles:nil]; | |
[alert show]; |
-(BOOL) NSStringIsValidEmail:(NSString *)checkString { | |
BOOL stricterFilter = YES; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/ | |
NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}"; | |
NSString *laxString = @".+@([A-Za-z0-9]+\\.)+[A-Za-z]{2}[A-Za-z]*"; | |
NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; | |
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; | |
return [emailTest evaluateWithObject:checkString]; | |
} | |
// Others |
// From resource | |
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.image); | |
// From assets | |
public static Bitmap getBitmapFromAsset(Context context, String strName) { | |
AssetManager assetManager = context.getAssets(); | |
InputStream istr; | |
Bitmap bitmap = null; | |
try { | |
istr = assetManager.open(strName); |