Why Your Team Shouldn’t Skip the Code Review

Mailbox with feedback written

In professional coding environments, it is common for us to have systems in place to check our work and verify that code written by one developer gets approved by others on the team. Review systems are a great way to ensure consistency and also raise flags and questions on better ways to streamline the work.

At a high level, this seems very straightforward — of course a team should be double checking work before releasing code! However, during times of tight timelines and pushes to do work fast, the temptation to skim over code reviews and merge without giving detailed thought can take over in order to save time.

There are obvious consequences to skipping over work-checking, but there are even more benefits that your team might be missing out if the code review is made a low priority.

Difficulty tracking down bug sources

Bugs happen. While every organization and team would like to think that they have golden code, it is inevitable that at some point, some piece may need to be changed or iterated on due to mistakes or even changes to dependencies. However, when code reviews are skipped, the ability to track down when and where a bug was introduced could potentially become more difficult.
In most cases, the team uses a form of source control, which helps track down sources. However, it becomes much easier to figure these things out when more than one person on the team has an idea of what pieces of code were touched, when, and by which team members. The most efficient way to do this is by consistently having peer code reviews before each pull request is merged.

Loss of consistency in code

For larger teams, having a consistent method or style of code is desirable. Following a convention can help streamline the way code is written, and make it easy to collaborate with other developers, and even other teams within the organization. When code reviews are skipped, it becomes easier for code to creep in that does not follow a specific style guide or method, or even duplicates something that is already there. This can cause issues down the road when methods are changed, or new developers take on work that results in a steeper learning curve than is expected.

Missing out on learning and growth opportunities

One major benefit of consistently having members of your team review other’s code is the amazing learning opportunity it brings. This goes both ways on the code review.
On one hand, the developer being reviewed can learn new techniques from their peers and also pick up good habits by having issues in their style, logic, and overall code pointed out to them with actionable solutions. On the other hand, reviewing someone else’s code can help open up new solutions that hadn’t been considered before, and enables a more collaborative effort to own the codebase, not just specific pieces of it.

Skipping code reviews can actually end up costing your team time

In some cases, skipping the code review will cost you more time than it will save. Let’s consider the most obvious issue with ignoring the code review process. Even the best developers can miss things in their code and make mistakes. When these issues fly under the radar and make it into production level code, or a developer has built code under the wrong assumptions, this can actually cost the team time. The team will then have to go back, find the issue, and possibly rewrite sections of code in order to fix the assumption. As this Atlassian points, out, there are other reason why poor reviewing can cost time.

In conclusion, while forgoing a code review or moving away from the process can be tempting sometimes, its most likely not going to save you time, or make your code better. Even a quick code review process for each pull request can help your team stay on the same page and stay accountable for their work. If you have additional thoughts on code reviews, or even some comments on when you don’t think a code review is necessary, We would love to hear your thoughts in the comment section below!

4 Ways to Reduce Workplace Eye Strain

If you have found this article, chances are you spend quite a bit of time staring at a computer screen.  Perhaps you even get headaches and fatigued eyes like me.  On long days, I might use my computer for 10 hours out of the day trying to get pressing work done.   While I will admit this is not particularly healthy, it sometimes seems unavoidable with project deadlines and work responsibilities.  After frequently getting migraines after some of these long, stressful days, I decided that enough is enough.  I started doing a bit of research on how I could minimize the effects and give my eyes, brain, and mind a break while still getting the work I needed to get one.  I am happy to say that with these 4 tips in this article, I have greatly reduced the amount of eye strain in my daily work life.

Adjust your display

If you are frequently getting eye fatigue from working long hours at the computer, consider changing the screen settings.  There are a few ways you can adjust the display, but the ones that may make the biggest difference from eye strain are the brightness and the color temperature.

  • Brightness:  If the brightness on your display is much brighter than your surrounding work station, it may be causing eye strain.  Turn the brightness down so that it isn’t noticeably brighter than the rest of your desk.
  • Color Temperature: “Blue Light” is frequently blamed as the top cause of eye strain.  To turn down the amount of blue light coming out of your display, switch to a more “warm color” display.  It will look slightly red/orange compared to the default settings.

Stay hydrated

When in doubt, drink water!  While most of the article is focused on the screen time aspect of eye strain and headaches, being dehydrated will make any strain you have worse.  Dehydration is one of the causes of headaches, and in general will make any day more difficult.  It’s possible that the best thing you can do for yourself is to drink a big glass of water.  One thing I find that makes it much easier to stay hydrated is to have a reusable water bottle take to work.  Personally, I prefer one with a handle on top so it can be easily carried to meetings while also carrying a laptop. 

Step away from the computer 

Okay, I understand that this contradicts some of what I was just saying.  However, for a lot of us, there are times of the work day when we are working, but we don’t really need to be staring at the screen.  Maybe you are in a brainstorming call, or you are thinking through a problem that could be done on pencil and paper, or you are discussing a project with a colleague.  These are good times to just walk away from your work station and take a walk, go to another work area without a screen, or 

Get a pair of “blue light” glasses

Out of all the things on this list, this personally made the biggest difference for me immediately.  Blue Light is a certain kind of light that comes out of screens (computers, monitors, TVs, and your phone all emit blue light).  It has been shown that blue light is what contributes most to eye strain and fatigue.  Naturally, one way to cut down on eye strain is to purchase a pair of blue light blocking glasses.   While they sound futuristic and fancy, you can actually pick up a pair at a very reasonable price.  I personally bought the following plastic pair by Gamma Ray for $15 and have had it for over 2 years.

The pair of Blue Light glasses I bought was only $15, but if you need prescription lenses, or prefer a designer frame, or want a step up there are certainly options for that as well.  For example, the LensCrafters site shows a nice collection and a few different variations of blue light lenses, including prescription glasses.  However, your local optometrist or eye glass store will likely have these as well.

If you have found this article, you are probably in need of a change in your life to help out with migraines or eye fatigue at work.  I encourage you to adjust your computer display, pay attention to your hydration, remember to take breaks, and consider the eye glasses.  Best of luck and happy coding!

How will autonomous vehicles effect our society?

For decades, science fiction books and television shows have depicted a world where vehicles are either flying, autonomous, or both.  These days, it’s estimated that 95% of new car productions will be for autonomous vehicles by 2040.  Now that self-driving cars are very much a reality, the question beckons, is trusting AI to drive our cars for us really a good idea?

Red Luxury Vehicle driving through Forest

Scientific evidence shows that the benefits to mankind are in the numbers.  With breakthroughs in deep learning, algorithms are able to detect if another vehicle is close, what speed the car should be going at to be safe, and how to stay perfectly within the lanes using image markers.  In addition to vehicles being capable of driving themselves, it can also be argued that self-driving cars will be much better drivers than humans due to their inability to become distracted.  Humans are notoriously bad at staying focused on driving when there is a text message to answer, they have been driving for long hours without sleep, or there is a crying baby in the back seat.  Additionally, concerns also arise around drivers who are reckless, upset, or under the influence of a substance that affects motor skills.

Taking this into consideration, the evidence seems very supportive of self-driving cars.  A refined algorithm has the ability to be a better driver with less accidents and deaths than less-than-perfect humans.  However, there may be other consequences to the takeover by autonomous vehicles that may have a significant societal impact.

Teen Driver in convertible

In the United States and other countries, earning a driver’s license can be viewed as a cultural “Right of Passage”.  The milestone signifies that the individual can now transport themselves without supervision of an adult. To get a license, the maturing teen needs to prove that they understand and respect the rules of the road and can pass a driver’s test.  Driving also carries responsibilities that most teens have not yet had to consider in their lives. Following the law, adhering to the rules of the road, vehicle maintenance and attention to self preservation all have immediate benefits to their well-being.  Earning a license for teens can be a significant “transition period” between child and adult and helps prepare them for when they will leave home to pursue college or other endeavors on their own.   Considering this transition phase to be important in teen development, it can be argued that switching to a society where learning to drive is obsolete may have a negative effect on younger generations.   

In conclusion, the societal and developmental impacts of a self-driving society is an important to consider.  Earning a license as a teenager is something that has become ingrained into our society since the automobile was invented, and changing the way we drive will inevitably impact the way humans develop into responsible adults.

What do you think?  Feel free to comment below.

How to Choose the Best Text Editor for Programming

Chances are, you’ve found this page because you are trying to choose a text editor to use and are a bit overwhelmed sheer number of them.   While there are many text editors that can get the job done, we’ve narrowed it down to a few favorites. Whether you are a new developer or a complete pro, we will help you find the best text editor for programming you style of code. 

If you need something simple, and are on a windows machine, use Notepad++

Notepad++ Text Editor for Programming

Notepad++ is a great editor for any skill level, as it is lightweight, clean and simple. 

Pros

Notepad++ is built on C++ and boasts a small program size.   I personally recommend it to programmers who are new and want something that is a step up from notepad, but don’t necessarily need to fully customize the editor and use every bell and whistle.  The UI is easy to use and the editor runs quickly. 

Cons

The biggest con here is that Notepad++ is only available on Windows.  Sorry Mac and Linux users!  It’s also not as customizable as products like Atom and Sublime.

If you specialize in Front End Development or Web Design, use Brackets

Brackets.io text editor for programming

Brackets is specifically designed to use when working in the browser or on front end code.  Whether you are a front end developer or a designer, this text editor is ideal.  

Pros

One of the most practical and useful features of Brackets is the ability to easily switch from a class tag to it’s corresponding CSS.  If you are a front end developer, this can save a lot of time and searching for the correct file and class name.  While it has other great features and a clean UI, this feature alone is one of the reason why it’s on our list for the best text editors for programming.

Cons

If you do more than just Font End Development, you might want to look elsewhere.  While Brackets is awesome for web development, it falls behind when it comes to some other languages.

If you are old school and used to command line, use Vim

Vim logo text editor for programming

If you are reading this article, chances are you aren’t going to choose use Vim unless you already use it regularly.  Vim is popular with “grey-beard” developers who remember when things were simpler, or maybe more complicated.

Pros

Vim is included in Linux and Mac operating system command lines and is the most convenient if you are already hacking away in the command line on your operating system.  It’s also extremely fast as there are no fancy packages or additional features to slow down the processes.

Cons

Vim is not for those who want an editor that will point out syntax errors, display color coding, or show a full file structure in the left hand margin.  

If you want to add your own formatting rules, use Sublime Text 3

Sublime Text 3 text editor for programming

Sublime Text 3 is one of the top industry leaders for text editors.  It has some great features like package managing, preprocessing, and is lightning-fast.  It’s also unique in that it’s the only text editor on this list that has a paid version ($80).   However, you can use it for free if you download the “trial version” and never upgrade.

Pros

The package manager allows customization of a plethora of programming languages.  Sublime Text 3 also offers a comprehensive set of shortcut commands to use within the program as well as easy project switching.

Cons

I am not a big fan of having to pay for text editors.  While Sublime Text will let you keep the trial version for an indefinite time, you will receive popups every so often reminding you to pay for the premium version.  This is a big annoying, but if you don’t mind having to close out these alerts very often, then this is the best choice in text editor for coding.

If you want to add your own formatting rules, and you don’t want to deal with periodic popups, use Atom

Atom logo Best Text Editor for Programming

Atom is fairly similar to Sublime Text 3 in terms of the customization capabilities.  Like Sublime, Atom uses a package manager to import various packages such as beautify, which helps format your code in any languages, or jshint, which will show you possible mistakes and warning in your Javascript code as you type.

Pros

I’ll be honest, Atom.io is my personal favorite text editor for programming.  Atom competes with Sublime in terms of its package manager.  If you use a Source Control like GitHub, Atom will also help resolve conflicts on merges.  The biggest pro here is that it is completely free, doesn’t ask you to upgrade to a premium version, and there are tons of useful packages which make it easy to set up a productive work environment, no matter what languages you are writing it.  

Cons

Atom can be slow at times if you’ve got too many projects loaded.  If you aren’t very well versed in coding, package config errors can be time consuming and difficult to debug.

If you are a native developer, use Android Studio or Xcode

Luckily, if you’re a Native App Developer, you probably already know that there are recommended (or required) development environments for both Android and iOS. 

Android Studio is the best text editor for Android developers, as it includes automatic importing, hints, and comprehensive error messaging, as well as all the tools to build your app on emulators or your own device. 

Android Studio Best Text Editor for Programming

Xcode is essential for iOS developers, mostly because there is no way to build iOS apps and deploy them to your device without Xcode.  Xcode is only available on OSx, which means if you plan to develop application for iPhone, you’ll have to invest in a Macbook or a Mac in the Cloud.

Xcode Best Text editor for programming

Conclusion

Now that you know a little about our picks for the top text editors for programmers, it’s important to mention that there are hundreds of other options.  At the end of the day, as long as you are comfortable with your environment and are able to produce code the way you want, your preferred text editor is the correct one.  We’d also love to hear about your favorite text editor and why, so feel free to comment below!

6 Tips to Help you Learn to Code

How can I learn to code? Won’t a code academy or bootcamp break the bank?

I can’t tell you how many friends and family members have asked me this question at one point or another.  If you are reading this article, chances are you have the same question.  Maybe you’ve thought of an idea for a website or app you’d like to create, or you want to learn how to use a particular tool.  Everyone seems to have an app idea these days, but how can you gain the skills you need to implement it yourself?  

Luckily, there are literally thousands of resources and tutorials online that are completely free to use and can help you get started learning to code.  But if this is true, then why does it seem so hard to get started, and why hasn’t everyone picked up the skills?  Well, the truth is, learning to code or program when you have no prior knowledge usually involves a very steep learning curve.  Often times to really grasp how to create that first real application or website takes consistent work and dedication, and many failures before success. 

Many people tend to get discouraged and give up, or maybe it’s too time consuming to get over the learning-hump, or perhaps it just doesn’t keep their interest.  However, I’m going to let you in on a few tips that I suggest if you are a newbie to coding but are looking to either teach yourself or jump into some kind of program, bootcamp, or class for the very first time.

1. Learn by Coding a Project Hands On

The first piece of advice that I have for anyone who is brand new to development is that the only way to truly learn how to code is to make a project.  Sure, tutorials and reading are great and can help lead you in the right direction.  However, creating your own project where you are forced to debug issues on your own will help you get used to the problem solving process that is at the core of effective programming.  Creating something real will also help keep you motivated. If you don’t have any ideas right now, there are plenty of [idea lists](https://www.reddit.com/r/learnprogramming/comments/2a9ygh/1000_beginner_programming_projects_xpost/) that can give you some inspiration.

2. Take Advantage of Online Resources

If you ever get stuck in your work, come across errors in your code you can’t identify, or just need a reminder, Google it.  When it comes to debugging your code, getting help, and better understanding how to improve your projects, the internet is a goldmine.  Even seasoned developers will tell you that they use StackOverflow almost every day.  Chances are if you are coming across a problem, someone else already as also and has written the solution online.

There are also many many awesome free courses online.  MIT offers free online computer science courses, and other platforms like Coursera and Udacity have free programming video courses online.  If you would be more motivated when you pay, you might check out a program like Udacity where you get code reviews, mentorship, and a certificate afterwards.  If you feel like you need an intensive kind of course, you might consider a coding bootcamp or code academy.

UPDATE 7/15/2019: Right now, Udacity is offering $100 off their Nanodegrees with this special referral link! If you are on the fence, this is a good time to join (Offer is valid through Nov 30, 2019)

3. Find a Mentor

Although plenty of people have learned to code completely on their own, I suggest finding a mentor or colleague.  Having someone to help you with questions, encourage you, and occasionally give you tips can make your live so much easier and you have a much better chance of succeeding with someone in your court.  There are tons of reasons why having a mentor can make you a better developer, and they will also help act as a sounding board for your ideas.

4. Don’t Give up

This might seem obvious, but I thought I should reiterate this.  When I said there is a learning curve, I wasn’t kidding.  If you have some exposure to programming, math, and sciences, you might find creating your first webpage or application easier, but if you don’t, that doesn’t mean you are not cut out for it.  Programming is basically a series of logic operators and commands which go in a particular order.  The first time you are writing instructions for the computer this way, it can be difficult and confusing.  However, practice is what is going to get you there.  The other great part about this is that once you do learn one programming language well, it’s generally a lot easier to pick up the second, and the third, fourth etc.  Once you get over the hump, you can take on anything.

5. Practice Regularly

The longer you wait between coding sessions, the more likely you are to spend a lot of your time trying to remember what you did in the last session.  To avoid this, and to keep things fresh in your mind, I definitely suggest revisiting your project as often as possible.  Even if you don’t have time to spend 2 hours in a day on coding, try to fit in 30 minutes that day and fix a smaller bug; it will be easier to context switch and pick the project back up the more often you see the code.

6. Have Fun

At the end of the day, remember that coding should be fun!  Yes, it can be very difficult to learn to code at times, but it is also very rewarding and (hopefully) sometimes it will be enjoyable too.  Personally, I find that being able to play with my finished product is a wonderful feeling of success, accomplishment, and a confidence booster.  The knowledge that I’ve created some kind of cool product, app, webpage, or program out of thin air feels somewhat magical, and it is pretty fun to have that sense of ownership.  

So remember, as you embark on the next steps of your journey:  create a project, find a mentor, use those free online resources, practice, don’t give up, and HAVE FUN!

Voice to Text App for Android Tutorial

Voice To Text services are all the rage these days.  Just look at the VUI (Voice User Interface) systems many of us have in our homes like Google Home and Alexa.  Industry leaders like Google, Amazon, Apple, and Microsoft are all betting on voice assistants by creating interfaces like Google Assistant, Siri, Alexa, OneNote dictation and Cortana. These systems wouldn’t be possible without some kind of underlying technology that is able to convert our spoken audio into discernible text. 

If you’ve ever wanted to integrate speech to text into your applications, you might have though that it would be difficult or complicated. However, using Googles Speech to Text API, its actually quite simple.  Many apps out there utilize the speech recognition feature, such as Google Keep. In this article, we’ll learn how to build a simple speech to text app on Android using the speech recognizer library provided by Google.  By the end of this short tutorial, you’ll have a working version of a voice to text dictation app!

Prerequisites

  • Android Studio IDE downloaded and configured on your PC or Mac.
  • An Android Smartphone or Tablet (Unfortunately, Voice Recognition does not work on an emulator).
  • Basic Android knowledge like how to create a layout and run a program.

Step 1.  Create a Simple UI

To get started, let’s first create a new project in Android Studio. Go ahead and create a new project using the “Create New Project” wizard in Android Studio.  I’ll name my project “Speech Recognizer”, but you can name it whatever you like.

Start a New Project in Android Studio

I’ll also choose to create an empty activity for this example.

Android Studio Select Blank Activity

 

Android Interface with Microphone Button

For the purpose of this simple speech to text tool, let’s create a new Activity with only two elements on the page:  a TextView and a Button or ImageButton.  We’ll use the button to turn on/off listening for speech, while the TextView will be used to place our converted speech text on the screen.  In this example I’ve also wrapped theTextView in a ScrollView, just in case there is enough text to fill the page!  The interface looks pretty simple, but will do just fine for what we need.

 

 

 

 

 

 

 

 

 

Currently, my activity_main.xml file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="279dp">

        <TextView
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:layout_margin="10dp"
            android:layout_marginTop="20dp"
            android:textSize="25sp" />
    </ScrollView>

    <ProgressBar
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:id="@+id/progressbar"
        />

    <ImageButton
        android:id="@+id/recordButton"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="112dp"
        android:background="@drawable/microphone_button_off" />

</RelativeLayout>

Step 2. Implement RecognizerListener in our Main Activity

Now that you have a UI with a TextView and Button, it’s time to get into the meat of the code.    To get our speech recognizer to work, we’ll need to implement RecognizerListener.  This class will enable use to to use Google’s voice to text engine and add our own custom actions at different points in the voice recognition life cycle.  To do this, you will want to change the class declaration in your MainActivity.java to:

public class MainActivity extends AppCompatActivity implements
        RecognitionListener {

 

Like I said before, RecognizerListener has all of the underlying methods which you can edit.  In our Main Activity, we will also want to add the following code (we’ll fill in the required functions later).




//We'll need this to ask the user for permission to record audio
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        
}

@Override
public void onResume() {
	super.onResume();
}

@Override
protected void onPause() {
	super.onPause();
}

@Override
protected void onStop() {
	super.onStop();
}

//Executes when the user has started to speak.
public void onBeginningOfSpeech() {
	Log.i(LOG_TAG, "onBeginningOfSpeech");
}

//Executes when more sound has been received.
@Override
public void onBufferReceived(byte[] buffer) {
	Log.i(LOG_TAG, "onBufferReceived: " + buffer);
}

//Called after the user stops speaking.
@Override
public void onEndOfSpeech() {

}

//Called when any error has occurred

@Override
public void onError(int errorCode) {
	String errorMessage = getErrorText(errorCode);
	Log.d(LOG_TAG, "FAILED " + errorMessage);
}


//Called when partial recognition results are available.
@Override
public void onPartialResults(Bundle arg0) {
 	Log.i(LOG_TAG, "Results");
}

//Called when the endpointer is ready for the user to start speaking.
@Override
public void onReadyForSpeech(Bundle arg0) {
	Log.i(LOG_TAG, "Ready For Speech");
}

//Called when recognition results are ready.
@Override
public void onResults(Bundle results) {
	Log.i(LOG_TAG, "Results");
}

//The sound level in the audio stream has changed.
@Override
public void onRmsChanged(float rmsdB) {
	Log.i(LOG_TAG, "RMS Changed: " + rmsdB);
	progressBar.setProgress((int) rmsdB);
}




3. Requesting Permission

One important aspect of the speech recognizer functions is that you will need to use the microphone to get any sound (obviously). Any time you use a feature on your device that can record the user or access their personal information like the microphone, camera, or reading files, the user must grant the app permission first. The same goes here, and we will have to prompt the user for permission to access their microphone before the Voice to Text engine will work. Ideally, we’ll call a function to ask our system if the user has already granted permission before starting to listen.  If they have not yet granted permission, we will then ask them.

 
    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        switch (requestCode) {
            case REQUEST_RECORD_PERMISSION:
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    speech.startListening(recognizerIntent);
                } else {
                    Toast.makeText(MainActivity.this, "Permission Denied!", Toast
                            .LENGTH_SHORT).show();
                }
        }
    }

In addition to this piece of code, you will also need to add the following lines to your `AndroidManifest.xml`

    

<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET" />

Step 4.  Triggering the listener to begin

Now that we’ve got our permissions function started, it’s time to add a trigger when the user clicks our button.  In this section, we also need to declare our variables and set up the recognizer in the `onCreate()` function:

returnedText = (TextView) findViewById(R.id.textView);
recordButton = (ImageButton) findViewById(R.id.recordButton);
recordButtonStatus = false;

progressBar = (ProgressBar) findViewById(R.id.progressbar);

speech = SpeechRecognizer.createSpeechRecognizer(this);
Log.i(LOG_TAG, "isRecognitionAvailable: " + SpeechRecognizer.isRecognitionAvailable(this));
speech.setRecognitionListener(this);
recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);

recordButton.setOnClickListener(new View.OnClickListener() {
	public void onClick(View v) {
		if(recordButtonStatus){
			recordButtonStatus = false;
			progressBar.setIndeterminate(false);
			progressBar.setVisibility(View.INVISIBLE);
			speech.stopListening();
			recordButton.setBackground(getDrawable(R.drawable.microphone_button_off));
		}else{
			ActivityCompat.requestPermissions
 				(MainActivity.this,
					new String[]{Manifest.permission.RECORD_AUDIO},
					REQUEST_RECORD_PERMISSION);
                 recordButtonStatus = true;
                 recordButton.setBackground(getDrawable(R.drawable.microphone_button_on));
        }
    }
});

Great! Now, when I build the app and start it, I should be requested to record audio.

Step 5. Add a function to handle the listener output

Now that we now how to trigger the listener to start listening, the speech recognizer does a lot on its own. However, we will want to tell the recognizer where to put the text once we’ve finished our audio input. The correct place to put that would be in the `onResults()` function. In this case, we just simply want to display the transcripted text in our `TextView`.

The speech recognizer will actually return an `Array` of possible results to the speech, with the most relevant result in front. So, we’ll just take the result in position 0 and display that.

	
    @Override
    public void onResults(Bundle results) {
        Log.i(LOG_TAG, "Results");
        ArrayList<String> matches = results
                .getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);


        String text = matches.get(0);
        returnedText.setText(text);

        recordButtonStatus = false;
        recordButton.setBackground(getDrawable(R.drawable.microphone_button_off));
    }

At this point, I should be able to run my simple speech recognizer and see my words printed on the screen. While this is a very simple example, there is a lot more you can do with this technology. If you’re like me, you might be thinking about all the possibilities that you could use this feature for in an app.

Conclusion

Now you have a basic voice to text app built on your smartphone or tablet!  If you’re like me, you can probably think of some ways that this might be useful.  Perhaps you can make a note taking application for students. Perhaps someone could use this technology when interviewing.  Even yet, maybe speech to text could be a feature in an app you are building to use custom voice commands, similar to how Google Keep and OneNote utilize Speech Recognition technology.

Android Speech Recognizer Screen If you’d like to see basic Note Taking app I added to the Google Play store that is build on top of the code here, please visit the Google Play Listing. and feel free to leave suggestions on further ways to improve the app in the comments!  If you liked what you learned here, you might also enjoy my article on Speeding up your Android WebView with SQLite transactions, or my article on ideas for lucrative side gigs.

Source code for what we learned here can be found here.








 
 
 
 

7 Great Side Gigs for Developers

Stack of one dollar bills

So, you’ve got a great full time job as a developer, But there’s still something missing.  Maybe you’re looking for something to build your resume.  Perhaps you wish to have your own side business.  Or, very possibly, you are looking for a way to make some extra dough.  Luckily, these days there are increasingly more ways an individual earn money on the side, often online.  Most have heard of doing side gigs such as Uber and Lyft, but what about gigs that are geared towards developers?  In this article, I compiled 7 ways to make some extra cash that are geared towards developers, programmers, and those with technical backgrounds.

1. Get a Freelancing Gig

Table with laptop, coffee, and notepad

 

Freelancing can be a great way to supplement your income, and for those successful enough, it can become a full time gig and offer some real benefits.  For one, you tend to be in control on picking the jobs that make the most sense for your skills, schedule, and interest.  The hard part is building a client base.  Luckily, there are a few online sites that can help you get started. Upwork is probably the most well know and largest platform out there, where you can easily sign up for an account and start bidding on projects.  There are a whole bunch of other freelancing websites out there as well, one of my favorites being TopTal, which is quite selective in their vetting process of applicants.  If online is not your style, you can also try to build your own network of clients.  Perhaps of people you know previously and enjoyed working with you, family friends, or schools.

2. Become a mentor for an online education company

women coding on laptop

 

There are a few online learning companies which offer programming and coding courses.  The most notable of these are Coursera, Udacity, and Udemy.  If you happen to take and graduate a Nanodegree program at Udacity, you might be in a good stop to get a side gig.  If you’ve gained enough experience and performed well in the course, you could be invited to apply to become one of their course mentors or code reviewers. Udacity Mentors work as contractors and get paid based on engaging with students and reviewing projects, and the hours are flexible.  This kind of work is especially rewarding if you enjoy helping other people learn to code and grow as developers.  Udacity offers a wide variety of programs including Artificial Intelligence, Android Development, Self Driving Cars, Virtual Reality, and other cutting edge subjects!

3.  Start a Technology Blog

Individual using mobile phone

 

If you love writing or have a lot to share, you might consider starting a technology blog in order to share articles, ideas, and code snippets.  This method will probably not give you a big paycheck immediately, but if you keep writing quality content and optimize your SEO, you can see your blog grow.  If you get enough website traffic, you can earn revenue by running ads with Adsense or using affiliate marketing.  If you are successful, this could even turn into a full time gig.  Some of the more successful blogs can rake in upwards of 100k or more.   Thats nothing to laugh at!

4.  Become a Tutor

Woman teaching group of students

 

As a developer or programmer, chances are you have a strong background in Math and Science.  STEM tutors are frequently in demand for grade school, high school, and college students.  In order to get involved, you might market your own business in your area to parents or around campus, or join a tutoring agency in your area.  STEM tutors can make anywhere from $20-$70 an hour depending on the area and level you are tutoring.  This is another great option for anyone who enjoys teaching and helping shape young minds.

5. Write your own Trading bot

Bitcoin, Ethereum, and Ripple cryptocurrency coins

 

This one might seem a little “out-there”, but its also one of the more fun ideas on this list.  Trading bots are algorithms which detect patterns in markets and execute buys and sells based on its predictions.  With the late 2017 craze of Bitcoin and Cryptocurrencies, companies like Coinbase great exponentially.   More and more people are becoming interested in the volatile currencies.  Especially in high paced, volatile markets (such as Cryptocurrency), they have the potential to be successful and lucrative.   There are more than a few tutorials online that can help you get started.  While this could be profitable, like any kind of investment, it’s important to remember that it can also lose you money. Furthermore, it’s debatable how effective these trading bots actually are.  I’m not necessarily advising anyone do this, but if you feel up to a challenge and a cool project, it’s a fun one to take a stab at.  

6.  Make your own mobile application

Developer Team coding Javascript

 

One thing that you can do if you aren’t already worn out from your full time gig of coding is to consider creating your own personal Mobile App.  Both the App Store for Apple products and the Google Play Store for Android are platforms on which you can publish your apps.  In order to succeed in making money, you’ll either need a paid app, an app that runs ads, or an app which requires in-app purchases.  Not to mention, this one also looks great on a resume!

7.  Create your own online course

A few platforms such as Udemy and Teachable allow users to create their own online courses and release them on their platform.  There is a huge market for people looking to learn more through online courses.  If your content gets enough traffic and has real interest, you can make a real chunk of change in passive income once your course is released, such as this fellow who earned more than $5000/month in passive income from Udemy courses in 2015.

All in all, there are many ways to earn a few extra bucks, especially as a developer.  Whether you want to do more development, help tutor or mentor others, or write about what you’ve learned, that opportunities are out there, you’ve just got to decide what makes sense for you, your interests, and your time commitments.   Good luck!

SQLite Bulk Transaction functions for Android and iOS

In a previous article I wrote on SQLite performance techniques, I explained that using SQLite bulk transactions, especially in a WebView application on your mobile app, can be a huge performance booster.  In this article, I’d like to expand a little more and offer some basic code solutions for your Android and iOS applications.

Let’s start with a simple example.  Let’s say, for instance, that you are creating a mobile WebView-based application where you are pulling a large amount of data from a back-end service or API and inserting the rows in your your local SQLite database.  For this example, let’s say we are pulling in a list of coffee shops and we are going to insert into our SQLite table the following columns:

CREATE TABLE IF NOT EXISTS coffee_shops (
    id INTEGER PRIMARY KEY,
    name TEXT,
    address TEXT,
    price_range TEXT
);

For each coffee shop, we’ll give it an auto-incremented ID and insert a name, address, and a “price range” (in this case, either “$”, “$$”, “$$$”, or “$$$$”). You already know that you want to use bulk transactions, but you need to create a function to do it.

Android SQLiteStatement

Android native Java code is built to work hand in hand with SQLite.  The SQLiteDatabase and SQLiteStatement classes will both help you tremendously, and we will use them in our example.  Let’s say, for the example’s sake, that the data we have retrieved from the back-end service/API is in JSON format using an AJAX call in our WebView. 

The data might look something like:

{"coffee_shops": 
    [
        {
	        "id": 0,
	        "name": "Downtown Coffee",,
	        "address": "123 Main Street, New York, NY 10012"
	        "price_range": "$$"
	    }
        //...
    ]
};

We’ll also say that we’ve converted it to a string using JSON.stringify in our Webview, and are now passing the string to our native application to perform the SQLite interactions.


Once we pass that data to the native portion, we’re gong to be using SQLiteDatabase and SQLiteStatement. Most notably, SQLiteDatabase has the BeginTransaction(), SetTransactionSuccessful(),  and EndTransaction() methods which are essential for bulk transactions, while the SQLiteStatement class allows you to use a compiled prepared statement in your inserts.  If you want to look at another more in depth solution on these classes, I also recommend checking out This great article with examples.

Circling back to the coffee shop example, here’s a function we can write in Java to take our Stringify’d JSON object and insert all the objects using a bulk transaction.

// objectID = "coffee_shops"
public JSONObject bulkInsertCoffeeShops(String stringValues, String objectID) {

    try {

    JSONObject stringJson = new JSONObject(stringValues);
    JSONArray values = stringJson.getJSONArray(objectID);

    try {

        String sql = "INSERT OR REPLACE INTO coffee_shops VALUES (?, ?, ?, ?);";

        coffeeDB = mContext.openOrCreateDatabase("coffeeDB", 
        Context.MODE_PRIVATE, null);
        SQLiteStatement statement = coffeeDb.compileStatement(sql);
        coffeeDb.beginTransaction();

        for (int i = 0; i < values.length(); i++) {

            statement.clearBindings();

            try {

               JSONObject o = values.getJSONObject(i);

                statement.bindDouble(1,o.getDouble("id"));
                statement.bindString(2,o.getString("name"));
                statement.bindString(3,o.getString("address"));
                statement.bindString(4,o.getString("price_range"));

                statement.execute();

            } catch (JSONException e) {

                errorMessage = e.getMessage();
                Log.e(TAG, errorMessage);

            }

        }

        coffeeDb.setTransactionSuccessful();

    } catch (Exception e) {
        errorMessage = e.getMessage();
        Log.e(TAG, errorMessage);
    } finally {
        //end transaction
        coffeeDb.endTransaction();
        coffeeDb.close();
    }
} catch (JSONException e) {
    errorMessage = e.getMessage();
    Log.e(TAG, errorMessage);
}

};


Using Swift for iOS

If you’ve also got an iOS app running on the same or similar WebView code, you’ll probably also need an equivalent in your iOS app to insert your coffee shop data. For swift, it will be the same process, but we’ll use  SQLite.swift as our library as well as SwiftyJSON to help process our JSON data.

func bulkInsertCoffeeShops(values:String, objectID:String) -> Bool{

    let fileUrl = //your file path to your DB

    //open our database
    if sqlite3_open(fileUrl.path, &db) != SQLITE_OK {
    }
    let SQLITE_TRANSIENT = unsafeBitCast(-1, to: sqlite3_destructor_type.self)

    // convert our JSON string into an object
    let fieldStringData = fieldString.data(using: .utf8, allowLossyConversion: false)
    let objectID = String(objectID)
    let data = values.data(using: .utf8, allowLossyConversion: false)

    if let json = try? JSON(data: data!)
    {

        var compiledStatement: OpaquePointer?
        //Start our transaction
        sqlite3_exec(db, "BEGIN IMMEDIATE TRANSACTION", nil, nil, nil)
        var query = "INSERT OR REPLACE INTO coffee_shops VALUES (?, ?, ?, ?);";

        let rowObjects = json[objectID]

        if(sqlite3_prepare_v2(db, query, -1, &compiledStatement, nil) == SQLITE_OK)
        {//Bind or variables and execute each statement
            for (index, obj) in rowObjects
            {

                sqlite3_bind_int(compiledStatement, Int32(1), 
                Int32(obj["id"].stringValue)!);
                sqlite3_bind_text(compiledStatement, Int32(2), 
                obj["name"].stringValue, -1, SQLITE_TRANSIENT);
                sqlite3_bind_text(compiledStatement, Int32(3), 
                obj["address"].stringValue, -1, SQLITE_TRANSIENT);
                sqlite3_bind_text(compiledStatement, Int32(4), 
                obj["price_range"].stringValue, -1, SQLITE_TRANSIENT);

                if (sqlite3_step(compiledStatement) != SQLITE_DONE)
                {
                    NSLog("%s",sqlite3_errmsg(db));
                }

                if (sqlite3_reset(compiledStatement) != SQLITE_OK)
                {
                    NSLog("%s",sqlite3_errmsg(db));
                 }
            }
        }
        if (sqlite3_finalize(compiledStatement) != SQLITE_OK){

            NSLog("%s",sqlite3_errmsg(db));
        }//Finally, let's commit our transaction

        if (sqlite3_exec(db, "COMMIT TRANSACTION", nil, nil, nil) != 
            SQLITE_OK) {
                NSLog("%s",sqlite3_errmsg(db));
            }
        }
        //Close our DB
        if sqlite3_close_v2(db) != SQLITE_OK {
            print("error closing the database")
        }
        return true
    }
    //Close our DB
    if sqlite3_close_v2(db) != SQLITE_OK {
         print("error closing the database")
    }
    return false

}

And there you have it.   We can now successfully insert our large sets of data into our SQLite databases using both Swift and Java.  If you like this article or found it useful, feel free to leave comments in the comment section.