Opening Sublime From Powershell

Lately I've been setting up my environment on my Windows laptop. What really bothered me is that I was unable to open Sublime directly from Windows Powershell. Turns out it's not that hard to do!

So first, open Windows Command Prompt. Make sure you choose "Run as Administrator" so that you can make the modifications necessary.

Next, paste the following code into the prompt:

Close the Command Prompt window and restart PowerShell. Check it out! Now you can use the command subl to open Sublime or basic file commands such as subl . to open the folder you are currently in in Sublime.

Happy Coding!

Project Euler #2 - Ruby

Time for the second Project Euler post!

Project Euler #2

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. Project Euler #2

So it looks like we need to find all of the even numbers in the Fibonacci sequence, and then add them all together.

Calculating the Fibonacci Sequence

It seems like a good place to start would be finding the Fibonacci Sequence up to the limit specified by the question. The next number in the sequence is found by adding the previous two terms. The question shows that the sequence starts with 1 (actually, it starts with 0 followed by two ones, but we'll follow the problem) and the following number is 2. We'll specify our starting points in the code.

The code above will set new_num to 2 + 1 which is 3, the next number in the sequence. However, this code can only ever find the next number after the first two numbers. We're going to want to keep going until we hit the limit. This seems like the perfect time for an until loop.

Now this code has a few problems. First, limit is never defined. We can fix that by wrapping our code in a function that has the limit as a parameter.

Our code still has a major issue. The loop will continue forever since we are never changing the value of num. Since we also don't change the value of previous_num, new_num will always be three, so this code doesn't get us any further in the Fibonacci sequence. We need to update the previous_num as well as the current num in order to keep going in the sequence.

Now we're finding all numbers in the Fibonacci sequence up to the limit!

Calculating the Sum

Finding all the numbers in the Fibonacci sequence up to the limit is great, but we're not actually doing anything with those numbers. The problem specifies that we're going to ultimately want the sum of the even numbers, so we should probably keep track of that as we go along.

So now we check if the nummber is even and if it is, add it to our sum, all we need to do now is make sure we return that sum, which in Ruby is generally done implicitely.

Arriving at a Solution

To get the solution, run your code! In the terminal, running ruby file_name_here.rb with whatever you named the file that you are coding in, will display the soluton to the terminal screen. When you think you have a solution, you make sure to submit it here.

If you feel that you have a better solution, post a gist to it in the comments!

Project Euler #1 - Ruby

I am going to start solving all of the Project Euler problems on my blog. This will take an incredibly long time, but I believe that it's a great warm up for coding. So that being said, there's no better place to begin than with number 1.

Project Euler #1

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6, and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000. Project Euler #1

After reading the problem, I have a basic understanding of what I need to do. I need to first find all of the multiples or either 3 or 5 that are less than 1000. Once I have those multiples, I need to add them all together to get my solution.

Collecting the Multiples

First I need to find all of the multiples under 1000. In order to do that I have to know what makes a number a multiple or 3 or 5. A great way to tell is if the number in question divided by either 3 or 5 results in a whole number with no remainder. If this is true, the number is evenly divisible by either 3 or 5 and a multiple. I know that Ruby has a great function for checking for remainders called modulo.

This code will return true if the number_in_question is a multiple of 3 or 5. However, we stil have no way of finding the number_in_question.

The problem gives us a hint at where to start for this part. The problem is asking for all multiples that are below 1000. Therefore, we need to check all numbers below 1000. That suggests that we need to use an exclusive range. So to collect all of the numbers below 1000 in an array we can do the following:

However, this will collect all of the numbers below 1000, and we only want the numbers that are multiples of 3 or 5. To do this, we can use the select method.

This will only select numbers that are less than 1000 but a multiple of either 3 or 5 and store them in an array. Let's turn it into a function, so that it is easily accessible for our next step.

Now that we have access to an array of all the multiples we want, all we have to do is add them together. Luckily, Ruby has a great function to help us out. The reduce function will allow us to perform an operation on all of the items in an array. So to find the sum of the multiples this is all we have to do:

Arriving at a Solution

We've done all the coding necessary to find the solution! Now I don't want to give it away, so I'm not going to post it here, but if you're unsure if your code works or not, look at the example in the problem. Use 10 as your limit and try to get 23 as a result. When you think you have a solution, you can sign up for a Project Euler account and submit it here. Here's some proof that this code works:

And if you want to see all the code in one place:

In the terminal, running ruby file_name_here.rb with whatever you named the file that you are coding in, will display the soluton to the terminal screen.

If you feel that you have a better solution, post a gist to it in the comments!

What Is Software?

Engineers build things. That's pretty much their job description. So what makes the product of software engineering any different than that of other engineering? To really answer this question we need to look at the characteristics of software.

1. Software is not manufactured

Electrical engineers design circuit boards that are then manufactured. Mechnanical engineers build machines that are then manufactured. Biomedical engineers build medical devices that are then manufactured. Software engineers build software that is then. . . Wait. How do we manufacture software? The answer is simple: we don't. Yes, software engineers design and build software, as other engineers design and build their products, but that software can't be manufactured since it's not a physical product. This removes any of the quality issues that can arise when a product is manufactured, which is extremely beneficial to software engineering teams.

2. Software doesn't wear out

Software is not a physical product, so there's nothing physical to wear out over time. Suppose I have a simple program that simulates a swing.

Now suppose we want to play on our swing set.

Now we're really enjoying our brand new swing set, so we swing a lot. . .

Shouldn't the swing have worn out? I suppose that's a silly example, but it illustrates my point. A physical swing would wear out after that much use, software, on the other hand, has nothing physical to wear out. Software can become outdated, but that's certainly not due to overuse.

3. Software can be undone

You've just designed the latest and greatest iPhone. You expect to be sold out by the end of the first day of sales. You manufacture them and they start to sell. You've sold over a million in the first 10 minutes. . . but none of them work. Apparently, there was an error in the manufacturing and all the iPhones are defective. You need to find a new manufacturer and deal with angry customers, which costs a lot. What a mess.

Let's change the situation a bit.

You've just designed the latest and greatest feature for Facebook. You roll it out to users and find out soon after that it has a major bug. You immediately rollback (go back) to the last working version which undoes the last buggy deployment, all within a matter of minutes, costing you pennies.

All this is possible with version control, something that's pretty unique to software. However, you have to make sure that your version control is being used properly in order for this to work.

4. Software is endless

In the swing set example mentioned earlier, I could have made the loop something like this:

Ten million swing sets would have been made in seconds. That's just not possible in hardware. Even if we had enough materials and millions of swing set factories, eventually we wouldn't be able to make anymore. With software, we can just keep make swing sets. The code does not care. The only potential pitfall would be lack of memory, but that can always be fixed. Software can make millions of copies for free practically instantaneously. That's definitely not a property of hardware.

Conclusion

Software is a product. However, software is unique in many of its properties. Because of this, building software is unlike building any other product. The quality can increase dramatically in a short period of time because of the ability to test components and different methods of doing the same thing without needing a multitude of resources. Furthermore, manufacturing is not a concern, which cuts out a huge cost of production. At the end of the day, software's unique properties provide its developers with a multitude of opportunities at a low cost.

This post uses many concepts found in Software Engineering: A Practitioner's Approach by Roger S. Pressman

Coding the Universe

Space. There's a reason that NASA and SpaceX are extremely selective with their employees. This week I, along with three other Flatirons, have been working on a web application that would allow the user to see the stars that would be above them that night in their location. So far it's a simple one page application that grabs the user's location when they go the site, crunches the numbers, and displays the result. Sounds simple right? Wrong.

Well, not fully wrong. But partially wrong. The code isn't that complicated. Just a matter of passing around information from JavaScript to Rails and back again. That doesn't sound too hard, and it's really not. But there's one problem. . . getting the information.

Well, not all the information is hard to collect. Getting the user's location is simple. Using that information is hard. Think about it. We have the earth, right. And a person on that earth with a latitude and longitude. And let's just say that person happens to be at The Flatiron School, which has a location of 40°42'19.3"N 74°00'50.2"W. Suppose that very person decides to check out our website. As soon as they arrive their location information is collected using JavaScript. An AJAX call later, that information is available in a controller. Let's take a step back. We have the user's coordinates. As far as stars are concerned, what does that give us? Everything. At least, everything that we need from the user.

Our user wants to see the stars. So let's listen to a popular piece of business advice and "give the user what they want". How do we do that? Well, we have their location. Let's think about how that relates to the stars in question. The user can only see the stars that are above them at night. For simplification purposes, let's say that the person can see the stars above the plane tangent to their location on the earth. So how do we find what stars are above that plane given the person's latitude and longitude? "Projecting an Arbitrary Latitude and Longitude onto a Tangent Plane" by Ivan S. Ashcraft provides the mathematical formulas for finding the tangent plane given the information we have been provided with. However, since we need to find the stars above, below, or on that plane, we only really need the normal (or perpendicular) vector to the plane. Following Ashcraft's formulas we can get the i, j, and k components of that normal vector, which Ashcraft labels as A, B, and C. Now that we have the normal vector, we need to adjust it to use the coordinate system that our stars use, the Galactic coordinate system, which uses the sun as the center. Because of the earth's orientation in comparison to the Galactic coordinate system, we need to rotate the normal by -240 degrees. So we have the normal to the plane, but how do we figure out which stars are above that plane?

Finding out whether a star is above, below, or on the plane is simple, all we need to do is the dot product. For each star, we dot the coordinates with the i, j, and k components of the normal vector. This gives the following formula: Ax + By + Cz. If the result of this formula is positive, we know that the star is above the plane and therefore visible at the location. If the result is negative, the star is below the plane and not visible. If the result is 0, the star is on the plane, which for this situation we'll consider not visible. That wasn't too hard, now was it?

At the end of the day, the project wasn't too difficult. However, conceptualizing what we needed to do to the data that we had to achieve our desired results was extremely difficult. Especially with the added pressure of a week deadline. However, by staying cool and taking things one step at a time, my group and I successfully finished LUMENsee. Check it out!

Low Self-Esteem? Try Coding

Learning to code leads to much more than just a practical life skill. Throughout my journey at the Flatiron School I've noticed an unexpected benefit to learning how to code. At week nine I feel confident and ready to take on the world. Now don't get me wrong, I still have a lot to learn, but I'm already finding that I'll be in the middle of doing something, find that I don't like how I have to do it, and create a way to fix it. For instance, I wanted to tweet news articles, but didn't want to do it manually. I created a program for it. I don't like the way my school's enrollment website looks. I'm making a Chrome extension to change that. At week 9 in my programming career I can take a simple problem and fix it. Furthermore, I've been given the tools I need to improve my skills and be able to create anything. All it takes is a computer and some practice. That is powerful.

One of the best parts of learning to code is that it can be as cheap as you want or need it to be. While I chose to go down the bootcamp path, many have not. With many online resources, learning the basics of coding can be completely free. If you want to start, check out these free websites:

Reading coding books is also a great way to learn to code. I find that the best way to really understand what the code is doing is to read about it. There's plenty of free books available as well:

I listed Ruby books since that's what I'm learning, but you can find an extensive list here.

I also highly suggest getting involved in the social aspect of programming. It keeps it interesting and gives you lots of opportunities to learn something new, or think about something from a new point of view. Some great communities to check out are:

At the end of the day, it all comes down to the effort you're willing to put in. But remember, learning to program leads to a new way to express yourself, which brings along many unexpected benefits and an open door to opportunity.

How to Turn an Array Into a Hash Using Ruby

It seems like the hardest part of learning a language is knowing its tricks. In Ruby, one of these tricks is turning an array into a hash. So let's get started!

Suppose you have the following array:

This array seems to be assigning a level of elegance to the item before it, so a hash may be better suited for it. You could iterate through the array and assign the values into a hash, however Ruby provides an easier way to accomplish this:

That's it! Hope you enjoyed this short but sweet refactor tip!

How Coding Bootcamps Are Like Greek Life

Coding bootcamps are popping up across the world. As a student at a NYC bootcamp, the Flatiron School, as well as a sorority sister of Delta Phi Epsilon, I couldn't help but notice some similarities between the two.

New Member Class

Even if you don't know much about Greek Life, "pledge classes" are notorious. Now commonly referred to as a "new member class", this is a group of people working towards full membership of the sorority or fraternity. New member classes are encouraged to do everything with each other while they bond over the shared difficulty of balancing the time commitment, classes, and other life responsibilities. I finished pledging by the spring semester of my freshman year, however I find myself repeating the experience in many ways at the Flatiron School. Instead of a pledge class of college girls, I'm working with a cohort of men and women in all walks of life. We all are working towards the common goal of graduation from the program as well as jobs in software development. During this experience, we all have to balance the intense workload as well as commutes and real world responsibilities. In many ways, my cohort is my pledge class.

Mentorship

One of the most exciting parts of pledging is getting a big. This generally happens around halfway through the pledging process. A big is expected to be a mentor to their little and support them through pledging and beyond. At the Flatiron School, we call this "mentorship". In week 6, which is halfway through the bootcamp, we receive our mentors. We can then contact our mentor via email and ask them questions about their experiences. If they are local and available, we have the option of meeting with them in person as well. While this mentor is not as much of a physical presence as a big, their role is the same. They share their experiences as someone that has previously experienced the long journey of becoming a developer and can be there to support their mentee through their journey.

As a pledge class, we looked forward to the day that we would become full members and finally be able to wear letters. It was a common part of conversation, as we would plan out what letters we would get and what fabric we would use to make them. At the Flatiron School, my cohort is excited for the day we get our own Flatiron School hoodies (especially when the air conditioning is a tad too cold). As a pledge, seeing the sisters wearing their letters was seen as something to work towards. As a budding developer, seeing the TAs, faculty, and alumni wearing Flatiron gear is a push to keep working hard and a reminder that graduation isn't all that far off.

Crossover

As a new member, crossover is the ritual of rituals, the night that everyone has been waiting for, yet came as a surprise. When I was pledging, the date of crossover was kept a secret, so while we looked forward to it, we never knew quite when it would be. However, when it came it was extremely exciting. We were finally being accepted as full members of the organization that we had grown to adore. At the Flatiron School, graduation holds a similar excitement. While we know when we will be graduating, we can't help but get excited for crossing over from a Flatiron student to a Flatiron alumna.

Conclusion

Sorority life and bootcamp life aren't all that different. Both involve a community of people looking out for each other. Both have new members that go through a journey towards a common goal. Both encourage their members to be their best version of themselves. Personally, I think that's pretty neat.

How Coding Bootcamps Are Like Greek Life

Coding bootcamps are popping up across the world. As a student at a NYC bootcamp, the Flatiron School, as well as a sorority sister of Delta Phi Epsilon, I couldn't help but notice some similarities between the two.

New Member Class

Even if you don't know much about Greek Life, "pledge classes" are notorious. Now commonly referred to as a "new member class", this is a group of people working towards full membership of the sorority or fraternity. New member classes are encouraged to do everything with each other while they bond over the shared difficulty of balancing the time commitment, classes, and other life responsibilities. I finished pledging by the spring semester of my freshman year, however I find myself repeating the experience in many ways at the Flatiron School. Instead of a pledge class of college girls, I'm working with a cohort of men and women in all walks of life. We all are working towards the common goal of graduation from the program as well as jobs in software development. During this experience, we all have to balance the intense workload as well as commutes and real world responsibilities. In many ways, my cohort is my pledge class.

Mentorship

One of the most exciting parts of pledging is getting a big. This generally happens around halfway through the pledging process. A big is expected to be a mentor to their little and support them through pledging and beyond. At the Flatiron School, we call this "mentorship". In week 6, which is halfway through the bootcamp, we receive our mentors. We can then contact our mentor via email and ask them questions about their experiences. If they are local and available, we have the option of meeting with them in person as well. While this mentor is not as much of a physical presence as a big, their role is the same. They share their experiences as someone that has previously experienced the long journey of becoming a developer and can be there to support their mentee through their journey.

As a pledge class, we looked forward to the day that we would become full members and finally be able to wear letters. It was a common part of conversation, as we would plan out what letters we would get and what fabric we would use to make them. At the Flatiron School, my cohort is excited for the day we get our own Flatiron School hoodies (especially when the air conditioning is a tad too cold). As a pledge, seeing the sisters wearing their letters was seen as something to work towards. As a budding developer, seeing the TAs, faculty, and alumni wearing Flatiron gear is a push to keep working hard and a reminder that graduation isn't all that far off.

Crossover

As a new member, crossover is the ritual of rituals, the night that everyone has been waiting for, yet came as a surprise. When I was pledging, the date of crossover was kept a secret, so while we looked forward to it, we never knew quite when it would be. However, when it came it was extremely exciting. We were finally being accepted as full members of the organization that we had grown to adore. At the Flatiron School, graduation holds a similar excitement. While we know when we will be graduating, we can't help but get excited for crossing over from a Flatiron student to a Flatiron alumna.

Conclusion

Sorority life and bootcamp life aren't all that different. Both involve a community of people looking out for each other. Both have new members that go through a journey towards a common goal. Both encourage their members to be their best version of themselves. Personally, I think that's pretty neat.

Markdown Cheat Sheet

Markdown is used a lot, so I figured a cheat sheet could be useful, so here goes:

Tables

Headings in Markdown are preceded by the octothorpe (#). You can also add trailing octothorpes, but this is optional.

Another way to create heading 1 and heading 2 are with equal signs (=) or dashes (-) under the text you want in the header.

Paragraphs

Paragraphs are determined based off a new line or at least two spaces at the end of a line.

Horizontal Rule

You can break up paragraphs with a horizontal line.

Just do any of the following:

___ Three underscores

--- Three dashes

*** Three asterisks

Text Styling

For text styling, the asterisk (*) or underscore(_) is used.

Bold

To make an item bold, use two asterisks on each side of the item.

Italic

To make an item italic, use one asterisk on either side of the item.

Strikethrough

To strikethrough an item, use two tildes (~) on either side of the item.

Escaping Characters

Some characters have meaning in Markdown, so when you want them to be displayed you may run into issues. You can escape these characters, so that you can display them without side-effects. To do so, put a backslash (\) before the character.

The following characters have this property:

Symbol Name
# Octothorpe
+ Plus Sign
- Hyphen
\ Backslash
 Backtick
* Asterisk
_ Underscore
{} Curly Braces
[] Square Brackets
() Parentheses
. Period
! Excalamtion Point

For links, the text you want displayed is kept in brackets([]), with the link kept in parentheses (()). You can also include a title after the link, which generally appears as a tooltip. These links will open in the current tab, so if you want the link to open in a new window or tab, use the html syntax.

You can also use a reference style for links.

Named Anchors

If you want to create navigation from within the page, you can use named anchors, which is basically a link. At any headings that you want to be able to jump to, add <a id="named-anchors"></a> so that the headings will look something like this:

You can also put the link of the line of the header, but this will bring you to the content and cut off the header. To create a link to each one of the headings you would do so in the same style as a normal link.

Paragraphs

Named Anchors

Images

Images are also similar to links. They use the same syntax, but have an exclamation point (!) preceding them. The text in the brackets will act as the alternative text, should the image not be able to load. The text after the url is what will show up as a tooltip when the user hovers over the picture.

You can also use a reference syntax.

Lists

Unordered Lists

To create an unordered list use either an asterisk (*), a plus sign (+), or a hyphen (-) followed by a space before each bullet.

• This is a bullet
• This is also a bullet
• This is a lower level
• Even lower
• And lower
• So low
• Almost through the earth
• And back up

Ordered Lists

Ordered lists are pretty self explanatory. Simply precede each item in the list with the number or letter, followed by a period, followed by a space.

1. This is the first item!
2. And this is the second
3. I think you get it. . .

The numbering you put doesn't necessarily affect the numbering. For instance:

Produces the following list:

1. I'm number 1
2. I'm number 2
3. I'm letter A
4. I'm number 64

Quotes

Quotes can be inserted by putting a greater than sign > at the beginning of the line. To site the sourse, use the <cite> tags.

My greatest pain in life is that I will never be able to see myself perform live. Kanye West

Code Snippets

Inline

To create an inline code snippet (like this!), use the backtick () on either side of the item.

Indented

You can create a code snippet through the use of indentation. Add four spaces to the beginning of a line of code for this to work.

This is code.
Am I right?


Block

To create block code, which is what I've been using for all of the code examples in this cheat sheet. To do this use three backticks on the top and bottom of the code snippet. Next to the top three backticks, you can specify the language that you are writing the code in so that the syntax will be higlighted appropriately. If you're not sure what code to use for a particular language, check out the short codes on this reference guide.

Tables

Tables can be created through the use of pipes (|) to separate columns and dashes (-) to separate the titles from the rows.

Id Name Description
1 Elle Woods Lawyer in pink
2 Emmett Forrest Handsome husband
3 Bruiser Woods Chic chihuahua

By default, the table will be left aligned. If you want to center the items in the table, use colons (:) as follows:

Id Name Description
1 Elle Woods Lawyer in pink
2 Emmett Forrest Handsome husband
3 Bruiser Woods Chic chihuahua

You can also right align the information.

Id Name Description
1 Elle Woods Lawyer in pink
2 Emmett Forrest Handsome husband
3 Bruiser Woods Chic chihuahua