Classy Coding

My Journey to Code


Leave a comment

Javascript Under Pressure

Yesterday, I completed the javascript under pressure game online. The game gives you 5 challenges with a series of tests that should pass if completed correctly all while there is a timer ticking away. This at first sounds intimidating however the timer doesn’t really mean anything. You can take as long as want so for me I didn’t even really look at the clock. What is helpful and worth your time is the fact that there are a series of tests that check your code. So your code may work for these simple cases however, there are more complex cases that your code will break on. This is fantastic because you it forces you to think more about how to make your code more generic and efficient. More in terms of general cases instead of specific set of cases that you are familiar. These helped me find methods in javascript that I had not seen before and how to structure my loops to make efficient use of my conditions. 

One example of this was challenge 3 where you were given a string that may or may not have a file extension. You needed to write a condition to output the extension if there was one or false if there was no file extension. This at first seemed straight forward however, it can quickly become tricky.  At first, I simply used the splice method by “.” and then since that puts it into an array you can quickly return the file extension through the index notation. However, you could also check using the indexOf to check the array for the presence of “.”

The last challenge was the most challenging. This challenge I learned a lot since javascript does not have classes. For example the challenge gave you an array and your code should return the sum of the array. However, this is no simple task since you could be given an array of arrays with strings or numbers so you need to find a to check for these conditions. My first attempt had nested for loops (quite horrendous to look at really) but it broke on the last test because it was an array like this: [ [[[[[[[[1]]]]]]], 4,5] therefore, my nested loop would break and the way I had structured my code I would need to know exactly how many times to loop through however, that didn’t seem to be the most efficient way to go about doing it. I realized I needed to have a recursive call for this iterative function that way it didn’t matter what I got so an array like this: [ [[[[[[[[[[2,3,]]]]]]]]]],4,5] would not break. Therefore, it actually ended up making my code shorter by doing this and I was able to take out the ugly nested loops. This helped me get more comfortable with different methods in javascript that I didn’t know about beforehand. That way when I have a more complicated problem I already have more tools in my toolbox now. Unfortunately, this website does not allow you to go back to the code you submitted otherwise I would have copied and pasted it in here to better explain. 

I’m going to post some more examples on my refactoring as I learn more in javascript. Stay tuned. 

Advertisement


Leave a comment

Getting Inspired

I just read such an inspiring posting about a documentary that is currently in the making to showcase and spread the stories of incredible women who have succeeded in the tech start up world. Some of the stories they listed were absolutely amazing, women creating businesses and showing their programming skills as well. After reading these stories I am incredibly inspired and just by reading about other successful women who have tackled programming challenges and able to see so many women with the courage to make their own businesses is so incredibly inspiring. I can’t wait to see this documentary when it is completed. I think this was a very much needed boost as I continue through my coding journey here at MakerSquare. 

You can read more about the documentary here: http://www.indiegogo.com/projects/she-started-it-a-documentary-on-women-founders

Hope this inspires you as much as it did for me. 


Leave a comment

Relieve Your CSS Anxiety

Yesterday, MakerSquare held a seminar on design and thanks to the wonderful Elyse Holladay she gave an awesome presentation and tools that I want to share.

If you are starting out a project the first thing you should do is get your basic layout set. The best tool to do this is to use borders around all your divs so you can be sure you aren’t using a CSS trick to visually fix any issues but actually solving your issue. So beware with CSS tricks that look like they solved the problem but they just hide your real problem and then if you have to expand on your layout you will run into problems.

Also, there is a fantastic tool called CodePen where you can put in your html, javascript, and css to see how your changes will look before committing them and having to refresh your page to see what your changes did. This is such a time saver and I tried this on a sample code that Elyse provided and you can really learn how floats work in your layout by doing this. Before learning this, doing any styling was so painful and took three times as much time.  I found using this in combination with the border trick to see my issues and fix them. Check out this awesome blog post about all the different code playgrounds such as code pen so you can choose the best one for yourself to work with: http://www.sitepoint.com/7-code-playgrounds.

Begin any CSS project using borders, using a code playground, and begin with your basic layout before diving too deeply into your styling. These are the tips that I have learned this past week in my studies at MakerSquare and I hope they will help you as much as they did for me. I didn’t like CSS until I learned these steps and tools. So thank you MakerSquare and Elyse Holladay for relieving my CSS anxiety!


Leave a comment

How to Use an API with Ruby

This past week I learned how to use an API with Ruby! It is amazingly easy so here are the steps.

Step 1.

Go to  http://rdoc.info  or https://www.ruby-toolbox.com/ to search for the API. Both sources are reliable and have an extensive collection with documentation. Searching for your gem is so easy!

Step 2.

For ruby-toolbox, this is how your screen will look. This gives you information regarding the gem version, release date, bug tracker, pretty much all the info you could possibly want. Then it gives you the github link as well as the rdoc link.

Image

Step 3.

When you click on the Rubygem, you be taken to this page https://rubygems.org/gems/twitter This gives you instructions on installing the gem. Pretty easy so far!

Step 4.

The documentation link (this link appears on both screens at step 2 and 3) re-directs you to the rdoc page that explains in detail the functions available to you with this gem.

This includes further installation instructions:

Image

a quick start guide (with a link to registering your application so you don’t have to search around for that!):

Image

….and the best part gives you usage examples that are INCREDIBLY helpful. This allows you to see all the methods available to you while using this gem. Pretty awesome!

Image

Step 5.

After installing the gem, registering your application with Twitter, finish configuring with the authentication codes you received during registration. Follow the configuration format provided in the quickstart section listed previously. Don’t forget to require your gem in your ruby document.

Step 6.

That’s it! You are set up with the Twitter API gem. This instructions can easily work with any API you are hoping to use in your ruby code.


Leave a comment

Completed My First Hackathon!

This past weekend I completed my first hackathon at MakerSquare.

Check out my group’s app at: tweet-o-phone.herokuapp.com 

The app is basically like a game of telephone through Twitter and Giphy. You give a word then Tweet-o-Phone searches Twitter for a tweet with that word. Then takes that tweet and chooses a random word from it to give to Giphy. The ouput is a hilarious gif that may or may not be related to your original search….so fun to see how things get translated through social media. 

We used the Twitter and Giphy Ruby gems. I have to say that the gems make it really easy to access the data you need. It was a blast!