Sencha Touch Quirk: Floating Panels

Floating panels (like the one below) are a great way to present helpful content, such as a form or help text, within the context of a parent user interface screen. Unfortunately, the Sencha Touch documentation fails once again at clearly explaining a useful framework feature. In the Ext.Panel documentation, they show some crazy way to use the Ext.Panel.showBy method, which is extremely unhelpful and dosen’t show how to use it in an MVC context. Further, the Overlays sample application is obfuscated and breaks all MVC convention and most general Sencha Touch conventions. Here’s a brief tutorial on how to actually use this in an MVC application.

Floating Panels are simply Ext.Panel controls that are hidden from the main Viewport. These panels are displayed much like an Ext.Msg.alert call, with the ability to customize them at a finer level of detail.

The panel itself is fairly easy to create:

Ext.define('App.view.FloatingPanelView', {
    extend: 'Ext.Panel',
    alias: 'widget.floatingPanel',

    config: {
        id: 'floatingPanel',
        html: '<p>Here's some content.</p>',
        styleHtmlContent: true,
        hidden: true,
        modal:true,
        hideOnMaskTap:true,
        height: '200px',
        width: '200px',
        scrollable: 'vertical'
    }
});

The modal and hideOnMaskTap configs provides the user with a visual indication that they can tap anywhere on the screen away from the panel to close the panel. The height and width configs take any CSS compatible pixel or percentage value. You can use maxHeight and maxWidth to loosely define hiehgt and width if you are not using the optional scrollable config.

A tricky piece is the scrollable config. It defaults to false and requires strings such as ‘vertical’ or ‘horizontal’ do indicate the direction of scrolling allowed. If you not explicitly define a height and width config, however, your panel will be displayed as a jumbled mess. This behavior is not officially documented at all, however this Sencha thread discusses the issue.

To show the panel on the tap of a button, you use it in your controller (or listener) like so:

Ext.define('App.controller.PanelDemoController', {
    extend: 'Ext.app.Controller',

    config: {

        control: {
            myButton: {
                tap: 'myButton_tap'
            }
        }

        refs: {
            myButton: '#myButton',
            floatingPanel: '#floatingPanel'
        }

    }

    myButton_tap: function(button) {
        this.getFloatingPanel().showBy(button, 'br-tc?');
    }
});

The Ext.Panel.showBy method automatically builds a frame around your panel and an arrow pointing at the button passed in the first argument. The second argument is a cryptic string:

  • The first two characters describe the arrow’s placement relative to the panel, in this example “bottom right”
  • The two characters after the dash describe the arrow’s placement relative to the item tapped, in this example “top center”
  • The final ? is optonal and forces the panel to be visible within the bounds of the Viewport. Omit this at your own risk!

The decoder ring for these strings are located in the Ext.Panel.showBy documentation.

I know this dosen’t describe everything floating panel related, such as using the Exp.Panel.show method or quirks using forms inside of a floating panel. Perhaps I will get to this down the road!

Weight Loss Update

Just a quick update on how things are going:

  • I’m down to 193.5 lbs as of this morning for about 7 pounds lost so far. A rate of loss a little over 3 pounds per week.
  • I don’t trust the accuracy of my own waist measurements, but I can tell you that I now comfortably fit into the size 34 khakis that I have been avoiding for about a year!
  • This week I’ve switched up my weight lifting routine, since I’ve been on it for 6 weeks and the body becomes efficient and adapts to the same movements over and over again. Syd found a great web site / mobile app called GAIN Fitness which has a “Quick-Workout” function. Much like iTunes Shuffle, it creates a custom workout on demand based on the muscle groups you are working, how much time you have, and what equipment you have available to you. I did a Chest & Back routine today that was auto-generated by the tool and it was pretty good. I may stick with this one, as it creates muscle confusion which is a key to any long-term muscle growth strategy.
  • I’m paying a return visit to the dietician this Friday. I predict there will be a reduction in my daily average calorie limit to help keep up the current weight loss pace. I’m excited about getting under 190 pounds and eventually around 180 pounds!

Weight Loss Food Strategies

I wanted to quickly share some strategies I’ve come up with in the past few days that have been a big help!

Protein

One gram of protein per pound of bodyweight is not easy to achieve throughout the day. Here’s how to make it easier.

Optimum Nutrition 100% Whey Gold Standard is the hands-down best tasting protein supplement on the market in my opinon. It’s also great from a protein-to-calorie ratio, coming in at 120 calories and 24 grams of protein per scoop Combined with a BlenderBottle, you get a pretty tolerable shake. Learn to like it with water instead of milk and you dramatically cut calories.

Optimum Nutrition also makes a Natural version that I’ve been using for about a year. It’s not quite as tasty, however it has no artificial sweeteners.

Be sure you are also getting protein from whole foods. I include eggs, yogurt, chicken, lean beef, pork, fish, and turkey into my diet for all three major meals. Combined with 4 scoops of protein per day, I usually have no problem getting over 200 grams of protein.

Fiber

Getting 35 grams of fiber today seemed almost impossible! Then I found this list from the Mayo Clinic listing high-fiber foods.

Lentils are an absolute fiber powerhouse! I cook an entire bag of Publix Dry Lentils for 30 minutes, refirgeraet one half and freeze the other. Each half gives about a week’s worth of 1/2 cup servings, which contains 18 grams of fiber and 16 grams of protein!

The other trick is to get some other high-fiber foods in during the day. Black beans are another fantastic source, as well as apples, pears, peas, and brocolli.

Combined with eating plenty of veggies during the day, I’ve hit the goal no problem.

Snacks

I have a major love of nuts and peanut butter. When I found powdered peanut butter like PB2, it was total shock and awe! Two tablespoons are only 45 calories. Mixed with about 1.25 tablespoons of water, it makes a peanut butter that has a similar taste to “natural” peanut butter, but for about a quarter of the calories! It’s also great mixed with protein shakes.

Laughing Cow spreadable cheese wedges are another good bet. Each wedge is 25 calories.

Pickles. Gotta have pickles.

We bought an Ice Cream Maker because we love our deserts but wanted to control what’s in them. So far, we’ve made a Raspberry Sorbet and Cake Batter Ice Cream, each one being around 150-175 calories per half cup serving.

Weight Training for Noobs

In my last post I mentioned three edicts from the dietician:

  • Consume 1 gram of protein per pound of body weight, and supplement as needed.
  • Three days of weight lifting minimum, even if it means dropping a day of cardio.
  • Higher intensity, more challenging lifts with heavier weights.

Let’s dive into why these are important! First, let’s examine what weight training does.

Resistance exercise is any excercise that requires contraction of your muscles to perform movement against an opposing force, such as gravity. Examples can be body weight exercises such as Push-Ups, Pull-Ups, and Crunches. Examples can also be free weight exercises like Dumbbell Bicep Curls or machine exercises like Leg Extensions.

When you perform resistance exercises, you are essentially causing controlled damage known as microtears in your muscles. As you continue to keep your muscles in a state of contraction, these microtears continue to develop. By performing exercises with proper form and technique, muscles can be isolated and exhausted to their fullest.

Using weighted exercises allows you to adjust the resistance to a level that continues to challenge your muscles. When weight training, make sure you log every workout and strive to add weight each session. DO NOT train the same muscles every day! I break my sessions up by muscle group – one day for chest and shoulders, one day for legs, one day for arms and back, and core / abdominal exercises on cardio days.

So what’s up with the protein? As you give your muscles a very important 2-3 days of rest after weight training, your body uses the available protein in your system to repair the muscle microtears. The repairs essentially fill in the spaces left by the microtears, adding size and mass to your muscles. With a steady and ample supply of protein, these microtears are repaired faster and with greater density, essentially adding new muscle. In fact, studies show that you should strive to consume protein immediately after completing a weight training workout, as the body begins the repair process immediately!

Why drop cardio in favor of weight training?
* As you add more muscle, your metabolism increases, raising your resting metabolic rate and allowing you to consume more calories.
* Weight training has been shown to cause your body to burn more calories than cardio, with increased calorie burning occuring for long after your workout is complete.

One last tip: train to “failure!” Failure in weight training is defined as not being able to perform one more repititon of an exercise during a set of repitions while using the correct form and technique. If you can bust out 3 more shoulder presses without swinging the weights up, you haven’t hit failure and need to keep going!

That’s it for now, more to come!

Weight Loss and A Visit to the Dietician

Most people who know me well know that I have a major knack for constantly being on-and-off different diets and being generally obsessed with my fitness level and weight. I come by it honestly! Frankly, I have to stay on top of it. My immediate and extended family leans toward the slow metabolism side, and my family history is chock-full of weight and fitness related health issues, including high blood pressure, high cholesterol, diabetes, arterial blockages, and stroke.

I’m a typical American who loves junk food. Perhaps in part because my mother (who is diabetic) only allowed my siblings and I to consume mostly sugar-free and artificially sweetened packaged foods growing up. I can eat a 16-ounce steak, two dozen hot wings, or a massive burger and super size fries like a boss, and finish it off with a milkshake and cheesecake.

On the other hand, I work out regularly. Since running my own business means I no longer have to commute to work, I’ve had time to get outside to run twice a week, and lift weights twice a week.

Even at 5′ 9.5″ and about 25% body fat, most people who know me cannot believe I have had an average weight of 205 pounds over the last year or so. I just happen to carry my weight well. My pants tell a different story; it has been a while since I have fit into my size 34 khakis.

Going by the Body Mass Index (BMI), the maximum weight I should be at to be “healthy” is 175 pounds. I think BMI is a load of crap as it is completely misused today and most professional athletes are considered “overweight.” My goal is to get down to 180-185 pounds and lower my body fat to somewhere below 20%, ideally 15%.

On the referral of my doctor, who can’t figure out why I’m having trouble losing weight, I visited a registered dietician this morning. She told me some things I already knew but was cheating on, and I got some very interesting insight.

First step was to find out my true resting metabolic rate (RMR) – the number of calories I burn while doing absolutely nothing. I was asked to fast and rest for 4 hours before the test. The somewhat uncomfortable test involved a clamp to hold my nose shut and a snorkel-like tube to breathe through for 15 minutes. Afterwards I learned that my RMR was around 2450 calories, which was much higher than I had previously thought. It turns out my metabolism is way above average, which is great news!

I also had to provide a 3-4 day food log. The dietician told me that I was doing the 80% to maintain my weight, but in order to keep my muscle mass and get to a more reasonable weight I need to step it up and get the extra 20%. I need to:

  • Average 2100 calories per day over a week period, plus or minus 100 calories.
  • Consume 1 gram of protein per pound of body weight, i.e. 200 grams / day, and supplement as needed. (I had been inconsistent on this, usually maxing out at 150 grams on a good day)
  • Consume 35 grams of fiber per day and supplement as needed. (I was way under)
  • Only eat whole food that comes off a plant, out of the ground, or from an animal that swims, crawls, or walks.
  • If I must eat packaged foods, only use foods with 3-4 ingredients maximum.
  • Significantly ramp up vegetable and legume consumption.
  • Eat 6 times a day and have a balanced meal with at least two different macronutrients. (i.e.: proteins, carbs, or fats)
  • Continue drinking water at my current level – 160 oz / day  (20 cups or 5 x 32oz glasses)
  • Do not drink calories, i.e. only water, coffee, and tea without creams, sweeteners, or condiments. (except perhaps a splash of lemon or lime juice)
  • Exception to the no drinking calorie rule: simple / natural alcoholic beverages are ok in extreme moderation. (4-5 drinks per week, 2 drinks a day max, no “alco-pops” or drinks with sugary or artificial mixers)
  • Three days of weight lifting minimum, even if it means dropping a day of cardio. (More muscle means higher metabolism, and you continue to burn calories after weight lifting, unlike cardio.)
  • Higher intensity, more challenging lifts with heavier weights. (It’s almost time to switch from my 3×12 split routine anyhow, so perhaps I’ll go back to a 5×5 split with new lifts)

It seems like a lot of rules, but I was doing most of this anyhow about 5-6 days a week.

My biggest struggle will be with my “cheat day” (In past diets I could eat anything I wanted for 24 hours, usually Friday night – Saturday night) and snacking during the week. The dietician said that I could cheat, preferably one meal, and preferably within the weekly calorie limit. The dietician also said that if I follow the plan without cheating I could reach my goal in 6-9 weeks but cheating will slow things down, so we’ll see.

So there you go. It’s a long post – perhaps my experience will help you! I’ll keep the blog updated with my progress, which you can also follow on My Fitness PalFitocracy and Nike+.

DISCLAIMER: This diet was tailored exactly to my personal situation after having my RMR tested by a professional. If you are planning on trying to follow this diet, note that your caloric needs will be different based on your own base metabolism. As a very, VERY rough estimate, you can try calculating your RMR, then use that to calculate your needs based on activity level, then determine a daily calorie max for weight loss. Be very careful, as dropping your calorie level lower than 1800 calories/day for men or 1200 calories/day for women should only be done under the guidance of a physician.

Sencha Touch 2 Quirks: Controller refs, ComponentQuery, and using id vs itemId

The Sencha Touch 2 documentation is absolutely brutal. I am going to keep track of the quirks I resolve on the blog to hopefully help myself and others.

In this edition: A fun, poorly documented quirk involving controller refs and ComponentQuery.

The Ext.Component documentation encourages the use of the itemId config over the id config due to the global nature of using id. According to the Ext.ComponentQuery documentation,  a query using a leading “#” in the selector string is supposed to match the id or itemId defined within the config of an Ext.Component you would like to reference. Except that is not the case.

Buried in the somewhat un-friendly dungeon known as the Sencha Touch 2 forums, the resolution to a bug report states that Ext.ComponentQuery can only resolve a component using itemId if a parent component is referenced in the query!

So let’s say you have:

Ext.create('Ext.Panel', {
   itemId: "parentPanel",
   items: {
      itemId: "childPanel",
      html: 'Child Panel',
   }
});

Ext.ComponentQuery.query('#childPanel') will not work, but

Ext.ComponentQuery.query('panel #childPanel') and

Ext.ComponentQuery.query('#parentPanel #childPanel') will work.

Controller refs are essentially an alias for an Ext.ComponentQuery selector string used within a controller, so this issue directly applies to Ext.Controller. This particularly comes into play when you try to create a ref by itemId to a view separated into a dedicated file, since you have to switch to the id config or include a reference to the main view component in your app.js to get a reference.

Overcoming IT Skills Gaps

Over the past five years, information technology has taken a huge leap. Mobile development, HTML5, the rise of dynamic software languages, agile and lean development methodology, cloud computing, and infrastructure virtualization are just a few of the areas that have seen massive growth. In many CIO / IT Executive circles, many feel that a skill revolution is around the corner. I believe they are late to the party; the revolution has occurred around them. The majority of the industry is playing catch up.

During the “Great Recession,” many IT departments slashed budgets, investing only the minimum to keep legacy systems on life support. IT professionals were asked to work longer hours maintaining systems based on technologies that are now in a range of 5 to 20 years old. Time and funds that were used for staff training and certification dried up, leaving IT professionals to fend for themselves. A gap has formed where many IT pros have mastered the skills of the 2000′s but have had zero exposure to the landscape of the 2010′s.

Today, the IT sector has recovered from the recession and hiring is at an all time high. A colleague of mine who is a partner in an IT staffing business explained to me that here in Atlanta, there are about eight open positions paying over $100,000 annually for every one senior-level Microsoft .NET developer. If you dig deeper, what is truly happening is that companies are now trying to accelerate to today’s technology, and even senior level IT professionals are not meeting the job requirements they desire.

Interestingly, the IT professionals (including yours truly) that consider themselves to be free agent “mercenaries” are now the most qualified. What traits do these technology soldiers of fortune possess that all IT professionals should have in this new world?

  • An understanding that there is no such thing as “permanent employment.” Take some time to read Pamela Slim’s Escape from Cubicle Nation for numerous illustrations of this.
  • Recognizing that IT outsourcing is the future of the industry. Information Technology departments are shrinking, even with the available job openings. Companies are outsourcing everything IT related. Cloud vendors make it possible to have minimal hardware infrastructure. Offshore development firms are as affordable as ever. IT operations can easily be handed over to vendors. IT consultants are hired to shore up major skill gaps. Position yourself as a vendor, even if you take a “permanent” position.
  • Valuing communication, business fundamentals, leadership, strategy, and customer service over technical prowess. It’s easy to find people who can configure a router, create a virtual machine, back up a database or code in any language you want. I build my teams around great people, not just great technical skills. Spend as much time learning project management, business analysis, business fundamentals, leadership, and customer service as you do technical skills.
  • Taking full responsibility for your own career development. Understand that companies are scared to provide training unless there is an immediate benefit to them. Purchase your own books and training courses. Free resources – from books, to videos, to even free cloud infrastructure – are abundant. Understand that in today’s IT, you must sacrifice your free time at some point – choose to spend it learning marketable skills and concepts.
  • Generalization over specialization. Finding a niche in IT is a great way to work yourself out of a job. Just ask ColdFusion, Adobe Flex, or Silverlight developers, all whom have seen their technologies of choice pulled out from under them like an old rug. Diversification is as important in your skill set as it is in your 401(k).
  • Following emerging technologies and methodologies very closely. We followed the emergence of Model-View-Controller frameworks, dynamically-typed languages, and Scrum seven years ago. Today, these are all mainstream concepts. Start learning about tomorrow’s technologies today.

The Essential Reading List for Every Software Professional

There was once a time where the only books I would read would be 500+ page technical books. Books with titles like “Professional Programming in ASP.NET MVC 3 with Entity Framework.” These days, however, I have become quite a fan of many different leadership, time management, marketing, and business books.

Recently I was asked what books I would recommend to someone as absolutely essential reading. Without further ado, I present my Essential Reading List:

How To Win Friends and Influence People by Dale Carnegie: Yes, this book is very old, and the stories Carnegie tells feel very antiquated. Regardless, this book is essential for understanding how to truly engage people you encounter in any situation in your life.

Getting Things Done by David Allen: This book, commonly referred to on the interwebs as “GTD,” was literally life changing for me. Allen explains that all the junk in your head relating to the things you need to do on a daily basis distracts you from actually accomplishing anything at all. The GTD system is absolutely brilliant, showing you how to best organize all of the “action items” of your life and actually accomplish them without fear of forgetting something somewhere down the line. If you are “gifted” with any degree of  ADHD, as I am, this book alone will help you dramatically.

Personally, I combine GTD with The Secret Weapon framework for Evernote and the Pomodoro Technique to turbo charge getting things done.

The 4-Hour Workweek by Tim Ferriss: Want the ability to work for your your self from anywhere in the world with as little work output as possible at any time? It’s a little far-fetched for those of us who choose to have kids and pets, but the lessons learned in this book are fantastic. It’s a great blueprint for maximizing your productivity through minimizing distractions from meetings, email, and co-workers while setting up your own business.

Good to Great by Jim Collins: A classic business book examining the real-life qualities of leadership that build companies that can stand the test of time. Collins uses real empirical data mixed with classic metaphors such as the Hedgehog Principle and the Flywheel Principle to demonstrate what it takes to be a true leader forging a great company.

Be Our Guest: Perfecting the Art of Customer Service from The Disney Institute: This is a book I urge teams that I lead to read. It is a quick, easy read that highlights the customer guest service approach at Disney Parks. Be Our Guest explains what guest service is, the business reasons behind it, and the principles to execute on providing a fantastic experience. IT professionals commonly are thought of as back-office workers ”cast members,” when the truth is that we all have customers even inside of our own organizations that we must provide great service to.

Optional (though still essential) Reading:

Rework by Jason Fried and David Heinemeier Hansson: This book is a recent one for me, and I am tempted to move it to the mandatory essential list. The authors are the founders of 37Signals, creators of Basecamp, and (for DHH) the inventor of Ruby on Rails. It is a collection of essays that underscore very important themes. Limit office distractions, emphasize less over more, simplify instead of adding more features, realize that planning is just guessing, get started now instead of later, and learn from your successes instead of your mistakes.

The 7 Habits of Highly Effective People by Stephen Covey: A classic that I recommend reading immediately after How to Win Friends and Influence People.

EntreLeadership by Dave Ramsey: A great primer for those running or starting their own business. Ramsey inserts his deep spiritual beliefs into the book regularly, which influences his advice on hiring and human resources issues in a manner that I disagree with. Overall, I found the business content of the book to be excellent.

Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin: If you write code, you must read this book. You must understand this book. You should live this book.

Cross Platform Application Development in a Mobile World

The team at AtomicGarden has been working on requirements for a number of great upcoming applications for mobile and web-enabled devices. One of the requirements that has been the most difficult to define is the platforms the applications should support. Our combined team skill set gives us many options: HTML5, Microsoft Silverlight, Adobe Flash / Flex / AIR, Java, and Apple iOS, to name a few. The question then becomes this: do you write one cross-platform app for multiple screens, or write one native app for screen?

Option one is to simply write a killer HTML5 web app. One app to rule them all! (Ok, probably not.) My opinion on web apps is that with the introduction of app stores and marketplaces on mobile devices, a web app limits you to a desktop-only audience. For example, Mobile Safari on iPhone is a very deep HTML5 web app platform. Unfortunately, iPhone users probably won’t use a web app; on iPhone you can find, purchase, install, and begin using a native app from the Apple App Store in a matter of minutes.

Option two is to create an app using one of many cross-platform libraries. Adobe AIR, with its ability to package and deploy a single Flash or HTML application to web platforms, desktop platforms, Android devices, Blackberry Tablet OS devices, and iOS devices is a compelling option.  For example, Christian Cantrell demonstrates a cross-platform app using Adobe AIR:

Other options, such as the open source PhoneGap library, Appcelerator Titanium, or Ansca Mobile Corona, offer you various degrees of cross-platform flexibility as well. Write once, tweak a little for each platform, and deploy, right? Unfortunately, Flash is notoriously power hungry and crash prone, as well as immature on mobile platforms. They also offer tradeoffs such as varying degrees of documentation completeness, slower performance compared to native apps, and inconsistent user experiences compared to native apps. No one library hits all platforms yet; for example, none of these platforms have documented support for Windows Phone 7 today. With the exception of PhoneGap, all of these libraries incur substantial licensing costs above and beyond just getting your app into an app store. Finally, based on what Steve Jobs had for breakfast that day, you never really know if your cross-platform library-based app will make it into the App Store on any given day.

That leads us to option three: go native. Native apps give your users the user experience they expect on their device, with speed and responsiveness to match. With native apps, you won’t be denied from an app store because you didn’t use the language du-jour. The downsides here are obvious: for each platform you support, you must port and maintain code for each one. You need a team that can write in multiple languages, some of which may seem completely foreign. (Objective-C, anyone?) You will need a Mac if you have any intention of developing an iOS app.

At the end of the day, perhaps the best strategy is to market test individual products on a single platform and compare the traction they receive. If an app takes off, begin porting that app to other platforms.

What are your thoughts on cross-platform mobile development strategies?