Built a CRUD API for Robots with NodeJS, Express, and MongoDB

After building an API about myself I wanted to get into another API project right away. I found this article on Scotch.io about building a CRUD API using NodeJS, Express, and MongoDB. As I have been learning the MEAN stack I have put off working with MongoDB. In my previous attempts I had multiple issues setting it up and running it locally. I had enough issues that I put it off for too long. The Scotch.io tutorial mentioned a couple different online hosts for MongoDB databases, one of which is mLab. They offer a free instance that you can use as a sandbox database for development purposes. This was perfect to me as I want to learn how to interact with MongoDB, retrieving data and saving new data, but I’m not interested in learning how to admin or run a MongoDB instance. At least, not at this time. So, having a way to easily run Mongo and work with it was a definite catalyst to this project. It also lead to this tweet.

In the Scotch.io article it goes over the basic setup of Express and Mongoose. I used that as a template for getting my API up and running. It was a pretty straightforward process as I only needed one route with the appropriate handlers for each verb. Working with Mongoose was really easy and it worked to set it up on the route file. Working with the Mongoose docs made it easy to get my schema as ai wanted. In my API I used Robots as the example object I am creating, reading, updating, and deleting. I gave the object two custom parameters, designation and evil. Designation is a string and seemed more appropriate for a robot rather than calling it name. And it feels pretty important to know if a robot is evil or not, so I have that as well as a boolean. Each of these are given to the API via query strings. Being that I only have the two parameters I went with query strings in the URL instead of parsing out the body of the requests. In my next project I want to make a more complex object and that should lend itself to working with constructing custom objects to provide in the requests. Maybe that one can be superheroes. I can probably come up with a few more parameters for a superhero object.

It felt like the project went pretty smoothly and I was able to it up and running. I used Postman for testing out the routes and worked pretty well. I was able to run the requests as I needed and simulate a few error situations. I already know of one that I am not accounting for right now that needs to be addressed which is that requests will still go through to the POST route if neither of the parameters are supplied. It will end up with an empty object being created with no designation or evil params. I need to fix it so that the request is checked for both before I go to the database with nonexistent values.

Once that is fixed I will feel pretty good about the project. In fact I am likely going to fix it after I post this tonight. Next, I am work on an API for a more complex object. After that, I want to tackle adding in authentication so that I can have individual users. Right now anyone could use this API and it will all come in as one person.

If you want to check out the project you can find it on Github here. Feel free to let me know what you think in the comments here or submit PRs with your own ideas.

I made an API about myself as a web developer and human

I have really been focusing my efforts on learning web development on backend lately. It is the most interesting to me. I’m not really a fan of creating interfaces and dealing with moving elements of a page a few pixels at a time until it looks right on one of a million different devices. I just like making connections between things and moving data between them. I also rally enjoy making command line apps where I don’t have to worry about a UI, but that is for another post.

Since I have been focusing on backend / API work I figured it would be fun to build an API that could be used as a resource to learn about me and what I have done in my self-taught journey. It would help me learn further and would be a fun talking piece. Plus, I think it would be hilarious if someone asked for a resume and I gave them a URL for them to make a GET request to for the appropriate info.

I started out making a JSON object to describe me as a web developer. I also threw in some fun personal stuff to ensure someone making requests for it that I am indeed a human being. It was both weird and fun to create this data structure that is supposed to represent me. Once I had that mostly complete I installed Express to the project and began building out the routes for the API. This part was pretty simple as I am only supporting making GET requests for this API since I don’t want someone changing data about me unless it is me making the changes.

The necessary data for this API is pretty simplistic and since I don’t need to write new data or update existing via requests I decided that implementing a database like MongoDB would be overkill. Instead I decided on just creating JSON files with the necessary data for each route to return. I have a main route that provides a brief explanation of the API and the available endpoints. I have my resume style object in another JSON file. This way requests made to the appropriate endpoint will quickly return data. I even made a JSON file for custom errors that I require in each route file so that I can give a custom error message when someone attempts a request other than a GET.

Along with providing info about myself I also setup a /fun endpoint to provide info about fun things that can be done with the API. I am saving this part of the project for the silly ideas I have for micro-services to do hilariously “useful” things. The first one is /api/band-names which returns a listing of awesome band names I have created, each with their own id number. You can use /api/band-names/{{id}} to return a specific band name based on its id number. This spawned a separate project to create this object. Since I don’t have a database generating the id numbers for me I needed a way to create them. I keep this list of band names in a sheet in Smartsheet. I used the Auto-Number system column to generate unique five digit numbers for each name. Then I build a script that connects to the sheet and builds out an object with the id numbers and name. This object is then written out to a JSON file that I copied into my data directory along with the other necessary JSON files. Now, as I come up with other fun ideas for micro-services I can place them in as part of this API.

This was a really fun project to make and it helped me learn a lot more about Express and building out the backend of an app. Next up I am going to build out a simple CRUD API that connects to a MongoDB database. This will be a more typical API that handles GET / PUT / POST / DELETE requests. At first I was thinking that I would base it around the ideas of todos for a todo list, but instead I’m going to go with robots. That sounds more fun.

If you are interested in checking out my API about me you can find it here:

https://daveskull.herokuapp.com

And the project can be found on Github here:

https://github.com/daveskull81/daveskull-api

Some of my favorite definitions of NPM

NPM is super awesome and I totes heart it. First coming into the world of Node.js and seeing the power of installing modules to add new functionality to my projects I was super excited. It also made sense when I heard or saw people call it “node package manager” since it was for loading and managing packages in Node.js.

But, I quickly learned how it was much more than that and how that definition limited how one could think about NPM. Most obvious is that even though NPM is bundled with Node.js you don’t have to use it solely in Node.js projects. It can be used to manage dependencies of a purely frontend workflow. You can also find lots of awesome CLI tools for making your shell life easier as well. I am also a huge fan of the purely silly packages that exist to bring smiles to people’s faces. I keep thinking about how I need to write more of these.

Through posts online and such I have seen that the folks who maintain NPM also feel the same way, that NPM is so much more than a Node.js package manager. On the NPM homepage you can see in the upper left corner a playful definition of what NPM stands for. It changes every time you load the page. I recently found myself refreshing the page repeatedly and taking screenshots of the ones that made me laugh the most.

So I present to you, my favorite “definitions” of NPM.

screen-shot-2016-06-22-at-8-51-47-pm

screen-shot-2016-11-05-at-3-29-24-pm

screen-shot-2016-11-05-at-3-30-35-pm

screen-shot-2016-11-05-at-3-31-04-pm

screen-shot-2016-11-05-at-3-31-18-pm

screen-shot-2016-11-05-at-3-34-36-pm

screen-shot-2016-11-05-at-3-44-59-pm

Going back to bash-ics with dev tools

I recently nuked my entire development environment and I did so purposefully. As I have been teaching myself to write code I have come across many fun, shiny things that can make developing for the web easier, flashier, or something-er. As someone new to the whole world I just kind of grabbed everything because people said it was cool and would fix so many problems. I also installed things at the advice of others I met who said a particular tool made something really easy for them.

Over time this has gotten me lots of cool things, but in the end it is LOTS of things. I recently read an article on Hackernoon regarding How it feels to learn JavaScript in 2016 and it got me thinking about my own dev setup. If you haven’t read it already I would suggest it because it is funny and sadly accurate at the same time. After reading it I began to think about my own development process and how I would make an app today if I was working on a project. It also reminded me of how a few months ago I erased my system and set everything up cleanly on my Mac. When I did this I made a list of all of my tools that I would need to install afterwards. I took great care to make sure I got all of these “important” items.

As I mentally went over what I have installed on my computer I realized that if someone asked me why I use a particular thing that I don’t think I could truly defend my choice in using it. I would likely start with a story of how I found out about the thing and read or was told how it solves a certain problem. If I was asked if I had experienced that problem I probably couldn’t say so for sure. For example, I was using Oh My ZSH on top of zshell instead of using bash as my shell in my Terminal app, which was Hyperterm instead of Terminal that comes with macOS. I was told awhile ago that Oh My ZSH was an awesome tool with these great configurable features, but it required using zshell. So, I changed the shell on my system and installed Oh My ZSH without ever really using bash and seeing how they are different and if I actually prefer one over the other.

This is also true of NVM, another tool I installed after reading a blog post. I understand the benefits of having multiple versions of Node on your system in case you need to develop apps using a particular version, but I have yet to actually have that need myself. It will likely come as I work more, but until then I am leaving it off.

Now, I have my shell set to bash, hence the awesome and pun-tastic title of this post, and I’ve uninstalled all of the things I can’t justify using. Going forward I plan on working on projects and as I experience the pitfalls of a certain process I can look into solutions for that issue. But, until then I am going to work with a more default setup. One benefit to this is that to get my dev environment setup on another computer will just take a .bashrc and .bash_profile along with installing Atom and Node.js. The contents of those bash files are stored in Google Keep, so I can easily copy and paste their contents into place. Fun fact, I have already replicated the things I was using and like about Oh My Zsh and zshell in bash. So, I probably won’t be switching back unless something pretty drastic comes up. I’m also using Terminal over Hyperterm.

In the end this is meant to help me solidify my learning in web development so that I can speak directly to the stuff that I am doing and why I am doing it.

Writing an API about myself for my Github page

All Github users have the option to make a personal page ({username}.github.io) from a repo. I have long had one setup with no content in it whatsoever. To check it out in all of its blank white page awesomeness you can go here, if you really want. I’ve always wanted to use this page to make a simple portfolio for my projects and show off some of the things that I have done in the realm of web development. As I learn more and more about building things for the web I have come to realize that I really enjoy backend processes much more than frontend work, hence my focus on NodeJS. And since Github pages only support frontend things like Javacript, CSS, and HTML I haven’t really put much effort into designing this page.

But, I want to have something fun and interesting. The other day I had a great idea. I will write up a server that will return an object that describes me and the work that I have done. It will be a resume in a JSON object, a kind of API all about me. I can make the main endpoint return the whole thing and set other endpoints to the various sections of it. Then I can build out the page to make AJAX requests to this server. I will host it on Heroku likely, the server that is, and maybe even set a dropdown for the various endpoints with a button to send the request. Then I will display the raw object on the page. This is a project I can get behind and will actually want to build.

I will admit that I have seen this done before by others and I am no way saying that I am doing something unique here, but it will definitely be fun. One in particular I have seen and really like is one by Ashley Williams, who works at NPM. I figure this kind of project will turn out much better than if I just tried to make a fancy looking page to be flashy. I am even thinking of making it text only and I might have it display the raw object. This will speak much more to the kinds of projects I like to work on. As I have been writing this I am thinking about the various sections and how I could have them break down. One section could be for full fledged web apps and another for CLIs that I have made. This will be fun indeed.

Holy moly! I gave a talk about code I wrote!

As I have been teaching myself how to code I have been trying to go to various code meetups in the Seattle area. It is always fun to get into a room full of like minded individuals and hear people’s perspective on different web technologies. Most of them have talks of some kind where a couple people will present their idea on something in the realm of code. I have always wanted to give one and just recently got the opportunity to do it. I go to most of the BellevueJS meetups as they are usually pretty close to my work and are easy to get to after I leave the office.

A friend of mine, Matt, helps run it and after I put up my post regarding publishing my first package to NPM they asked me if I wanted to do a talk about that. I thought about it for a moment and said yes without really thinking about it. As I thought about it more the more it felt like a great idea. I have been wanting to do a talk about something and I could never really think of a topic. This would be a perfect subject for me to talk about as it is more about my getting over fears of putting code I wrote out into the world than the actual code itself.

So, I began preparing the presentation. I decided to keep it simple and had about five slides or so. Each one with a few talking points on them. I tried to keep it moving as I spoke and kept to the topics on the slides. I let the audience know that it was my first talk at the start which was more for me to get the nerves out than it was a disclaimer for them. It was a very receptive group and there was even a couple of questions for me afterwards. The group seemed to be mostly folks that are new to world of writing code, so it felt like a topic that resonated with them. At least it felt like it did to me.

I got some good feedback afterwards on the talk and on my package. Much like when I published the package it felt good to put myself out there. To be honest this was really more for myself than anything. Knowing that I could get up in front of a group of strangers and talk about code I wrote makes me feel really good about where I’m at as far as my learning in the field of web development. And also like the package, as simple as the presentation was, it felt great to get something out there. Now I can take what I’ve learned and use it for future things. I’m actually excited about the idea of speaking in front of people again. I plan on giving more talks about code and my views on it.

If you have ever wanted to give a talk about technology or really anything you feel passionate about I say do it. Take the leap and put yourself out there. It’s the only way to really know how it will make you feel.

I published my first package to NPM!

As I have been learning more and more about developing software for the web I have been wanting to be part of open source software and getting code I’ve written out in front of people. Part of that is writing about code here on this blog and another part is writing code and publishing it somewhere people can find it. I recently did a post about my plans to publish my first package to NPM and now I have done it, hooray! Just moments ago I published the package.

The package is an ExpressJS project boilerplate creator. It creates a simple directory structure along with some files to get started in creating an ExpressJS app. If you are interested in seeing it you can find the project here:

https://www.npmjs.com/package/express_project_boilerplate

I’ve done some basic testing and it works pretty well. There is on occasion errors that I have to look into, but running the package again seems to work. So, that should be fun to troubleshoot, yay!

But, really getting this project out in the world is really meant to be the catalyst for me to get over my fears of putting code I’ve written out there. It may not be the most sophisticated and it may not even be the best way to do this, but it is code I’ve written and it does the thing it is meant to do. That is pretty cool to me.

Let me know if you have any questions in the comments!

Deploying my first app to Heroku

I recently checked off a couple of goals for myself in learning web development, deploying an app to Heroku and building an app that uses the Smartsheet API. I was able to do it with one project, a Smartsheet based quiz game. It has a familiar style and game play to a certain well known and trademarked game show. I originally made this game as a simple HTML page using JQuery to hide and show the questions and answers. It worked for its purpose, but was difficult to maintain since the questions and answers were in the markup. If you wanted to edit the game you had to go into the HTML. I also didn’t have it hosted anywhere so to use it you had to share a folder and open the index.html file.

I started to think how it would be a great project for an app hosted somewhere that could have some kind of database of questions and answers to create a new game board each time you played it. Naturally, I thought it would be great if that collection of questions could be stored in a sheet in Smartsheet. At the time there wasn’t a method to use the Smartsheet API with JavaScript, but I found out that a JavaScript SDK was being built using NodeJS. So, I patiently waited and once it was available started working out ideas for how the app could work.

I took some time to get to know the Smartsheet API and how to work with it in Node. Once I felt comfortable I began working on the app. During this time I also worked on learning how to build apps in Express which I used in the project. It is an Express app built on top of Node with Jade, or I guess I should say Pug now, for the view templates. As I’ve been working on my learning to write code I have come to really enjoy working on back end development work over front end. The more I learn about HTTP requests and piping data into streams the less I am interested in writing click events or the hex values of colors. The process to pull the data from Smartsheet and randomly build the object for the game board was a really fun logic problem to solve.

But, I guess you can’t call yourself a full stack developer if you can’t write some CSS to go along with your POST requests. Once I had the project done and functioning it was time for the fun part of deployment. I chose to put my app up on Heroku. I had a little experience with deploying apps there before, but nothing I built myself, only apps from tutorials. It is really simple to deploy to Heroku as they make it really easy. I published the app and visited the url to see the dreaded “Application Error.” I should note that I attempted to do this deployment on a morning before work. I finished up the functionality and layout of the app the night before. I thought about publishing it then, but in the interest of getting a good night of sleep I chose to not do it. I woke up the next morning with it still on my mind and had the great idea of deploying the app over breakfast. I started troubleshooting the errors and almost forgot to go to work as I got so involved in research. I ended up bringing my laptop to work to finish it up in my free time.

Looking at the app I realized I hadn’t updated my port to the environment variable so that it loads to the assigned port. Instead it was still going to port 3000, which I was using for testing. I adjusted my app.js file and updated the app on Heroku, but still got the error. Looking at some support docs I found some mention of supported versions of Node and since 6.0.0 had just come out my version of 5.x didn’t look to be supported anymore. I updated my version of Node and the app still worked locally, so I pushed that change to Heroku. This allowed me to load the first page, but the game board failed with the same error.

Looking at the app logs I saw it wasn’t finding needed environment variables. I remembered that I am using dotenv to set some environment variables so that I can connect to the Smartsheet API, but keep them out of the files I am pushing up to Github. Call me crazy, but publicly displaying my API access tokens seems like a bad idea. Next, I looked up how to set the environment variables for the server for my access token and everything started working! Once the server could connect to Smartsheet for the data it was able to do everything it needed.

Now the game is up and running. It is awesome to think about how an application I built and designed end to end is on the internet. I definitely learned a lot in regards to Node, Express, and especially Pug (Jade?) since it was my first time using a template language to build out a front end. It also gives me a great idea of where I want to go next in my learning. Now that I’ve got a good understanding of Node and Express I’m looking to start learning Mongo and Angular to complete the rest of the MEAN stack. I’ve joked around with the idea of making apps that work with Smartsheet are like SEAN apps(Smartsheet-Express-Angular-Node). It would be awesome if that became a thing.

If you want to check out the Smartsheet quiz game app you can find it here:

https://smartsheet-quiz-game.herokuapp.com/

And the Github repo is here:

https://github.com/daveskull81/smartsheetQuizGame

I’d totally be interested in any feedback or ideas. I have a list of a few things to add for a next version, but it would be cool to hear what others have to say. Let me know in the comments! 🙂

Building my first NPM package

As I teach myself to write code I’m trying more and more to get involved with open source projects and to contribute my own code to the greater JavaScript ecosystem. NPM is an awesome resource I have used quite a bit in my own projects to find helpful packages and it’s time I start paying the community back with my own code.

Last Fall I decided I wanted to create my own package as a learning process, but I couldn’t really think of anything to build. I mulled over the idea and nothing exciting came to mind. I chose to not force the issue and worked on other things. I thought to myself that I should just work on other projects and as I work I should think about the processes I’m going through. If there is something I’m doing often by hand it could be a great idea to automate it with a package and if it is something I find useful others might find it useful as well. That would make a great idea for something to publish to NPM.

A few weeks ago I had an idea. I really like working with Express to build Node apps. It makes routing super easy and it’s simple to get something up and running. In the Express documentation there is mention of a project generator. I’ve tried it out and it definitely does what it advertises, but after working with it a few times I found I was editing the folder structure pretty extensively to have it the way I like working.

So, this will be my first foray into creating a package for NPM. I’m going to make my own Express project creator. I prefer a more stripped down directory structure and this will help me automate a manual task. Most likely, only I will find it useful as it will set everything up the way I prefer to work, but maybe others wil try it and like it too.

The true point of this project is to get over the nervousness I have of creating my first package and putting myself out there in the open source community. Using a simple project to get started will help me relax. Maybe then I will have an idea that might be more community driven to solve a problem I see others facing. But, that time is not right now.

I will put up a post after I publish it. Have you published your first package to NPM recently? Or are you a seasoned pro with advice for a newbie? Let me know in the comments!

Tabs in my browser

I’m the kind of person that will have roughly a bajillion tabs in my browser open at any time, give or take. It helps me to organize things that I am working on, want to read later, or will share with people on the internets. Looking at them this morning it got me thinking that a good way to share them would be here in a list. Most of them are related to web development and my self-teaching pursuits in JavaScript and NodeJS.

  • Node for Beginners – great resource of links (a link in a list of links to a list of links?!?! Linkception!) from Raquel Vélez that covers places to learn JavaScript and NodeJS ranging from the beginner level up to advanced stuff.
  • Node Hero – a blog from RisingStack for learning NodeJS from the ground up. It is a blog series that updates weekly or sometimes bi-weekly with a new article on working in node with each topic building on the last one going the entire process of building an app.
  • Clippy.JS – this is too good to not share with everyone I know. I’ve already tweeted about it, but it deserves to be here too because it’s that good. It is a project from Smore that makes it super easy to implement everyone’s favorite digital assistant.
  • Botkit – an interesting project from Howdy to help make creating powerful Slack bots easy. My team switched to Slack as our main chat system awhile back and it got me interested in the world of Slack bots and making one for myself.
  • Meatcube – this one is technically related to code since I heard about it at a talk. I saw Ryan Lewis present on using Handlebars as a template system, which was super interesting. Ryan also mentioned that they run a small Japanese music label called Meatcube. I was immediately interested and have left it up in my browser since.
  • Make 8-bit Art – this is another one that is code related because it was made by a developer I recently followed on Twitter, Jenn Schiffer. They make all kinds of stuff, but also try to make art with code. This is one of their creations and it is a super fun site to draw and be silly with. It also makes me feel like playing Nintendo games all night, which is a pretty good feeling.

 

[UPDATED: May 2nd, 2016] – Got reached out to by someone at RisingStack on Twitter to let me know the Node Hero blog updates weekly or sometimes bi-weekly.

My first tech conference – WebDevCon

presentation space before the talk began
One of the talk rooms just before the keynote from Paul Duncan at WebDevCon.

Earlier this week, April 21st, I went to my first tech conference, WebDevCon. I heard about it from my Free Code Camp group and being free plus in my hometown I decided to go. To be honest, at first I wasn’t going to go, but Cassidy told me I should and I agreed with her. So I went and it was super fun! Having never gone to a tech conference I didn’t really know what to expect except for what I have read and seen online.
It was held at one of the Amazon buildings in South Lake Union here in Seattle, which was nice since this allowed me to walk to it. This conference is something that Amazon has been hosting internally since 2009 and this year was the first time they have opened it up to the public. It is a mostly front end focused conference and admittedly as I learn more I enjoy back end development more, but I still found the topics to be interesting and overall it was a great time.
I saw a few of the folks in my Free Code Camp group and also saw another friend of mine that works as a Java developer. The talks ranged from the performance of loading web fonts, to using observables to handle async issues, and keeping things as simple as possible in your workflow. That talk was the keynote given by Paul Duncan. He had some great points on keeping work simple and free of waste. He brought up a lot of kaizen practices and even called out the Toyota Production System as the prime example of creating waste free work. Cassidy loved hearing about this since that is her line of work at Virginia Mason now and they have a deep relationship with Toyota to create waste free work in the medical field.
My favorite talk was one given by Rachel White. Her talk was about her process making a robotic cat feeder titled Internet of Cats. The name had me, but I also saw it was built using NodeJS and Johnny-Five, so I had to check it out. Her talk was also about how scary it is to try something new and to put it out for all the world to see. She decided to make her project open source and she brought up some of the anxiety that can come from putting your thoughts and ideas out into the world for others to see and possibly judge very harshly. She gave some examples of things other developers she knows have gone through that has made them wary of working on open source software, but she also showed the awesomeness of others who have helped her on her project. It was a great talk on not only NodeBots, but also on the open source community itself and how it owes it to itself and its members to be a kind, respectful place. I really liked it.
Overall, the conference was a lot of fun. I got some stickers, a water bottle, and my brain filled with ideas on how the internet works.
This definitely makes me want to keep going to more conferences and web development type group talk/presentation things.

A decoder ring CLI for secret messages

I’ve recently been using Free Code Camp for exercises to continue my learning of JavaScript and NodeJS. Some of my favorite challenges are the algorithm scripting ones. They give you a specific process to accomplish along with expected results that your code is tested against. Once you get your code to pass all of the tests you can move on to the next one. They are super fun.

The latest one that I’ve finished challenges you to decode a set of strings using a ROT13 cipher. You have to figure out how to run through the string, taking in each character, accounting for punctuation, and then returning the appropriate letter based on the ROT13 system.

In the description of each challenge there are some tips on how to accomplish it with suggested methods to try using. But, you really are free to do it however you want. As long as the tests pass, you pass the challenge. I eventually got the challenge completed, but didn’t like my method. So, I checked out the FCC Gitter channels to see how others had accomplished it. One person had a really cool idea of creating an object to be a cipher to compare the given letters to and return the corresponding letter. I tried it out myself and was able to get my own version implemented.

This got me thinking about how it could be fun to have a little app the encodes or decodes messages using this system. It would be like a decoder ring for your terminal. This coupled with my recent discovery of VorpalJS and I had my next idea for a CLI project. Side note, I’m currently obsessed with the idea of making command line apps. It is kind of my jam.

So, I got to work on the project and it came along faster than I thought. As I was making the decode command I got to thinking about how I don’t really have to make separate functions for decoding and encoding. All I’m really doing is converting the letters from one to the other. So, I can just make a single conversion function to run for each command.

The code looks like this:

var cipher = {
"A": "N",
"B": "O",
"C": "P",
"D": "Q",
"E": "R",
"F": "S",
"G": "T",
"H": "U",
"I": "V",
"J": "W",
"K": "X",
"L": "Y",
"M": "Z",
"N": "A",
"O": "B",
"P": "C",
"Q": "D",
"R": "E",
"S": "F",
"T": "G",
"U": "H",
"V": "I",
"W": "J",
"X": "K",
"Y": "L",
"Z": "M"
};

function conversion(str) {
var converted = [];
var original = str.toUpperCase().split("");
for (var i = 0; i < original.length; i++) {
if (cipher[original[i]] === undefined) {
converted.push(original[i]);
} else {
converted.push(cipher[original[i]]);
}
}
return converted.join("");
}

I am pretty happy with it in its current state. Like my weather CLI I will revisit it later on and see what else I can add to it. If you want to check out the project you can find it here on my Github page.

I made a command line tool to lookup the weather

After typing in a zip code the results are shown on the command line.
After typing in a zip code the results are shown on the command line.

Now that I am putting the majority of my projects on Github I have been trying to come up with things to build. One of the first few things I set out to make was a command line app to get the current temperature based on a zip code. It is a simple node app that asks the user for a zip code, then looks up the current weather, and reports it back. I am using a couple of free APIs to make it happen. For the weather data I am using Forecast.io, but that requires a latitude and longitude to get the data. To get that based on a zip code I am using Zippopotam.us.
The basic flow of the app takes the user input using an npm package called Prompt and makes the request to Zippopotam.us. That returns a latitude and longitude for the zip code which is then passed into the call to Forecast.io along with a name for a city/town in the zip code.
The results are then printed out to the console in a basic sentence. I built something similar to this from a tutorial on NodeJS I did awhile back. I thought it would be a good starting point for getting up and running on Github as well as get me going on the “just build stuff” advice I get from basically everyone. I really liked the fact that this time around it was much easier to build and get working. I feel like I could have just built it in one sitting. I didn’t because I didn’t want to rush things, but it felt really good that this wasn’t as hard as I remember the tutorial being. It’s like I have actually learned a few things when it comes to building stuff in NodeJS.
If you want to see the code or even use the app yourself you can find the repo here. Feel free to submit a pull request if you come up with anything it needs.
I wouldn’t say this is complete, but it works pretty well. Let me know what you think!

Something I built is on the internets!

Something I built is live on the internets for all to see, OMG! It isn’t much, but dagnabit it’s true. What I am gleefully kermit flailing over is the website I built, awesomebandname.com. It is a simple site where you can click or tap on a button to be given a random selection from my personally curated list of awesome band names. For the longest time I would hear something and think how it would make a great band name. I started collecting these together into a comprehensive list of awesomeness. At one point I was posting them in a series on an old blog of mine. These posts were always the most enjoyed by my few readers. That blog is no longer with us, but I still kept up the list.

After coming to work at Smartsheet I started keeping them in a sheet as my repository of awesomeness. It is three columns for names, source, and notes. The source column is for if I heard it said by someone else and it wasn’t thought of by me directly. As of this writing there are 183 entries.

I have been teaching myself web development for a couple of years now and I am at that not a beginner, but not quite advanced point where the only advice anyone gives to continue learning is to “just build stuff.” So, this seemed like a great idea for a project. It is really just a simple website rather than a fully fledged app, but it does the thing I built it to do.

Everything is laid out on the page with Bootstrap. The well gets a randomly selected band name placed within it on page load and there is a simple JQuery click event on the button that empties the well, chooses another randomly selected band name, and places that within the well. The random selection is done via a random number selection function that I got from MDN.

The JQuery looks like this:

$(document).ready(function() {
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
$('.nameDisplay').append(bandNames[getRandomInt(0,bandNames.length)]);
$('.nameButton').click(function() {
$('.nameDisplay').empty().append(bandNames[getRandomInt(0,bandNames.length)]);
});
});

The entire thing is two documents, one HTML file and a JS file that is the collection of band names in an array called bandNames. Bootstrap and JQuery are brought in by CDNs. I thought about having all of the band names in the html file to make it all work in a single document, but that didn’t seem worth it and I figure it would only clutter things up. I added a tweet button to make sharing easier and a Google ad, just in case this gets tweeted by Wil Wheaton or some other viral internet craziness type event happens. I figure it couldn’t hurt to get a few ad impressions while I’m at it. I did try to install a Facebook share button as well, but that wouldn’t show up on the page. To be honest, I didn’t spend much time troubleshooting why. I will be leaving that for v2 of the project.

My favorite part of the project is how I create the JS file with the array of band names. In the interest of dogfooding I keep all of the band names in a sheet in my Smartsheet account. Originally I was going to copy and paste the names into a JS file and manually make the array, which would have worked, but would have been boring and tedious. Updating it later on would have bothersome too with the possibility that I could miss one or have double entries. To keep this from happening I employed the Smartsheet API. Recently, the Smartsheet API has been given a JavaScript SDK that is written in NodeJS which just so happens to be the thing I am teaching myself and prefer to work within.

I have already been working with the Smartsheet API for fun so that part was pretty straight forward. I ended up writing a script that pulls down the content of the sheet, stringifies all of the entries, and then concatenates all of that into a file called bandnames.js. I was especially happy when I thought of making it write out the “var bandnames = [“ at the front and ending the file with “];” to finish off the array. Now, when I update my sheet I can run this script and I get a new JS file to put up on my server for the website. No worrying about if I missed one or entered one more than once, just a nice brand new JS file.

I wouldn’t say this project is done yet, but I am proud to say it is a good v1. Next, I need to fix the Facebook share button problem and also figure out why my Google ad isn’t displaying on mobile devices. I may also play around with the layout and overall design. My original intent was to use a Bootstrap theme that makes sites look like they were built in Geocities, but I changed my mind. I may still go back to a sillier design approach to go with the humorous intent of the site.

If you feel like checking it out go to awesomebandname.com. Note, that some of the names may contain some adult language and may be a little NSFW. Enjoy!

UPDATED
This project has been moved to Github! The links in the post have been updated. If you want you can find the project here:
http://daveskull81.github.io/awesome-band-names/

Find out more about the move in the post here.

I like coffee, code, and photography…

I like coffee, code, and photography…

Hello!

My name is david inden. As the subject of this post says, I like coffee, code, and photography. This is where I plan to talk about these things. I am teaching myself to develop web applications, brew coffee, and take photos, both digitally and with film. Here I will talk about these things as I learn from my mistakes and triumphs and probably also occasionally state an opinion about the world around me. I hope you will enjoy.
I make no promises to never be vulgar as that is sometimes unavoidable, but I can promise that I will always be honest. In the past I have put together several of these blog thingys and this time I think it can stick. I like the idea of putting myself and my thoughts/creations out there for anyone and most likely no one to read.
I will try to keep most posts within the bounds of my three subjects, but if I feel like talking about something I’m probably going to do it.
Other things I like are sci-fi/fantasy books/tv shows/movies, so expect me to fly my nerd flag proudly and I’m pretty sure I can work in a Star Trek or Old Man’s War reference into a post about cold brew, just sayin.
So, come along and join me on this fantastic adventure that is the journey to the center of my brain. WARNING: May be wet and/or squishy.