• Managing Terminal Jobs

    My terminal workflow usually involves multiple windows and tabs with a job running in each. Lately though I’ve been trying to use the capabilities that Bash provides to manage jobs and run them in the background.

    Here are some useful commands I’ve found.

    Command What It Does
    ctrl-z Suspend the current job
    jobs List the current jobs
    fg %[number] Resume a job in the foreground
    bg %[number] Resume a job in the background
    kill %[number] Stops a job
    %[name|number] Resume a job in the foreground
    disown %[number] Keep a job to running after terminal is closed
    nohup job & Run a job in the background

  • Be Productive, Eliminate Distractions

    I love to-do lists. And automation tools. And pretty much anything that claims to aid productivity. Perhaps it’s the programmer in me that is never satisfied with the status quo and loves to tinker but I’m always wanting to reorganize, automate, or find a better way to do something.

    However good intentioned though, I often waste a lot of time being “productive”. There are hundreds of ways to organize a to-do list and a million things you could automate in your daily workflows and I’m fairly certain I’ve tried 99% of them. Unfortunately, in the endless search to make things efficient and be productive, much time is wasted.

    Often more important than automating and organizing but frequently overlooked is eliminating distractions and doing one thing at a time (i.e, no multitasking). There are numerous articles and research that show how much multitasking and context switching are bad for your productivity.

    Between Twitter, chat messages, emails, Hacker News, and Facebook there is an endless supply of distractions that waste much more time than most things I might try to automate. All those things are good but without care they can easily become constant distractions that slow you way down.

    The takeaway? Be mindful of how much time you spend trying out new productivity tools or automating things and instead trim down the daily distractions so you can focus on that important tasks at hand and get them done.

  • How to Use Git with SVN

    I’ve been using Git for the last couple years and really love it. SVN doesn’t hold a candle to Git in my opinion. Unfortunately though, not everyone uses Git.

    Thankfully, Git provides the git-svn bridge so you can use Git with an SVN repo. It’s a bit different than your typical Git usage but not difficult.

    To start off, you’ll want to clone the SVN repo to your computer.

    git svn clone -s http://path/to/svn/repo
    

    Notice the -s flag. If you have have the standard SVN layout of trunk, tags, and branches this will make Git aware of that. Otherwise, if you clone without the -s flag you’ll find all of trunk, tags, and branches folders checked out to your filesystem.

    After this you can work, branch, commit as you typically would if you were just using Git. When you are ready to pull down the latest changes from SVN simply do the following:

    git svn fetch
    git svn rebase
    

    The only thing left to do is push your changes to SVN. To do this you use the dcommit command.

    git svn dcommit
    

    That’s it. dcommit will push up all your changes. There’s more that you can do with the git-svn bridge but this is just the simple workflow that I use. Check out the docs for more information.

  • I Built an iPhone App

    Earlier this month I submitted my first iPhone app to the app store. You can check it out here. The Android version is forthcoming. I built it with AngularJS and Cordova and overall it was a great experience. Being able to use HTML, CSS, and Javascript, languages I already know, made the development very straightforward.

    The reason for using Cordova and not building a native app was two fold. First, the app needed to be cross platform (iOS and Android) so without Cordova two code bases would be needed.

    Second, the app needed to be delivered relatively soon. Understandably the company couldn’t wait the lengthy amount of time it would have taken for me to learn iOS and Android development then actually build the app. In this case, Cordova (or Phonegap if you like) made perfect sense.

    But not everything was smooth sailing.

    It’s The Little Things That Kill You

    By far the most challenging part of building mobile apps with Cordova is making the app actually feel like an app. Both iOS and Android apps have tons a visual cues and certain behaviors and users expect. Because you generally don’t have access to the native UI components while using Cordova, it can be a real challenge to get the app to feel right. Inevitably you’ll spend most of your time debugging and fine tuning the small details of the app.

    Going Down the Cordova Road

    Anyone planning on using Cordova should do lots of research because there are many tips and tricks you can find that you need to know about in order to get your app to feel right. From eliminating the 300ms click delay to using -webkit-overflow-scrolling: touch, these tips and tricks are important to be aware of.

    Also make sure you test of devices early. Very early. Like the first week you start coding. You’ll discover annoying issues like performance problems and font issues that you won’t see in the emulator. I didn’t test on a physical device until I was getting close to finishing and had a brief moment of panic when I found many issues that didn’t happen on the emulator.

    Lastly, when testing on Android, use the Genymotion emulator and not the one that Google provides. I just learned about Genymotion in last couple days but I wish I had known about it much much earlier. It would have saved me tons of time. The problem is that the emulator that Google provides is slow. Super super slow. Even after installing HAXM and enabling the “Use Host GPU” option, the Android emulator is just too slow. You can’t get a feel for how your app actually works and the iterative software development cycle is slowed way down. This article explains how to setup and use Genymotion. Use it. It’ll make your life easier.

    Beyond these couple things, there are many other “gotchas” and tips and tricks but as you do research you’ll find them mostly well documented. Cordova is really a great development experience if you use it correctly.

    Now go forth and build!

  • Refactoring Bad Code

    Like every programmer, I often come across code that isn’t quite right or just plain bad. Sometimes it’s my own, sometimes it’s not. It happens to every programmer though. You write some code in a hurry, maybe don’t quite understand the problem very well, or just learn a much better way to do something after the fact. The question though, is how to handle refactoring that code?

    I sometimes have perfectionist tendencies so when I come across bad code it’s often tempting to dive in and start refactoring. It feels great to take some ugly code and turn it into a work of art! While often times this is not a problem, especially if it’s a small refactor, I often find that I have blind spots that prevent me realizing what I’m getting myself in for.

    Problems With Refactoring

    Here are a couple problems I’ve noticed when undertaking large refactorings.

    • Not fully understanding why the previous programmer did what they did.

      Often times programmers think it’s going to be easy to refactor code because they can’t see the full picture and don’t understand the challenges the previous programmer faced or thought process for solving it. They don’t know the meetings that took place to discuss the best solution or the alterantive approaches that were tried and failed.

    • It may take longer than expected or lack of time.

      I’m a severe underestimator of the time it takes to finish a project or feature and I’ve found most programmers are the same. With that in mind it can be dangerous for a project when a programmer jumps into a big refactor with limited time and an underestimation of the required time.

    Nowadays when I come across some shoddy code, if it’s not quick and simple, I try to be diligent about noting it somewhere, whether in a ticket tracking system or as a simple “TODO” in the code, and then come back at a later time. This keeps me from wasting time that I don’t have and prevents me from forgetting about it and letting bad code go forever.

    We all write shoddy code so let’s make better. Just don’t do it blindly.

  • AngularJS Directives Are Not Just For Packaging jQuery

    I came across this StackOverflow answer today and thought is was fantastic advice to those new to Angular.

    One thing that stuck out was about how to view and work with directives.

    Some directives just decorate what’s already in the view (think ngClass) and therefore sometimes do DOM manipulation straight away and then are basically done. But if a directive is like a “widget” and has a template, it should also respect separation of concerns. That is, the template too should remain largely independent from its implementation in the link and controller functions.

    AngularJS comes with an entire set of tools to make this very easy; with ngClass we can dynamically update the class; ngBind allows two-way data binding; ngShow and ngHide programmatically show or hide an element; and many more - including the ones we write ourselves. In other words, we can do all kinds of awesomeness without DOM manipulation. The less DOM manipulation, the easier directives are to test, the easier they are to style, the easier they are to change in the future, and the more re-usable and distributable they are.

    I see lots of developers new to AngularJS using directives as the place to throw a bunch of jQuery. In other words, they think “since I can’t do DOM manipulation in the controller, I’ll take that code put it in a directive”. While that certainly is much better, it’s often still wrong.

    I find that if I’m doing much work with jQuery, I often can refactor my code to be more like the “Angular Way” and not deal with jQuery. Angular makes it dead simple to do so once you understand a few concepts.

  • Goodbye Adobe, Hello Sketch and Pixelmator

    For as long as I can remember, Adobe has had the go to products for design. Photoshop and the rest of the creative suite have always seems to have a strangle hold on the design market and all the competitors were far behind.

    In the last couple years, however, that seems to have changed. Now there are great alternatives like Sketch and Pixelmator. Both are very quick, much simpler than their Adobe counterparts, and provide everything I need to UI/UX design. The best part? They cost a small fraction of what Adobe charges for Photoshop, Illustrator, and the now defunct Fireworks.

    I’d highly recommend anyone checking them out unless Adobe’s products provide a specific feature you need.

  • Auto Restart Node Scripts with Nodemon

    If you use node and find yourself constantly restarting your scripts after you make changes, nodemon will be a life saver. Instead of constantly hopping over to the terminal to restart the script, simply make a change and it will automatically be run.

    Instead of

    node ./server.js localhost 8080
    

    do this

    nodemon ./server.js localhost 8080
    

    Boom.

  • Learning for the Masses

    Humanity now has an unprecedented opportunity for learning. Not only do we have the classic ways of learning like attending a university or reading books, but now we have a new generation of online resources ranging from online video to sophisticated online tools enabling people around the world to learn nearly anything for little to no cost. With a time and motivation you likely could attain the equivalent to a college degree.

    In the last couple weeks I’ve had the pleasure of starting the Functional Programming in Scala course from Coursera. So far I’ve been very impressed with the quality of the course and enjoyed learning to think functionally.

    The course is setup so that each week the students watch recordings of the professor lecturing and then do homework. The homework is submitted via a terminal script and then automatically graded within about 10 minutes. Because of the automated nature of the grading, the class can have far more students than any normal college class. The last time the class was offered over 50,000 people signed up!

    The great thing about courses like this is that anyone can sign up, you don’t have to fork over thousands of dollars, and you can take the course from anyware – no need to sit in a classroom.

    Cousera is only one of many new online tools people can use to learn. edX, Khan Academy, MIT Open Courseware, DuoLingo, Codecademy, and JustinGuitar are just a few popular sites where you can learn a wide range of topics but many more are available (check out NoExcuseList!).

    When you start looking at these available resources you’ll quickly notice they take very different approaches to teaching. Some, like Coursera, attempt to replicate the traditional class format and have lectures to watch and due dates for assignments. Others take more of a “go at your own pace” approach where there are no due dates and you can do the work and learning on your own time. Both ways have pros an cons. If you lead a busy life and have very little free time then being able to work at your own pace might be the best. But for others, having a due date for assignments and having a sense of keeping up with the rest of the class may provide some incentive to stay caught up and meet the deadlines.

    Because these new ways of learning are still in their infancy, many challenges have not yet been met.

    One challenge being worked on is how to let students get credit for completing a course. Coursera gives students a certificate upon completion but it is hardly college credit. Many of these online courses are equivalent to what you’d get in at a fully accredited university yet once the course is completed, no college credit is given. One might argue since the course is free or cheap, it is an acceptable trade off. That said, for employers that want an employee to have a degree, a list of equivalent courses taken online is unlikely to be a good substitute. Coursera has begun to explore giving credit for some courses but there is still a long way to go.

    Another challenge is that because of the often massive class sizes, it is nearly impossible to get the same kind of tutoring or one-on-one time with the professor. This can be mitigated with other tools like forums where students can talk with other students and with the professors but it isn’t quite the same. There is a risk of students being left behind because they can’t get the help they need to work through a problem or get feedback.

    Student retention seems to also be a problem with some of these online resources. Due to the low cost and ease of signing up for a course we may simply be seeing people who would not normally sign up checking it out only to find it isn’t their cup of tea and abandon it. Another possibility is that some students may be getting stuck and not able to get the help they need. More investigation should be done to find out why many students don’t finish the online courses. Maybe a survey at the end of the course sent to the students that didn’t finish could be beneficial.

    One thing is certain though, despite any problems, it is an exciting time for those who want to learn!

  • Javascript and jQuery Tips

    I came across Paul Irish’s 10 Things I Learned From the jQuery Source screencast today and found it quite interesting. He delves into some of the inner workings of jQuery as well as a few nice tips for plain old Javascript. Rather than telling you myself, I’ll just let him do it. I’ve embedded the screencast below. In addition, I’ve embedded Irish’s presentation slides from his presentation “jQuery Anti-Patterns for Performance & Compression”. It also has a few good tips and some new jQuery functionality that I’m going to try out. If you have some time, take a look at both as they have some good info.