#SeattleSkyline

In a new place with a lot to see…what else should I do? Took my camera and went on an evening of exploration. End result…beautiful views of Seattle. To be continued…

Seattle Nigh Skyline
Seattle Nigh Skyline
Seattle Sunset
Seattle Sunset

My Focus Fix

I spend a lot of time thinking of how to become more productive. Lately, I’ve been facing issues related to staying focused on a single task at a time. The problem is that I get distracted easily. So here are a few things that I’m slowly adopting.

  1. Phone off
  2. Self Control App – used to block all social media and news websites
  3. Concentrate App – only applications required for coding tasks are open while I’m coding
  4. White Noise – https://www.youtube.com/watch?v=ArwcHjmsw3A

What do you do to remain focused?

iOS 8 – Parse SDK – Geo Point For Location Issue

If you recently upgrade to Xcode 6 and using Parse SDK v1.4.0, you may be faced with an issue if there’s a need to to call PFGeoPoint:geoPointForCurrentLocationInBackground

Problem:

The call to geoPointForCurrentLocationInBackground seems to be utilizing one of the requesting authorization methods on CLLocationManager. Since, iOS 8 these methods require the existence of either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription  key in the apps plist.

Solution:

Add NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription  key to your plist

plist-geo-location-service-keys

Reference:

iOS Documentation – The user prompt contains the text from the NSLocationAlwaysUsageDescription key in your app’s Info.plist file, and the presence of that key is required when calling this method.

International Student – After Graduation – OPT

Congratulations! You’ve accomplished another goal in your life. This is your proud moment. There are many options to choose from going forward. You may decide to return home, go to grad school or you may be thinking about working in the US. What are your options?

OPT – Optional Practical Training

You’re entitled to at least one year of OPT after graduating from a US university.  It’s your responsibility to submit an application for OPT before or immediately after you’ve graduated. This can be considered your work permit for maximum of 1 year. This allows you to work within your field of study and you are required to obtain such employment within 3 months of your graduation date. Communicate with your International Student Services office for assistance during this process.

OPT 17 Months STEM Extension

Can you get an extension? Yes; however, if and only if your degree is within a STEM field. You are partially eligible for an extension of your OPT if your are a STEM graduate. In order to be fully eligible, your employer is required to be enrolled within USCIS E-Verify Program. This is a completely new OPT application and follows the same guidelines as your previous OPT application with the additional requirement of providing your employer’s E-Verification ID. You are required to submit the application for your extension before the expiration of your first OPT.

Can I Travel on OPT?

Yes. You are able to travel on OPT; however you would need to provide proof of employment on return to the US. This would include your job offer letter and past pay stubs.

Can I obtain multiple OPT?

Yes you are entitled to OPT after each level of study. After your Bachelors, Masters etc…

Upcoming Posts

In future posts, I will cover the H1B process. This will cover a few timelines that you should be aware of depending on your graduation date and field of study. In addition, I will cover what should be done for an H1B Transfer.

Stay tuned…

 

Amazon Route 53 Updater

I’ve recently transitioned my hosting into my living room. Why pay for hosting when I already pay for internet service? Simple solution, I went out and bought some hardware. Installed Ubuntu. Done. If you’re interested, the list is below. Final Price $246.46

The Problem:

I do not have a fixed ip address. Hosting without a fixed ip is a problem. It’s not a problem that has not been solved. It’s a simple concept of lowering your DNS ttl and update your DNS entry on every ip address change. There are already dynamic DNS service providers. However, their prices range from $25 – $35 /yr.  Amazon Route 53 is $0.50 per million DNS queries a month which works out to be about $6 a year which is at max a 76% saving. Route 53 however isn’t a DDNS. It’s just a DNS provider. Hence the need for a solution to my dynamic DNS requirement.

Solution:

There’s already a perl dnscurl script which allows for updating a record set; however it wasn’t as user friendly. I’ve added a simpler more user friendly updater script which utilizes the dnscurl script to do the heavy lifting in the background. It’s called Simple Amazon Route 53 Updater and can be found on GitHub.

GitHub Link: 

https://github.com/gmatthew/simple-aws-route53-updater

SIMPLE.com VISA Debit Card

Simple VISA CardOver the last 6 months, I’ve been using SIMPLE.com. It’s an invite-only online bank. I strongly recommend SIMPLE. As the name says, it’s SIMPLE! FREE Mailed Checks, NO ATMs Fees, Mobile Notification within minutes etc…

It’s not a credit card! You receive a VISA debit card which means you’re spending your own money and not getting into debt.

Since it’s invite only, there’s a waitlist. However, you’re able to bypass the waitlist with my personal invite. Join Simple!

chai-tea

Productivity Tip: Chai + Fan Sound

I am one of those who try to maximize my output on a daily basis. As a developer, coding all day, I need to stay concentrated on the task at hand at every moment. Therefore, I consistently research new ways to be as focused and productive as possible. You should too!

Here’s my  ‘stay focused’ / ‘ increase productivity’ combination:

For me, I am very relaxed when I drink tea. Unlike coffee which gets me really hyper. The desk fan provides that first level of ‘white noise’ when the office isn’t that noisy. At times, the office gets to the point where I hear too much from outside of my cubicle. I then move to the second level of ‘white noise’ on my headphone with AC Fan Sound.

At this point, everything is blocked off, I am relaxed and in beast mode.

How do you stay focused and productive? Let me know what works for you.

iOS: Display UITextField when hidden by keyboard using UIScrollView

Sample

There are many times where you may have a UITextField or some other input element covered by the keyboard after becoming the first responder. This is a common problem since the user is not able to view the values entered while typing. Below I will outline a simple solution to this problem utilizing UIScrollViewNSNotificationCenter and a UIView Category.

First, we will subscribe to the the four keyboard notifications

  • UIKeyboardWillShowNotification
  • UIKeyboardWillHideNotification
  • UIKeyboardDidShowNotification
  • UIKeyboardDidHideNotification
- (void) setupKeyboardObservations
{

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShowHandler:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHideHandler:) name:UIKeyboardWillHideNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShowHandler:) name:UIKeyboardDidShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHideHandler:) name:UIKeyboardDidHideNotification object:nil];

}

We will then define the notification handlers within our UIViewController. Note, these methods are not calling the appropriate methods yet.

- (void) keyboardWillShowHandler: (NSNotification *)notification {}
- (void) keyboardDidShowHandler: (NSNotification *)notification {}
- (void) keyboardWillHideHandler: (NSNotification *)notification {}
- (void) keyboardDidHideHandler: (NSNotification *)notification {}

We then need to define the method which will handle the scrollview when UITextField is covered. This will be triggered either within the keyboardWillShowHander or keyboardDidShowHandler methods.


- (void) scrollScrollView: (UIScrollView *)scrollView forNotification: (NSNotification *)notification
{

    //Obtain First Responder
    UIView *currentFirstResponder = [scrollView findFirstResponder];

    //Item Frame
    CGRect item = currentFirstResponder.frame;

    //Obtain Keyboard Location and Size Information
    CGRect keyboardFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

    //Add Keyboard Size Padding to ScrollView
    UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, keyboardFrame.size.height, 0.0);
    scrollView.contentInset = contentInsets;
    scrollView.scrollIndicatorInsets = contentInsets;

    //Determine visible frame
    CGRect visibleFrame = self.view.frame;
    visibleFrame.size.height -= keyboardFrame.size.height;

    //Determine whether item is in visible frame
    if (!CGRectContainsPoint(visibleFrame, item.origin) )
    {
        //Calculate point below item
        int scrollPointY = (item.origin.y - keyboardFrame.origin.y) + item.size.height + 5; //5 = minnor padding
        CGPoint scrollPoint = CGPointMake(0.0,  scrollPointY);

        //Scroll to new point
        [scrollView setContentOffset:scrollPoint animated:YES];

    }

}

You will notice, the first instruction tries to determine the current first responder.

//Obtain First Responder
UIView *currentFirstResponder = [scrollView findFirstResponder];

This is done by creating a Category on UIView called UIView+FindFirstResponder. The block of code below simply goes through a UIView and all it’s subviews to determine the current firstResponder. Since UIScrollView inherits from UIView this method is available for its use.

@implementation UIView (FindFirstResponder)
- (UIView *)findFirstResponder
{
    if (self.isFirstResponder)
    {
        return self;
    }

    for (UIView *subview in self.subviews)
    {
        if ([subview findFirstResponder])
        {
            return subview;
        }
    }

    return nil;
}

@end

The rest of the code for the scrollScrollView:forNotification: method is self explanatory. We determine the item’s frame. We then determine the visible frame based on keyboard coordinates. If the item is hidden, we then determine the appropriate amount to scroll the scrollView then we perform the scroll.

Note:  You may modify this method if there are other factors that could reduce the current visible frame coordinates.

Once the user has completed entering text and proceeds to hide the keyboard, two notifications will be fired. These will be the UIKeyboardWillHideNotification and UIKeyboardDidHideNotification. I’ve gone ahead and handled these notifications using the following method.

- (void) scrollViewResetView: (UIScrollView *)scrollView
{
    UIEdgeInsets contentInsets = UIEdgeInsetsZero;

    [UIView animateWithDuration:0.5 animations:^{
        scrollView.contentInset = contentInsets;
    }];

    scrollView.scrollIndicatorInsets = contentInsets;
}

The above method simply resets the scrollView’s contentInset to 0. You could think of the contentInset as CSS padding if you’re familiar with web development.

Using the above methods you will be able to achieve scrolling of UIScrollView when any UITextField is covered by the keyboard.

Feel free to leave your comments below on anyway this solution may be improved.