Working with Scanner devices and angularjs

Recently my work has had me working in a unique, or at least, underdocumented set of hardware and software. I’ve never done any developer blogging, but I want to try to pay it forward for all the blogs that have helped me in the past.

I recently wrote an angular front end for a large scary Microsoft Dynamics application. The point of contact for the application to be consumed was a 2014 ipod touch placed in a Captuvo sled. If you’re not familiar with captuvo sleds they turn your ipod or iphone into a hand held scanner. Rather than use the ipod on screen keyboard, you hold a button, it scans using the ipod camera and a little grocery store style laser. The value that is scanned is immediately entered into the field.

The Captuvo sled saves you the time of punching in all those tiny keys with your fat fingers. But you still need to press the ‘enter’ key, as well as navigate around the page. Luckily there is an application, that is a complete heaven send, the SwipeTrack Browser. SwipeTrack browser is a handy wrapper that wraps the default browser and adds a few functions via the API. I REALLY WISH they documented more features. But here are the important ones:

  • You can trigger a device sound. There are 3. Alert, error, and success. Unfortunately you cannot just load your own sounds. Which makes zero sense to me.
  • On the iphone you can trigger a vibration and set the duration of the vibration. This kind of feedback is super useful (ipods do not have a vibration mode).
  • You can trigger custom delimeter after the scan, such as: space, tab, return, submit. I’ve found on things like ‘return’ and ‘submit’ mileage varies depending on the implementation of your app. Our ASP.NET application behaved differently than our Angular app.
  • you can call javascript functions after a scan. YES YES YES YES YES. This is so great. It opens up a world of possibilities.

I’ve built two applications using this devices/software combination. For the simplist interoperability between scanners and applications, I simply have each scanner calling scan() . I define scan() differently in each app, and really you don’t want to have to type in a ton of javascript in to a scanner using your fat fingers.

Having access to call one function and use jquery allows you to find out which input field you’re in, pass the value to your javascript, focus() the next field and so on. You can reduce the amount of keypad touches drastically.

I use this helpful block to trigger sounds throughout my app

function soundSucces() {window.location = "stBrowser://playSound?sound=success";}
function soundAttention() { window.location = "stBrowser://playSound?sound=attention";}
function soundError() { window.location = "stBrowser://playSound?sound=error";}

I wish you could here the soundError() it sounds like a sad robot. The use of window.location is how swipeTrack has chosen to trigger sounds. Interesting, eh?

Capturing values from input fields

I’m going to show how I solved a bug that we encountered testing the scanners. This was for an Angular 1.4 application, and I encourage anyone with a better solution to post it in the comments.

The problem

See the Pen Updating input values with jquery and angular by Steve Barman (@dreamtroit) on CodePen.

as you can see the scanner doesn’t actual update the model. On the first actual keystroke, Angular will update the model. When I submitted the form I would submit undefined as the value of the input field.


It took me a while to figure out because I was so focused on passing the model into the controller on submit. My fix was check the value of the input AFTER the form was submitted. There’s no ‘real’ submitting in javascript anyway, right?

var scannerField =  angular.element(document.getElementById('scannerField')).val();

after submission I then pass around scannerField to any service or model that might need it. Neat-o.

Terminator Genisys

There’s probably going to be spoilers in here. This is a combination of a review mixed with my general thoughts. I’m not a film critic. If that’s what you’re looking for, I suggest you check out Leonard Maltin

Terminator Genisys was interesting. It takes this weird position that Terminator 3 and 4 never happened. I doubt however that hardcore Terminator fans could actually tell you what that difference means for the continuity. Genisys says to continuity: shrug. The characters mention in the outtro monologue that they themselves haven’t figured all of it out yet. Echos the MST3k sentiment of

“if you’re wondering how Joel eats and breaths, and other science facts, repeat to yourself it’s just a show, you should really just relax”

I’m sure that won’t quell angry fan boys. But really Terminator Genisys is really fun at parts, and at parts stands equal to T2. Those points I feel is when it’s most heavily impersonating T2.

There’s 4 different times in the film 1984, 1997, 2017. Each year has a different color filter. 1984 matches the first Terminator film. 1997, T2. 2017: Instagram. In the future, as well as the present all films are shot in instagram.

In 1991 when James Cameron made Terminator 2, heavy color filtering was still a new thing and directors could still use it tastefully. For horrible examples, see Terminator 4 and that pile of shit Ferngully knock-off Avatar. In Genisys, it’s not totally offensive but it works.

There’s a genuine feeling as they go through this film that they’re trying to expand the storyline to expand past what they’ve done with the previous films. Rather than just non-stop John Connor getting hunted, they’ll revisit the first Terminator and show it from a different perspective, those new perspectives echo into results in the future. That’s neat.

Terminator 3 felt like a $2 version of terminator. T3’s “more advanced” terminators were weaker, goofier, and cheaper seeming than the liquid metal T-1000s. T3 in a nutshell was “there’s the terminator, run!” “oh shit, there she is again, run!” (rinse repeat). Genisys at least made the tech more terrifying and kept some level of cohesion and budget with the first two movies.

There was a couple of points in the film when Emilia Clarke was doing a Linda Hamilton impression, which was cool. But Linda Hamilton in T2 was a buff brute and Emilia Clarke looks like a cuddler. Her arms have no muscle, which I’m sure might have looked bad on her in game of thrones, but couldn’t the CGI department give her some bicepts? She’s been preparing for the apocolypse since she was 9 years old and has done less push ups that she does in the mental institution in T2.

There’s a scene where they go into this secret weapons cache that has been there for 20 years that Pops set up for them. First thing they have to do? Start putting bullets in magazines. There was a fucking terminator hanging out for 20 years and he couldn’t get these fucking bullets in clips? What the fuck, talk about waiting until the last minute.

Skynet, you don’t have to mimic human form and talk to people while they’re trying to kill you. Why not do something to try to kill your enemies instead of wasting the CPU cycles to appear to grow older. There was a point in that same sequence where Sarah Connor and Reese are like “oh no, we’ve got 4 minutes left!” - I totally thought they were going to start banging to make John Connor. Sadly, it didn’t happen.

The movie was decent but flawed, I hope they make the 2 sequels that have been outlined because I’ll throw another $10 at the franchise.


Growing up I spent most of my life in a peculiar position. I sat through school completely uninvolved because I couldn’t be bothered. I understood everything, everything just went at a pace that put me to sleep. Teachers would call on me, to try to bring me back to earth. I’d answer the question, correctly, then continue to space out. I spent a year in “primary first grade” for kids who were above kindergarten, not ready for first grade. I scored in the 99th percentile in all my elementary school tests, but couldn’t maintain any sort of focus.

I remember an assignment in primary first grade. We had to draw something we did on vacation, then present in front of the class. I must have phased out, I do that a lot. I drew something I wanted to do on vacation, fly to the moon in a spaceship. When I saw the other children present I was terrified. Utterly fucking terrified. I should have said “I watched the moon landing on tv”, or “I was confused about the assignment”. Instead of the rational options, I feigned sickness - extreme foot pain, to get out of class. My mom actually took me to the doctor for my fake foot pain. The doctor, could not cure my illness. There wasn’t yet a name for what I had.

As an engaged, teen with a sponge like brain, I listened to a lot of talk radio, and pretended like I read the news. I learned about Attention Deficit Disorder. At that time ADD wasn’t yet synonymous with Attention Deficit Hyperactive Disorder. I have ADD, not ADHD. I was never more hyperactive than any other child who loved coca-cola and Fun Dip. I insisted that I be taken to the doctor to be diagnosed. The doctor, to his credit, wasn’t in favor of pumping me full of speed and sending me into the world like everyone else. But I convinced him. He started me at 4mg dose of ritilin, the maximum suggested amount.

At school I noticed everything. I was hyper aware. I watched the school clock tick by in slow motion. I burned through churned through my readings and my assignments. My mouth was dryer than a desert no matter how much water I drank. I wasn’t hungry at lunch, which is weird for a chubby kid. I felt completely dead inside. Sad movies couldn’t trigger a tear. I felt like I could watch a bus load of puppies explode and not care. In an English class our assigned reading was “Catcher in the Rye”. I read the first 2 chapters. I was depressed. Horribly depressed. I was smart enough to know that Catcher in the Rye is what multiple gunman had on their person when apprehended. I knew the book was was a gasoline to the flame of frustration with the world. I felt that if I read the book I might be so depressed I took my own life. So I read the cliffs Notes. I got a C.

I quit using Ritilin 2 weeks in. Feeling like a self-destructive robot is no way to go through adolescence. I don’t know if taking a lower dose would have helped me. I’m kind of glad the doctor scared me out of pharmaceuticals by giving me what I wanted. Later in life I met a guy who was in the test group for ritilin. He had a very visible set of facial tics that went off every three or four seconds.

In college I used deadlines to keep me focused, which was good in essays I could b-s (film papers), and horrible for things like statistics, and history papers. Reading and retention classes I did well in. I am the king of the multiple-choice quiz. Large assignments requiring self motivation was like herding cats (but to my own credit, I did well in nearly every class). The college stress made me realize that my ADD was just part of me. I didn’t want to use it as a crutch like some kids did, and I didn’t want to TRY to use it to my advantage, by procrastinating.

I had to use my body and mind as an instrument and tune it according to the tasks at hand. I found that repetitive daily activities made more aware of what I was doing. Doing the same things, at the same time of day, in the same order. Writing lists was very helpful, keeping it in my back pocket I could find the tasks that i had to complete by the end of the day (this was later replaced by phone apps). I found I could stay focused reading books if I actively tried to speed read them (I run a bookmark down the page and have my eyes dart directly behind it). When I’m in the zone, I will run at a task until I’m exhausted, and as long as I return back to it, I can actually get the damn thing done.

I still have ADD. I self-medicate with meditative exercises and coffee. I should probably find some herbal supliment to help out naturally. My work in front end design isn’t hindered terribly much by the ADD (most of the time). I feel like bouncing between markup, scss, and javascript is kind of helped by my ADD. I can usually have bad 80s movies on when I work at home without any adverse effects. If I can’t focus, I’ll take a minute walk, get a drink of water meditate for a minute and go back into the zone. So much of programming is type a line, save, make sure it worked, adjust, in an infinite short burst cycle.

The conspiracy theorist in me thinks there’s some ingredient in white bread that our pregnant mom’s ate too much of that gave my generation ADD/ADHD, or something like that. Or perhaps it was just watching hours and hours of Nickelodeon/MTV/and Ricki Lake as a kid. Regardless of the cause, rather than drugging all the kids, I’d rather unchain them from their desks and let them learn through play. Let their attentionless minds discover by asking questions, until they find a topic they really want to focus on.