Elegant Development

For all your programming needs

Opening Sublime From Powershell

| Comments

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:

1
2
3
4
5
6
7
REM Begin Copy
powershell
Set-Content "C:\Program Files\Sublime Text 2\subl.bat" "@echo off"
Add-Content "C:\Program Files\Sublime Text 2\subl.bat" "start sublime_text.exe %1"
if (!($Env:Path.Contains("Sublime"))) {[System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";C:\Program Files\Sublime Text 2", "Machine")}
exit
REM End Copy

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

| Comments

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.

1
2
3
num = 2
previous_num = 1
new_num = num + previous_num

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.

1
2
3
4
5
num = 2
previous_num = 1
until num >= limit
  new_num = num + previous_num
end

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.

1
2
3
4
5
6
7
def even_fibonacci_sum(limit)
  num = 2
  previous_num = 1
  until num >= limit
      new_num = num + previous_num
  end
end

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.

1
2
3
4
5
6
7
8
9
def even_fibonacci_sum(limit)
  num = 2
  previous_num = 1
  until num >= limit
      new_num = num + previous_num
      previous_num = num
      num = new_num
  end
end

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
def even_fibonacci_sum(limit)
  num = 2
  previous_num = 1
  sum = 0
  until num >= limit
  if num.even?
      sum += num
  end
      new_num = num + previous_num
      previous_num = num
      num = new_num
  end
end

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
def even_fibonacci_sum(limit)
  num = 2
  previous_num = 1
  sum = 0
  until num >= limit
  if num.even?
      sum += num
  end
      new_num = num + previous_num
      previous_num = num
      num = new_num
  end
  sum
end

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

| Comments

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.

1
(number_in_question % 3 == 0) || (number_in_question % 5 == 0)

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:

1
2
limit = 1000
(1...limit).to_a

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.

1
(1...limit).select{ |i| (i % 5 == 0 || i % 3 == 0)}

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.

1
2
3
def collect_multiples(limit)
  (1...limit).select{ |i| (i % 5 == 0 || i % 3 == 0)}
end

Adding the Multiples Together

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:

1
collect_multiples(1000).reduce(:+)

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:

1
2
3
4
5
def collect_multiples(limit)
  (1...limit).select{ |i| (i % 5 == 0 || i % 3 == 0)}
end

puts collect_multiples(1000).reduce(:+)

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?

| Comments

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class SwingSet

  def initialize
    puts "New swing set built!"
    @count = 0
  end

  def swing
    puts "Swinging forward. . ."
    puts "Swinging back. . . "
    @count += 1
    puts "I've swung #{@count} times."
  end
end

Now suppose we want to play on our swing set.

1
2
3
4
5
6
7
8
9
> swing_set = SwingSet.new
New swing set built!
 => #<SwingSet:0x007ffadc3172a0 @count=0> 

> swing_set.swing
Swinging forward. . .
Swinging back. . . 
I've swung 1 times.
 => nil 

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

1
2
3
4
5
6
7
8
9
10
11
12
13
> 10000000.times do
>   swing_set.swing
> end
Swinging forward. . .
Swinging back. . . 
I've swung 2 times.

. . .

Swinging forward. . .
Swinging back. . . 
I've swung 10000001 times.
 => 10000000 

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:

1
2
3
> 10000000.times do
>   SwingSet.new
> end

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

| Comments

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

| Comments

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

| Comments

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:

1
elegance_level = ["wedding", 10, "yacht", 10, "shack", 0, "wine", 8, "beer", 3, "cologne", 6]

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:

1
2
Hash[*elegance_level]
 => {"wedding"=>10, "yacht"=>10, "shack"=>0, "wine"=>8, "beer"=>3, "cologne"=>6}

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

How Coding Bootcamps Are Like Greek Life

| Comments

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.

Getting Your Letters

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

| Comments

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.

Getting Your Letters

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

| Comments

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

Headings

Paragraphs

Horizontal Rule

Text Styling

Links

Named Anchors

Images

Lists

Quotes

Tables

Headings

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

1
2
3
4
5
6
#This is heading 1!
##This is heading 2!##
###This is heading 3!
####This is heading 4!
#####This is heading 5!
######This is heading 6!######

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

1
2
3
4
5
I'm header 1
============

I'm header 2
------------

Paragraphs

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

1
2
3
4
This is the first paragraph, since there is no line separating it from the next sentences.  I'm still in paragraph one.
I'm also in paragraph 1, since there's no blank line.

I'm in paragraph 2!

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.

1
2
3
**I'm bold. :D**
__So am I!__
I'm not. :(

Italic

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

1
2
3
*I'm italic. :D*
_So am I!_
I'm not. :(

Strikethrough

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

1
2
~~I've been struck!~~
I have not.

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.

1
2
2 \+ 2
\#lol

The following characters have this property:

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

Links

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.

1
2
[I will be shown](http://www.thisistheurl.com/ "A Link")
[Google](http://www.google.com)

You can also use a reference style for links.

1
2
3
[Google][id]

[id]: http://www.google.com/ "Google"

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
<a id="headings"></a>

## Headings


<a id="paragraphs"></a>

## Paragraphs


<a id="named-anchors"></a>

##Named Anchors

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.

1
2
3
4
5
[Headings](#headings)

[Paragraphs](#paragaphs)

[Named Anchors](#named-anchors)

Headings

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.

1
![Pink](https://c1.staticflickr.com/5/4149/5018040485_28c0c3d9ef_b.jpg "Pink")

PinkSmall cell carcinoma - Yale Rosen

You can also use a reference syntax.

1
2
3
![Pink Two][id]

[id]: https://c2.staticflickr.com/2/1268/4698397342_64065cf293_b.jpg "Pink Two"

Pink TwoHypersensitivity pneumonitis Case 127 - Yale Rosen

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.

1
2
3
4
5
6
7
8
* 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
  • 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
2
3
1. This is the first item!
2. And this is the second
3. I think you get it. . .
  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:

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

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.

1
2
> My greatest pain in life is that I will never be able to see myself perform live.
><cite>Kanye West</cite>

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.

1
`like this!`

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.

1
2
    This is code.
    Am I right?
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.

1
2
3
4
5
 ``` rb
 def this_is_a_method(argument)
   result = argument * (1000)
 end 
 ```
1
2
3
def this_is_a_method(argument)
  result = argument * (1000)
end

Tables

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

1
2
3
4
5
| Id | Name | Description |
| -- | ---- | ----------- |
| 1 | Elle Woods | Lawyer in pink |
| 2 | Emmett Forrest | Handsome husband |
| 3 | Bruiser Woods | Chic chihuahua|
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:

1
2
3
4
5
| Id | Name | Description |
| :-:| :---:| :----------:|
| 1 | Elle Woods | Lawyer in pink |
| 2 | Emmett Forrest | Handsome husband |
| 3 | Bruiser Woods | Chic chihuahua|
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.

1
2
3
4
5
| Id | Name | Description |
| --:| ----:| ----------: |
| 1 | Elle Woods | Lawyer in pink |
| 2 | Emmett Forrest | Handsome husband |
| 3 | Bruiser Woods | Chic chihuahua|
Id Name Description
1 Elle Woods Lawyer in pink
2 Emmett Forrest Handsome husband
3 Bruiser Woods Chic chihuahua