DONN FELKER

Lessons Learned From the Software Industry

  • Home
  • About
  • Development Training
  • Fragmented Podcast
  • Learn to Work for Yourself
  • Contact

Connect

  • GitHub
  • Google+
  • Instagram
  • LinkedIn
  • RSS
  • Twitter

Powered by Genesis

WP Markdown Themes for Google Code Prettify

June 5, 2018 by Donn Felker Leave a Comment

Writing in Markdown is probably one of the best experiences you can have for a technical writer for a few simple reasons –

  • Its easy to write with
  • The limitations of Markdown are actually a benefit (less is more)
  • Theming can be applied

If you’re using markdown to write your blog posts, you can post them to your WordPress site if you’re using the wp-markdown plugin you can easily get code to show up in a formatted code block by simply adding the back ticks or tab spacing.

This is great, except the default theme is not the greatest.

Under the hood, wp-markdown uses Google code-prettify, which allows theming. Thankfully, many kind folks have created themes for code-prettify and shared them online. I found one I really liked here. The problem was, how do I get this theme applied to the wp-markdown plugin? It’s quite simple …

Applying a New Theme to WP Markdown

Important Note: Before modifying any theme or plugin files it is recommended that you back your site up just in case you completely bork something.

To update the theme you want to use on WP Markdown, simply go to your WordPress dashboard and then go to Plugins > Editor.

Plugin Editor

From there, you’ll select the WP Markdown plugin and then you’ll click Select.

Next, you’ll open the css folder on the right hand side and select the prettify.css file.

Once this file is open in the editor, you’ll take the theme CSS that you want to use (I grabbed one from here and modified it to my needs) and you’ll replace the prettify.css file contents with the file contents of the theme of your liking. Then you’ll click Update File.

Plugin Update

Thats it, your site should now be using the new code-prettify theme that you specified!

Caveats

Warning

You may have noticed that WordPress has this nice little warning:

Warning: Making changes to active plugins is not recommended.

This is true, you need to be sure what you’re doing here. If you edit the wrong file, you could completely host your WordPress installation. Be careful here.

Site does not reflect changes after updating the theme?

If you have any caching plugins, be sure to purge the cache. This can also happen if you run on sites like WP Engine, be sure to flush their cache. Also, if you’re running on a CDN, make sure the CDN file is updated. I had a CDN enabled and it was not picking it up until I flushed everything and reseeded it.

Updating the plugin will probably destroy your changes

When you you update a plugin, a new version of the plugin is downloaded and installed over the top of the old one (more or less). This can, and usually will wipe out any changes you made to your plugin (Ala what we did in this post). To make life easier, save the css that you put into the prettify.css file into an online site like gist.github.com so that when you do update your plugin you can easily repeat these steps with your updated theme (because the plugin update will wipe out your updates).

Enjoy!

Filed Under: Development, Marketing, Misc Tagged With: markdown, wordpress

Your First Test: The Launch Test

March 6, 2018 by Donn Felker 1 Comment

I get it. Your application (mobile app or web app) doesn’t have tests and … well … you’re scared anytime you make changes.

Why? … well … because you’re not sure if you broke anything when you commit that code.

I encounter this a lot in the realm of software consulting.

There’s one simple way to remedy fear in your development lifecycle – tests.

The more tests you have, the more confident you will be that you didn’t screw anything up.

Yeah, Ok, I get it, but what if I don’t have any tests, where do I start?

Great question.

The first test you need to write is a Launch Test.

A launch test is a functional test that runs on your continuous functional server (or even your local machine if you don’t have CI yet) that confirms that the application you just compiled/etc will actually start and you can hit the home screen/home page of the app.

Simply check that your home screen text is showing as you would expect it to show and that certain key values are present. Simple. Done.

Hold up … but I know I didn’t break my home page. Why should I test it? Why is this important?

You said you didn’t have any tests. Are you sure you’re sure you didn’t break it?

Thought so, probably not.

The reason why this is important is that you may have made a change to the dependency injection code that uses reflection that does something at runtime that would only be exposed when the app is run.

What would happen if you didn’t catch that in development?

💥BOOM! CRASH! 💥

Exactly.

Furthermore what this first functional test does is give you a starting point. It gives you a jump off point. It’s your first test of many.

Yes, it might hit production servers. Ok, when you test manually you probably were hitting production servers too. Yikes. It is what it is.

The key thing to remember here is that you now have a test covering you to ensure your app launches.

What to Test Next

Ultimately the next thing you should be testing is your most used screens:

  • Home/Main Screen
  • Customers
  • Orders
  • Etc

Once you get some tests around these screens (do they load, do they work when interacted with) then you can refactor.

Refactor with Confidence

That’s the key takeaway here. Tests give you the confidence to do work that otherwise might be overly stressful and risky because you’re not sure what you’re breaking.

Functional (and integration) tests are the best place to start because they’re true end-to-end tests and they mimic what the end user is going to see and this is important because …

Nothing else matters more than the end user experience.

If the end user sees a screen that’s broken, gets a crash, or sees incorrect data they’re not going to be happy and they won’t give two cents that your app is powered by AI with advanced machine learning to render results from a globally decentralized blockchain network running on Ethereum.

User’s don’t care about your cool tech stack if your app doesn’t work.

To the user, if the app doesn’t work, it’s garbage.

… and …. well … at that point, let the 1-star reviews come flooding in.

So … if you don’t have any tests, start with some functional tests and then you can refactor with confidence and then and only then should you introduce more testing mythologies into your app.

 

PS: If your app is an Android app, quickly set up an Espresso launch test with the Espresso Test Recorder. Sam Edwards has a great course on it here.

 

Photo: Ehud Neuhaus

Filed Under: Development Tagged With: programming, Testing

I Don’t Have Time is a Myth

November 6, 2017 by Donn Felker 18 Comments

I Don't Have Time

“I don’t have time” is a myth.

The statement, “I don’t have time”, really gets under my skin.

Why? Because you do have the time.

Get up early. Cant? Go to bed earlier.

Stop watching TV shows and YouTube channels that do nothing to help you progress in your dreams.

Stop playing video games.

Stop going out to the bar.

Stop wasting time reading news websites, Reddit, surfing Facebook or Instagram for hours.

You have the time. Its right there in your hands. Use it.

How much time would you get back if you stopped doing all of those things above? You’d be blown away by how much time you’d get back. In fact, let us dig in a little bit deeper …

Watching 45 Days of TV Per Year 👎

The average American spends 3 hours a day watching TV.

3 HOURS A DAY!

Some reports show an upwards of five hours a day.

Let us be conservative and stick with 3 hours.

That’s 21 hours a week!

90 hours in a month!

1,095 hours in a year.!

That’s over 45 days of watching TV for 24 hours straight!

This is just watching TV. This does not include time spent looking at your phone!

That’s just insane.

“I don’t have time.”

 

Pffft. Whatever.

 

No, you do have the time – you’re just choosing not use it for the things you say “You don’t have the time for.”

The magic of time optimization

Is life hard sometimes? Yes, it is. Oh god yes. It can feel completely overwhelming and you might feel like you can’t get a breath. But … you still have time … if you don’t waste it.

Single mothers and fathers exist and they make magical things happen. They work multiple jobs, have little or no help from family and they have to do everything themselves. Somehow, they make magic happen.

You know what? I bet you most of these folks have “more time” than most.

Why? How?

They optimize their life to maximize their time.

Furthermore, I bet you they read more books than most too.

Imagine being one who catches the bus at 6:30 am after dropping the kids off at early-drop off and/or daycare/preschool. So what do they do with that next 10–30 minutes of commuting time (before and after work)? They probably use that next 10-30 minutes to listen to a book or podcast or watch a video tutorial that they downloaded on their phone instead of passively looking out the window or on FacebookInstagramRedditNewsetc.

They have the time & you have this same time.

Maybe you don’t commute via train, maybe you drive to work.

Same thing.

Use that time to learn, grow, etc. Maybe you work at home? That’s cool. Listen to books/podcasts while driving/walking to the grocery store or dentist/or wherever you’re driving.

For example, let’s think about the time in the shower. Could that be put to use? Hell yes, it can. Put an audio book on while you’re in the shower. That’s 10-15 minutes a day. 10-15 minutes a day for 30 days is 5 to 7.5 hours. You can easily listen to a book a month simply by listening to it in the shower. Use the Audible app to download books and listen to them on the go.

“I don’t have the time.” Yeah. Ok.

“… but I don’t have time to eat healthy and work out”

Maybe you want to work out and get yourself into better health and don’t have time for the gym. I get it. Do a bodyweight program by any number of fitness trainers 3-5 days a week at home. There a TON of them online for free. Eat salads for lunch. The best shape I got into in my life I worked out two days a week and ate healthy (salads and steamed veggies). The diet did more for me than working out did.

Maybe you don’t have a ton of time for meal prep. Ok, I get it. Then follow intermittent fasting – it helps you learn how to control your hunger and is proven to be very good for your health. Fewer meals to prepare – eating less and improving health? Yes. I’m in. Eat steamed veggies from the microwave for two meals a day with lean grilled meats. Do a meal prep day on Sunday. There are always options.

I once knew a girl in college who would cook beans and rice every Sunday and have that for lunch because she didn’t have time to make lunch every day and bring it to college. She did the work on Sundays. She found the time, owned the problem and fixed it – even on the cheap.

Finding Time is Easy

Finding time is easy if you look hard enough. It’s everywhere. 10 minutes here, 15 minutes there. Before you know it you have an hour or two each day you can use.

If you feel like you don’t have time try to find all the spaces where you’re not doing anything (dentist office waiting, doctors office waiting, at a kids drama practice, waiting) and then use that time to push the ball a little further down the field. I bring my laptop everywhere, just in case I have a free moment to crank things out. In fact, I’m writing this post at my accountant’s office this AM while he’s preparing some documents for me.

I’m not saying to give up that time you spend with your family. That has importance too. Maybe one of your goals is to be a great parent and/or spouse. Then execute on it and find the time to be a great parent. Use the spare time for that. Same for anything else that you find that you want to accomplish. It doesn’t have to be “work” or “business”. If you “don’t have time to walk the dog”, then stop surfing Facebook or Instagram while you’re on the toilet (you know you do it too).

The moral of the story is – you do have the time, it’s most likely being wasted on needless activities that provide no real growth value to you.

Tips

One thing I advise is to try to get up earlier – before anyone else. I’ll admit, it’s not easy. One thing I do the night before is write down a couple of things I want to get done before everyone else gets up (could be work out/run, get task x done, read, work on your project, etc). You get such a head start on the day that you feel positive and happy.

Can you do the same at night? Yes, for sure. Maybe you’re a night owl and get most your work/etc stuff done from 9pm-3am. That’s fine too. However, I will say this – when you’re tired, it’s much easier to simply go to bed and miss out on those hours. When you get a head start at the beginning of the day you start off on the right foot. Waiting to get some stuff done at the end of the day can sometimes fall apart (bad day, super tired, made a bad decision by having few too many at happy hour, etc).

Next, focus on whatever you want to accomplish and execute until it’s done. Don’t lose focus. Do not get distracted. Kill all external distractions. Complete the task at all costs. Striking an item off a to-do list (even if it is mental) is a huge win. Build upon these wins and snowball them.
Be obsessed with your passions and goals. Its ok to be that way. Do you want to be the best parent in the world? Go do it. Don’t let anything stop you. Do you want to be the best long-distance marathon runner? Go do it. Do you want to be the best rheumatologist in the United States? GO. DO. IT.

No one is going to give you anything. You have to get it yourself. You have to take the risks. You have to make it happen. To do those things you’ll need to find the time and trust me, you have it.

 

Make it happen.

 

 

Photo credit: @loic

Filed Under: Business, Health, Misc Tagged With: Goals, Life, Productivity

Android MVVM with DataBinding – Removing Logic from Your Views with BindingAdapters

October 20, 2017 by Donn Felker 3 Comments

One of the things that’s great about MVVM (I’m using data binding in my implementation) is the lack of the boilerplate that you have to deal with. When working with the MVP pattern you are forced to deal with an obscene amount of get/set boilerplate code. Sure, this does make your UI logic more testable but it doesn’t get around the fact that there is a lot of boilerplate.

While MVVM with Data Binding does remove a good deal of this boilerplate you also run into new issues where logic is now present in the views, like this:

<TextView 
    ...
    android:visibility="@{post.hasComments ? View.Visible : View.Gone}" />

As Joe Birch accurately pointed out in his article –  this has a code smell and it just feels gross.

The logic is now buried in an Android XML view and its near impossible to test unless you’re rigorous about your Espresso tests … and let’s be brutally honest here… you’re not rigorous about your testing.

Removing Logic from XML Views with Custom Binding Adapters

Removing logic from XML Views is quite easy with custom BindingAdapters. Early adopter and DataBinding aficionado, Lisa Wray, posted about this back in 2015: Pro tip: More data binding — Easy view visibility in XML! I heard you guys l….

In short, you create a binding adapter in Java (or Kotlin as I’ve done below) and drop it into your project.

@BindingAdapter(“isVisible”)
fun setIsVisible(view: View, isVisible: Boolean) {
  if (isVislble) {
    view.visibility = View.VISIBLE
  } else {
    view.visibility = View.GONE
  }
}

The logic for showing a view is now determined by a Boolean value. To use this in an MVVM Data Binding XML View you’d do the following in your view:

<TextView 
    ...
    app:isVisible="@{post.hasComments()}" />

The logic for the hasComments code is now kept inside of the View Model which can be easily unit tested.

Testing the Custom BindingAdapter

We may have removed the logic from the XML view, but we still have code that needs to get tested. Now that the view logic is based upon a Boolean we can easily test this with an Espresso test:

@Test
fun isVisibleShouldBeEasilyControlledWithABoolean() {
  val v = View(InstrumentationRegistry.getTargetContext())
  setIsVisible(v, true) // visible
  assertThat(v.visibility).isEqualTo(View.VISIBLE)

  setIsVisible(v, false) // gone
  assertThat(v.visibility).isEqualTo(View.GONE)
}

You’re going to put this in your androidTest folder.

I know what you’re thinking – this is an Espresso Test, it runs slow. Not really. You’d be surprised at how fast this test runs as it does not need to fire up an activity and start clicking on buttons/etc.

You now have logic that can (and is) tested via a simple test. Your display logic is then kept inside of your View Model (does a post have comments or not, that’s a fairly simple true/false boolean).

Furthermore … your ViewModel is not riddled with Android package references (which can make it harder to test). Which brings me to …

Keep the ViewModel free of Android Dependencies

One goal that I have is to keep the View Model free from Android Dependencies if at all possible. This allows me to utilize JUnit unit tests for a quick feedback loop. I can write, test and iterate much faster with a unit test than I can with an Espresso based test.

Yes, you could put some of this logic into the View Models, but I find keeping it as clean a possible provides for the best possible outcome when it comes to testing.

As with everything, there are always caveats to this – using resource identifiers (as they’re only integers, etc). My rule of thumb is to try to avoid the Android packages in my view models. That way it makes testing a snap.

 

Filed Under: Development Tagged With: Android, Kotlin, MVVM, Testing

Make the Most of Your Time

September 14, 2017 by Donn Felker 5 Comments

Make the Most of Your Time
Photo: Uroš Jovičić

Recently, a  friend of mine asked if I wanted to partake in a small side project with him. Unfortunately, I didn’t have the time to commit to the project so I politely declined.

He responded with:

Dude I totally understand. I’m single at the moment and pretty much have my ass alone to take care of and I can barely remain afloat. You are a rockstar. I don’t know how the hell you can do it.

What he’s saying is that he has no idea how I get so much stuff done with my situation (Married, 2 kids, consulting, founding a company, a podcast, presenting, writing, 3 dogs, 3 cats, etc etc etc).

So how do I get so much stuff done?

Time optimization, 100%.

Don’t get me wrong … I’m not some zen-productivity-master, not at all. I just value my time.

The way I see it is like this:

Time is your life.

Life is Finite

One time I did an exercise that scared me: I took a look at the average life span of a US Male (~78 years) and I calculated the days I had left in my life.

Hint: It’s not that much. 😯

After seeing that number it catapulted me into action. To check yours go here: http://www.countmydays.com/

I’m not being morbid about life, it’s merely factual.

 

Seeing the Number of Days Left in Your Life is Scary

My friend replied back with a shocked face:

I calculated the waking hours I had left in my life.

Holy cow, this freaks me out … 😮

I know the feeling. Every time I look at the number, it’s smaller. 📉 It never goes up. 😢

Not many people look into how many days are left in their life. They should though – as it’s a humbling exercise. I think it’s important as it helps keep yourself grounded and keep your ambitions high because, well, your time is limited. You have less of it than you think.

There’s a popular blog post titled The Tail End in which the author draws little pictures of how many months, weeks and days he has left. He goes on further to outline how much time we have left with loved ones, time left doing things you love, face time with children, etc. Read it, it’s worth your time (pun intended).

You probably never thought about this, but around 90% of the time that you will have spent with your parents was done from the ages of 0-18. So if you have kids – remember this. My daughter just turned 9 and I realized that I’m already 45% through the average time that I will spend with her in our combined lives. That really sucks, but it also puts urgency into what matters – being with my children as much as possible and not taking it for granted.

So … Why am I harping on this so much? 

I’m doing so because your time here is finite. You only have so many at bats and then the game is over. That’s it. All done. Why not give it all you have, all the time? Why not chase those ambitions and dreams? Fix those broken relationships? Say sorry instead of being stubborn. You get what I’m saying.

The value of my time is a primary driver in my decision to work remotely. I know I only have so long with my kids, my wife, my family. Why waste that valuable resource commuting to and from work just to sit at a desk? To me, that’s absolutely insane.

Unfortunately, even though this information is quite eye opening, sometimes people will still avoid doing what they want to do due to fear.

Fear of failure.

Fear of rejection.

Fear of success (yes, it’s really a thing).

Break Down Your Fears and Do It

One of my favorite things to use to combat fear is to utilize a technique known as “Fear Setting“. I picked this up from Tim Ferriss, and you can watch a video on it here – Fear Setting by Tim Ferriss (Ted Talk). It helps you determine what you’re scared of and helps you realize it’s usually not that big of a deal. The video is very important, so please take a few minutes and watch it. Queue it up while you eat your lunch, etc. One of the quotes he uses in the talk is this one –

We suffer more often in imagination than in reality. – Seneca

This is so true. Using quotes like this and a mix of Stoicism to remind you of important things in life makes it easy to appreciate what you have, and how much time you have left and what you can do to maximize it.

Lastly, Steve Jobs has a quote that I often refer to:

Remembering that I’ll be dead soon is the most important tool I’ve ever encountered to help me make the big choices in life. Because almost everything — all external expectations, all pride, all fear of embarrassment or failure — these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked. There is no reason not to follow your heart. – Steve Jobs, Stanford 2005 Commencement Speech

I’m not a huge Steve Jobs fan, but this speech really helped ground me. I have a recurring calendar event every 3 months to watch this speech. It always helps course correct me when I’m wandering in the sea of life.

Yeah, I know … you’ve heard that life is short, but seeing it in numbers is humbling and action inspiring, no doubt.

So, how do I get so much done?

I remind myself that life is finite.

 


I’d like to thank Kaushik Gopal for reviewing this article.

 

Filed Under: Business, Health

« Previous Page
Next Page »
Donn Felker Google Android GDE Fragmented - An Android Developer Podcast

Projects / Apps

Caster.IO
Fragmented Podcast
American Express Android
Aaptiv
AndroidJobs.IO
Groupon
MyFitnessPal
Poynt

Books

  • Android Developer Tools
  • Android App Dev For Dummies V2 (V1)
  • Android Tablet App Dev for Dummies

Categories

  • Book
  • Business
  • Development
  • Health
  • Marketing
  • Misc
  • Mobile
  • Screencasts
  • Uncategorized