-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1618 lines (1055 loc) · 92.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Elegant Development</title>
<meta name="author" content="Sara Tibbetts">
<meta name="description" content="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 …">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="http://tibsar.github.io">
<link href="/favicon.png" rel="icon">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<link href="/atom.xml" rel="alternate" title="Elegant Development" type="application/atom+xml">
<script src="/javascripts/modernizr-2.0.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="/javascripts/libs/jquery.min.js"%3E%3C/script%3E'))</script>
<script src="/javascripts/octopress.js" type="text/javascript"></script>
<!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href="//fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Fjalla+One" rel="stylesheet" type="text/css">
<!--- MathJax Configuration -->
<script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-63688470-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body class="collapse-sidebar sidebar-footer" >
<header role="banner"><hgroup>
<h1><a href="/">Elegant Development</a></h1>
<h2>For all your programming needs</h2>
</hgroup>
</header>
<nav role="navigation"><ul class="subscribe" data-subscription="rss">
<li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS" target="_blank"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25" height="25" viewbox="0 0 100 100"><path class="social" d="M 13.310204,73.332654 C 5.967347,73.332654 0,79.322448 0,86.621428 c 0,7.338776 5.967347,13.262246 13.310204,13.262246 7.370408,0 13.328572,-5.92245 13.328572,-13.262246 0,-7.29898 -5.958164,-13.288774 -13.328572,-13.288774 z M 0.01530612,33.978572 V 53.143878 C 12.493878,53.143878 24.229592,58.02347 33.068368,66.865306 41.894898,75.685714 46.767346,87.47449 46.767346,100 h 19.25 C 66.017346,63.592858 36.4,33.979592 0.01530612,33.978572 l 0,0 z M 0.03877552,0 V 19.17449 C 44.54796,19.17551 80.77551,55.437756 80.77551,100 H 100 C 100,44.87653 55.15102,0 0.03877552,0 z"></path></svg></a></li>
</ul>
<ul class="subscribe">
<li><a href="https://github.com/tibsar" rel="subscribe-github" title="@tibsar on GitHub" target="_blank"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25" height="25" viewbox="0 0 100 100"><path class="social" d="M 50,0 C 22.385714,0 0,22.385714 0,50 0,77.614286 22.385714,100 50,100 77.614286,100 100,77.614286 100,50 100,22.385714 77.614286,0 50,0 z m 29.692858,79.692858 c -3.859184,3.859182 -8.351022,6.887754 -13.35,9.00306 -1.27041,0.536736 -2.560204,1.009184 -3.867348,1.415306 v -7.493878 c 0,-3.938774 -1.35102,-6.835714 -4.053062,-8.690816 1.692858,-0.163264 3.24694,-0.390816 4.663266,-0.683672 1.416326,-0.292858 2.913266,-0.716328 4.491838,-1.27041 1.57857,-0.55408 2.994896,-1.213264 4.247958,-1.97755 1.253062,-0.765306 2.458164,-1.758164 3.613266,-2.978572 1.155102,-1.220408 2.12449,-2.604082 2.905102,-4.15 0.780612,-1.545918 1.4,-3.40204 1.855102,-5.566326 0.455102,-2.164286 0.683674,-4.54898 0.683674,-7.153062 0,-5.045918 -1.643878,-9.341836 -4.931634,-12.890816 C 77.44796,33.35 77.285714,29.10204 75.463266,24.512244 l -1.22143,-0.145918 c -0.845918,-0.09796 -2.368366,0.260204 -4.565306,1.07449 -2.196938,0.814286 -4.663264,2.14796 -7.396938,4.004082 -3.87449,-1.07449 -7.893878,-1.611224 -12.061224,-1.611224 -4.19898,0 -8.203062,0.536734 -12.012246,1.611224 -1.72449,-1.17245 -3.361224,-2.139796 -4.907142,-2.905102 C 31.753062,25.77449 30.516326,25.254082 29.587756,24.97653 28.660204,24.7 27.79796,24.528572 27,24.463266 c -0.79796,-0.0653 -1.310204,-0.08062 -1.537756,-0.04898 -0.22755,0.03164 -0.390816,0.0653 -0.487754,0.09796 -1.82347,4.62245 -1.985714,8.87143 -0.487756,12.743878 -3.287754,3.54796 -4.931632,7.844898 -4.931632,12.890816 0,2.604082 0.227552,4.988776 0.683674,7.153062 0.456122,2.164286 1.07449,4.020408 1.855102,5.566326 0.780612,1.545918 1.75,2.929592 2.905102,4.15 1.155102,1.220408 2.360204,2.213266 3.613264,2.978572 1.253062,0.766326 2.669388,1.42449 4.24796,1.97755 1.578572,0.554082 3.07551,0.976532 4.491836,1.27041 1.416328,0.292856 2.970408,0.521428 4.663266,0.683672 -2.669388,1.82347 -4.004082,4.720408 -4.004082,8.690816 v 7.639796 C 36.536734,89.818368 35.083674,89.3 33.656122,88.695918 c -4.99898,-2.115306 -9.490816,-5.143878 -13.35,-9.00306 -3.859184,-3.859184 -6.887754,-8.351022 -9.00306,-13.35 C 9.1163263,61.171428 8.0071428,55.67347 8.0071428,50 c 0,-5.67347 1.1091835,-11.171428 3.2969392,-16.342858 2.115306,-4.998978 5.143878,-9.490816 9.00306,-13.35 3.859184,-3.859182 8.351022,-6.887754 13.35,-9.00306 C 38.828572,9.1163266 44.32653,8.0071428 50,8.0071428 c 5.67347,0 11.171428,1.1091838 16.342858,3.2969392 5,2.115306 9.490816,5.143878 13.35,9.00306 3.859182,3.859184 6.887754,8.351022 9.00306,13.35 2.186736,5.17245 3.295918,10.67041 3.295918,16.342858 0,5.672448 -1.109182,11.171428 -3.296938,16.342858 -2.115306,4.998978 -5.143878,9.490816 -9.00204,13.35 l 0,0 z"></path></svg></a></li>
</ul>
<ul class="subscribe">
<li><a href="https://twitter.com/saratibbetts" rel="subscribe-twitter" title="@saratibbetts on Twitter" target="_blank"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25" height="25" viewBox="0 0 512 512"><path class="social" d="M0.001,334.932c33.327,30.816,118.891,59.981,188.517-8.271c-12.52,1.955-22.972-0.416-30.913-8.269
c-7.531-7.465-7.945-15.182-3.914-22.202c3.275-5.725,10.184-9.741,16.977-13.934c-12.323,2.285-22.829,1.095-32.218-3.706
c-12.604-6.444-24.863-13.228-28.3-27.207c7.71-8.112,16.28-15.359,34.831-12.627c-17.45-5.83-33.087-13.429-44.41-24.815
c-11.028-11.091-12.163-18.302-13.932-26.996c9.632-3.567,19.688-5.421,30.478-4.353c-24.397-12.476-34.757-29.63-40.487-48.325
c-1.731-5.652-2.044-11.03-1.31-16.545c98.826,37.305,145.11,64.109,170.662,89.251c11.496-30.589,38.3-99.868,78.371-123.646
c0.191,3.77-1.309,7.837-4.357,12.189c11.863-6.609,21.125-17.188,37.445-16.98c-1.879,7.723-7.279,13.904-17.85,17.854
c10.662-4.084,21.463-7.545,32.65-9.578c10.375-1.881,10.229,6.304,4.355,10.444c-11.916,8.412-24.578,9.456-37.006,13.498
c38.105,0.949,69.266,18.994,93.604,58.343c8.088,13.074,13.52,26.149,14.807,40.487c16.254,4.563,32.426,5.494,48.76,2.61
c4.475-0.796,8.645-1.63,12.627-3.482c-6.354,9.529-13.686,17.356-23.947,20.899c-9.811,3.387-19.637,6.688-30.473,6.968
c17.641,6.675,37.082,7.045,57.033,5.659c-24.402,23.486-43.08,22.922-61.824,22.642c-8.221,34.703-25.025,69.315-60.52,101.005
c-46.559,41.569-96.678,61.397-148.457,65.742c-48.552,4.07-95.488,3.512-146.726-20.464
C56.486,393.349,24.648,368.884,0.001,334.932L0.001,334.932z"/></svg></a></li>
</ul>
<form action="https://www.google.com/search" method="get">
<fieldset role="search">
<input type="hidden" name="sitesearch" value="tibsar.github.io" />
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
</fieldset>
</form>
<ul class="main-navigation">
<li><a href="/">Blog</a></li>
<li><a href="/blog/archives">Archives</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
<div id="main">
<div id="content">
<div class="blog-index">
<article>
<header>
<h1 class="entry-title"><a href="/blog/opening-sublime-from-powershell/">Opening Sublime From Powershell</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-11-06T14:23:26-05:00'><span class='date'><span class='date-month'>Nov</span> <span class='date-day'>6</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>2:23 pm</span></time>
| <a href="/blog/opening-sublime-from-powershell/#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>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!</p>
<p>So first, open Windows Command Prompt. Make sure you choose "Run as Administrator" so that you can make the modifications necessary.</p>
<p>Next, paste the following code into the prompt:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>REM Begin Copy
</span><span class='line'>powershell
</span><span class='line'>Set-Content <span class="s2">"C:\Program Files\Sublime Text 2\subl.bat"</span> <span class="s2">"@echo off"</span>
</span><span class='line'>Add-Content <span class="s2">"C:\Program Files\Sublime Text 2\subl.bat"</span> <span class="s2">"start sublime_text.exe %1"</span>
</span><span class='line'><span class="k">if</span> <span class="o">(</span>!<span class="o">(</span><span class="nv">$Env</span>:Path.Contains<span class="o">(</span><span class="s2">"Sublime"</span><span class="o">)))</span> <span class="o">{[</span>System.Environment<span class="o">]</span>::SetEnvironmentVariable<span class="o">(</span><span class="s2">"PATH"</span>, <span class="nv">$Env</span>:Path + <span class="s2">";C:\Program Files\Sublime Text 2"</span>, <span class="s2">"Machine"</span><span class="o">)}</span>
</span><span class='line'><span class="nb">exit</span>
</span><span class='line'>REM End Copy
</span></code></pre></td></tr></table></div></figure>
<p>Close the Command Prompt window and restart PowerShell. Check it out! Now you can use the command <code>subl</code> to open Sublime or basic file commands such as <code>subl .</code> to open the folder you are currently in in Sublime.</p>
<p>Happy Coding!</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/project-euler-number-2-ruby/">Project Euler #2 - Ruby</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-10-28T15:31:00-04:00'><span class='date'><span class='date-month'>Oct</span> <span class='date-day'>28</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>3:31 pm</span></time>
| <a href="/blog/project-euler-number-2-ruby/#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>Time for the second Project Euler post!</p>
<h2>Project Euler #2</h2>
<blockquote><p>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:</p>
<p>1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...</p>
<p>By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. <cite>Project Euler #2</cite></p></blockquote>
<p>So it looks like we need to find all of the even numbers in the Fibonacci sequence, and then add them all together.</p>
<h3>Calculating the Fibonacci Sequence</h3>
<p>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.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">num</span> <span class="o">=</span> <span class="mi">2</span>
</span><span class='line'><span class="n">previous_num</span> <span class="o">=</span> <span class="mi">1</span>
</span><span class='line'><span class="n">new_num</span> <span class="o">=</span> <span class="n">num</span> <span class="o">+</span> <span class="n">previous_num</span>
</span></code></pre></td></tr></table></div></figure>
<p>The code above will set <code>new_num</code> to <code>2 + 1</code> which is <code>3</code>, 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 <code>until</code> loop.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">num</span> <span class="o">=</span> <span class="mi">2</span>
</span><span class='line'><span class="n">previous_num</span> <span class="o">=</span> <span class="mi">1</span>
</span><span class='line'><span class="k">until</span> <span class="n">num</span> <span class="o">>=</span> <span class="n">limit</span>
</span><span class='line'> <span class="n">new_num</span> <span class="o">=</span> <span class="n">num</span> <span class="o">+</span> <span class="n">previous_num</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>Now this code has a few problems. First, <code>limit</code> is never defined. We can fix that by wrapping our code in a function that has the limit as a parameter.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">even_fibonacci_sum</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span>
</span><span class='line'> <span class="n">num</span> <span class="o">=</span> <span class="mi">2</span>
</span><span class='line'> <span class="n">previous_num</span> <span class="o">=</span> <span class="mi">1</span>
</span><span class='line'> <span class="k">until</span> <span class="n">num</span> <span class="o">>=</span> <span class="n">limit</span>
</span><span class='line'> <span class="n">new_num</span> <span class="o">=</span> <span class="n">num</span> <span class="o">+</span> <span class="n">previous_num</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>Our code still has a major issue. The loop will continue forever since we are never changing the value of <code>num</code>. Since we also don't change the value of <code>previous_num</code>, <code>new_num</code> will always be three, so this code doesn't get us any further in the Fibonacci sequence. We need to update the <code>previous_num</code> as well as the current <code>num</code> in order to keep going in the sequence.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">even_fibonacci_sum</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span>
</span><span class='line'> <span class="n">num</span> <span class="o">=</span> <span class="mi">2</span>
</span><span class='line'> <span class="n">previous_num</span> <span class="o">=</span> <span class="mi">1</span>
</span><span class='line'> <span class="k">until</span> <span class="n">num</span> <span class="o">>=</span> <span class="n">limit</span>
</span><span class='line'> <span class="n">new_num</span> <span class="o">=</span> <span class="n">num</span> <span class="o">+</span> <span class="n">previous_num</span>
</span><span class='line'> <span class="n">previous_num</span> <span class="o">=</span> <span class="n">num</span>
</span><span class='line'> <span class="n">num</span> <span class="o">=</span> <span class="n">new_num</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>Now we're finding all numbers in the Fibonacci sequence up to the limit!</p>
<h3>Calculating the Sum</h3>
<p>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.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">even_fibonacci_sum</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span>
</span><span class='line'> <span class="n">num</span> <span class="o">=</span> <span class="mi">2</span>
</span><span class='line'> <span class="n">previous_num</span> <span class="o">=</span> <span class="mi">1</span>
</span><span class='line'> <span class="n">sum</span> <span class="o">=</span> <span class="mi">0</span>
</span><span class='line'> <span class="k">until</span> <span class="n">num</span> <span class="o">>=</span> <span class="n">limit</span>
</span><span class='line'> <span class="k">if</span> <span class="n">num</span><span class="o">.</span><span class="n">even?</span>
</span><span class='line'> <span class="n">sum</span> <span class="o">+=</span> <span class="n">num</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'> <span class="n">new_num</span> <span class="o">=</span> <span class="n">num</span> <span class="o">+</span> <span class="n">previous_num</span>
</span><span class='line'> <span class="n">previous_num</span> <span class="o">=</span> <span class="n">num</span>
</span><span class='line'> <span class="n">num</span> <span class="o">=</span> <span class="n">new_num</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>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.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">even_fibonacci_sum</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span>
</span><span class='line'> <span class="n">num</span> <span class="o">=</span> <span class="mi">2</span>
</span><span class='line'> <span class="n">previous_num</span> <span class="o">=</span> <span class="mi">1</span>
</span><span class='line'> <span class="n">sum</span> <span class="o">=</span> <span class="mi">0</span>
</span><span class='line'> <span class="k">until</span> <span class="n">num</span> <span class="o">>=</span> <span class="n">limit</span>
</span><span class='line'> <span class="k">if</span> <span class="n">num</span><span class="o">.</span><span class="n">even?</span>
</span><span class='line'> <span class="n">sum</span> <span class="o">+=</span> <span class="n">num</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'> <span class="n">new_num</span> <span class="o">=</span> <span class="n">num</span> <span class="o">+</span> <span class="n">previous_num</span>
</span><span class='line'> <span class="n">previous_num</span> <span class="o">=</span> <span class="n">num</span>
</span><span class='line'> <span class="n">num</span> <span class="o">=</span> <span class="n">new_num</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'> <span class="n">sum</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<h3>Arriving at a Solution</h3>
<p>To get the solution, run your code! In the terminal, running <code>ruby file_name_here.rb</code> 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 <a href="https://projecteuler.net/problem=2" target="_blank">here</a>.</p>
<p>If you feel that you have a better solution, post a gist to it in the comments!</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/project-euler-number-1-ruby/">Project Euler #1 - Ruby</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-08-19T07:11:32-04:00'><span class='date'><span class='date-month'>Aug</span> <span class='date-day'>19</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>7:11 am</span></time>
| <a href="/blog/project-euler-number-1-ruby/#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>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.</p>
<h2>Project Euler #1</h2>
<blockquote><p>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.<br/>
Find the sum of all the multiples of 3 or 5 below 1000. <cite>Project Euler #1</cite></p></blockquote>
<p>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.</p>
<h3>Collecting the Multiples</h3>
<p>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.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="p">(</span><span class="n">number_in_question</span> <span class="o">%</span> <span class="mi">3</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="n">number_in_question</span> <span class="o">%</span> <span class="mi">5</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<p>This code will return <code>true</code> if the <code>number_in_question</code> is a multiple of 3 or 5. However, we stil have no way of finding the <code>number_in_question</code>.</p>
<p>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:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">limit</span> <span class="o">=</span> <span class="mi">1000</span>
</span><span class='line'><span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="o">.</span><span class="n">limit</span><span class="p">)</span><span class="o">.</span><span class="n">to_a</span>
</span></code></pre></td></tr></table></div></figure>
<p>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.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="o">.</span><span class="n">limit</span><span class="p">)</span><span class="o">.</span><span class="n">select</span><span class="p">{</span> <span class="o">|</span><span class="n">i</span><span class="o">|</span> <span class="p">(</span><span class="n">i</span> <span class="o">%</span> <span class="mi">5</span> <span class="o">==</span> <span class="mi">0</span> <span class="o">||</span> <span class="n">i</span> <span class="o">%</span> <span class="mi">3</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)}</span>
</span></code></pre></td></tr></table></div></figure>
<p>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.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">collect_multiples</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span>
</span><span class='line'> <span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="o">.</span><span class="n">limit</span><span class="p">)</span><span class="o">.</span><span class="n">select</span><span class="p">{</span> <span class="o">|</span><span class="n">i</span><span class="o">|</span> <span class="p">(</span><span class="n">i</span> <span class="o">%</span> <span class="mi">5</span> <span class="o">==</span> <span class="mi">0</span> <span class="o">||</span> <span class="n">i</span> <span class="o">%</span> <span class="mi">3</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)}</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<h3>Adding the Multiples Together</h3>
<p>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 <code>reduce</code> 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:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">collect_multiples</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="ss">:+</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<h3>Arriving at a Solution</h3>
<p>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 <a href="https://projecteuler.net/problem=1" target="_blank">here</a>. Here's some proof that this code works:</p>
<p><img class="center" src="http://i.imgur.com/SEiCPvl.png">
And if you want to see all the code in one place:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">collect_multiples</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span>
</span><span class='line'> <span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="o">.</span><span class="n">limit</span><span class="p">)</span><span class="o">.</span><span class="n">select</span><span class="p">{</span> <span class="o">|</span><span class="n">i</span><span class="o">|</span> <span class="p">(</span><span class="n">i</span> <span class="o">%</span> <span class="mi">5</span> <span class="o">==</span> <span class="mi">0</span> <span class="o">||</span> <span class="n">i</span> <span class="o">%</span> <span class="mi">3</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)}</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="nb">puts</span> <span class="n">collect_multiples</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="ss">:+</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<p>In the terminal, running <code>ruby file_name_here.rb</code> with whatever you named the file that you are coding in, will display the soluton to the terminal screen.</p>
<p>If you feel that you have a better solution, post a gist to it in the comments!</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/what-is-software/">What Is Software?</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-08-04T12:38:37-04:00'><span class='date'><span class='date-month'>Aug</span> <span class='date-day'>4</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>12:38 pm</span></time>
| <a href="/blog/what-is-software/#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>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.</p>
<h1>1. Software is not manufactured</h1>
<p>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.</p>
<h1>2. Software doesn't wear out</h1>
<p>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.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">class</span> <span class="nc">SwingSet</span>
</span><span class='line'>
</span><span class='line'> <span class="k">def</span> <span class="nf">initialize</span>
</span><span class='line'> <span class="nb">puts</span> <span class="s2">"New swing set built!"</span>
</span><span class='line'> <span class="vi">@count</span> <span class="o">=</span> <span class="mi">0</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'>
</span><span class='line'> <span class="k">def</span> <span class="nf">swing</span>
</span><span class='line'> <span class="nb">puts</span> <span class="s2">"Swinging forward. . ."</span>
</span><span class='line'> <span class="nb">puts</span> <span class="s2">"Swinging back. . . "</span>
</span><span class='line'> <span class="vi">@count</span> <span class="o">+=</span> <span class="mi">1</span>
</span><span class='line'> <span class="nb">puts</span> <span class="s2">"I've swung </span><span class="si">#{</span><span class="vi">@count</span><span class="si">}</span><span class="s2"> times."</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<p>Now suppose we want to play on our swing set.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='irb'><span class='line'><span class="go">> swing_set = SwingSet.new</span>
</span><span class='line'><span class="go">New swing set built!</span>
</span><span class='line'><span class="go"> => #<SwingSet:0x007ffadc3172a0 @count=0> </span>
</span><span class='line'>
</span><span class='line'><span class="go">> swing_set.swing</span>
</span><span class='line'><span class="go">Swinging forward. . .</span>
</span><span class='line'><span class="go">Swinging back. . . </span>
</span><span class='line'><span class="go">I've swung 1 times.</span>
</span><span class='line'><span class="go"> => nil </span>
</span></code></pre></td></tr></table></div></figure>
<p>Now we're really enjoying our brand new swing set, so we swing a lot. . .</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class='irb'><span class='line'><span class="go">> 10000000.times do</span>
</span><span class='line'><span class="go">> swing_set.swing</span>
</span><span class='line'><span class="go">> end</span>
</span><span class='line'><span class="go">Swinging forward. . .</span>
</span><span class='line'><span class="go">Swinging back. . . </span>
</span><span class='line'><span class="go">I've swung 2 times.</span>
</span><span class='line'>
</span><span class='line'><span class="go">. . .</span>
</span><span class='line'>
</span><span class='line'><span class="go">Swinging forward. . .</span>
</span><span class='line'><span class="go">Swinging back. . . </span>
</span><span class='line'><span class="go">I've swung 10000001 times.</span>
</span><span class='line'><span class="go"> => 10000000 </span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<p>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.</p>
<h1>3. Software can be undone</h1>
<p>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.</p>
<p>Let's change the situation a bit.</p>
<p>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.</p>
<p>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.</p>
<h1>4. Software is endless</h1>
<p>In the swing set example mentioned earlier, I could have made the loop something like this:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='irb'><span class='line'><span class="go">> 10000000.times do</span>
</span><span class='line'><span class="go">> SwingSet.new</span>
</span><span class='line'><span class="go">> end</span>
</span></code></pre></td></tr></table></div></figure>
<p>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.</p>
<h2>Conclusion</h2>
<p>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.</p>
<p><em>This post uses many concepts found in <a href="http://www.mhhe.com/engineering/pressman/" target="_blank">Software Engineering: A Practitioner's Approach</a> by Roger S. Pressman</em></p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/coding-the-universe/">Coding the Universe</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-07-29T12:36:33-04:00'><span class='date'><span class='date-month'>Jul</span> <span class='date-day'>29</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>12:36 pm</span></time>
| <a href="/blog/coding-the-universe/#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>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.</p>
<p>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.</p>
<p><img class="left" src="http://s28.postimg.org/5odbge77x/VIIRS_4_Jan2012_708x432.jpg" width="370"> 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 <a href="http://flatironschool.com/" target="_blank">The Flatiron School</a>, 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 <a href="https://en.wikipedia.org/wiki/Ajax_(programming)" target="_blank">AJAX</a> 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.</p>
<p><img class="right" src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/Image_Tangent-plane.svg/2000px-Image_Tangent-plane.svg.png" width="200"> 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? <a href="http://www.mers.byu.edu/docs/reports/MERS9904.pdf" target="_blank">"Projecting an Arbitrary Latitude and Longitude onto a Tangent Plane"</a> 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 <a href="https://en.wikipedia.org/wiki/Galactic_coordinate_system" target="_blank">Galactic coordinate system</a>, 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?</p>
<p>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: <code>Ax + By + Cz</code>. 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?</p>
<p>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 <a href="http://lumensee.herokuapp.com/" target="_blank">LUMENsee</a>. Check it out!</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/low-self-esteem-try-coding/">Low Self-Esteem? Try Coding</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-07-26T20:13:09-04:00'><span class='date'><span class='date-month'>Jul</span> <span class='date-day'>26</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>8:13 pm</span></time>
| <a href="/blog/low-self-esteem-try-coding/#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>Learning to code leads to much more than just a practical life skill. Throughout my journey at the <a href="http://flatironschool.com/" target="_blank">Flatiron School</a> 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.</p>
<p>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:</p>
<ul>
<li><a href="http://codecademy.com/" target="_blank">Codecademy</a></li>
<li><a href="http://codeschool.com/" target="_blank">Code School</a></li>
<li><a href="http://teamtreehouse.com/" target="_blank">Treehouse</a></li>
</ul>
<p>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:</p>
<ul>
<li><a href="https://pine.fm/LearnToProgram/" target="_blank">Learn to Program</a></li>
<li><a href="http://learnrubythehardway.org/book/" target="_blank">Learn Ruby the Hard Way</a></li>
<li><a href="http://ruby-doc.com/docs/ProgrammingRuby/" target="_blank">Programming Ruby</a></li>
<li><a href="http://www.techotopia.com/index.php/Ruby_Essentials" target="_blank">Ruby Essentials</a></li>
<li><a href="http://ruby.bastardsbook.com/" target="_blank">Bastards Book of Ruby</a></li>
<li><a href="http://mislav.uniqpath.com/poignant-guide/" target="_blank">Why's Poignant Guide to Ruby</a></li>
</ul>
<p>I listed Ruby books since that's what I'm learning, but you can find an extensive list <a href="https://github.com/vhf/free-programming-books/blob/master/free-programming-books.md#ruby" target="_blank">here</a>.</p>
<p>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:</p>
<ul>
<li><a href="https://www.facebook.com/groups/hackathonhackers/" target="_blank">Hackathon Hackers</a></li>
<li><a href="https://www.reddit.com/r/programming/" target="_blank">r/programming</a></li>
<li><a href="https://dzone.com/" target="_blank">DZone</a></li>
</ul>
<p>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.</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/how-to-turn-an-array-into-a-hash-using-ruby/">How to Turn an Array Into a Hash Using Ruby</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-07-17T15:35:49-04:00'><span class='date'><span class='date-month'>Jul</span> <span class='date-day'>17</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>3:35 pm</span></time>
| <a href="/blog/how-to-turn-an-array-into-a-hash-using-ruby/#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>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!</p>
<p>Suppose you have the following array:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">elegance_level</span> <span class="o">=</span> <span class="o">[</span><span class="s2">"wedding"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"yacht"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"shack"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">"wine"</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="s2">"beer"</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s2">"cologne"</span><span class="p">,</span> <span class="mi">6</span><span class="o">]</span>
</span></code></pre></td></tr></table></div></figure>
<p>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:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="no">Hash</span><span class="o">[*</span><span class="n">elegance_level</span><span class="o">]</span>
</span><span class='line'> <span class="o">=></span> <span class="p">{</span><span class="s2">"wedding"</span><span class="o">=></span><span class="mi">10</span><span class="p">,</span> <span class="s2">"yacht"</span><span class="o">=></span><span class="mi">10</span><span class="p">,</span> <span class="s2">"shack"</span><span class="o">=></span><span class="mi">0</span><span class="p">,</span> <span class="s2">"wine"</span><span class="o">=></span><span class="mi">8</span><span class="p">,</span> <span class="s2">"beer"</span><span class="o">=></span><span class="mi">3</span><span class="p">,</span> <span class="s2">"cologne"</span><span class="o">=></span><span class="mi">6</span><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>That's it! Hope you enjoyed this short but sweet refactor tip!</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/how-coding-bootcamps-are-like-greek-life/">How Coding Bootcamps Are Like Greek Life</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-07-13T17:15:36-04:00'><span class='date'><span class='date-month'>Jul</span> <span class='date-day'>13</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>5:15 pm</span></time>
| <a href="/blog/how-coding-bootcamps-are-like-greek-life/#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>Coding bootcamps are popping up <a href="http://www.skilledup.com/articles/the-ultimate-guide-to-coding-bootcamps-the-exhaustive-list" target=_blank>across the world</a>. As a student at a NYC bootcamp, the <a href="http://flatironschool.com/" target=_blank>Flatiron School</a>, as well as a sorority sister of <a href="https://www.dphie.org/Home" target=_blank>Delta Phi Epsilon</a>, I couldn't help but notice some similarities between the two.</p>
<h3>New Member Class</h3>
<p>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.</p>
<p><img class="center" src="https://scontent-lga1-1.xx.fbcdn.net/hphotos-xpf1/v/t1.0-9/1381481_732106783472536_1494142350_n.jpg?oh=130e32e1004e0c888cc99a607e733584&oe=5625FD31" width="400" height="215"></p>
<h3>Mentorship</h3>
<p>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.
<img class="center" src="https://scontent-lga1-1.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/1425686_10151765451339499_2088666953_n.jpg?oh=5b79ce8958dca8bbaab83dfc796c4a35&oe=56126F85" width="400" height="215"></p>
<h3>Getting Your Letters</h3>
<p>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.</p>
<p><img class="center" src="http://themonogramexpress.com/images/thumbnails/rts233.jpg" width="400" height="215"></p>
<h3>Crossover</h3>
<p>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.</p>
<p><img class="center" src="https://www.involvement.mtu.edu/images/native/0/noshadow/General/1c8e7ede684e43839507de555629904c.jpg" width="500"></p>
<h3>Conclusion</h3>
<p>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.</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/how-coding-bootcamps-are-like-greek-life/">How Coding Bootcamps Are Like Greek Life</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-07-10T08:58:25-04:00'><span class='date'><span class='date-month'>Jul</span> <span class='date-day'>10</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>8:58 am</span></time>
| <a href="/blog/how-coding-bootcamps-are-like-greek-life/#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>Coding bootcamps are popping up <a href="http://www.skilledup.com/articles/the-ultimate-guide-to-coding-bootcamps-the-exhaustive-list" target=_blank>across the world</a>. As a student at a NYC bootcamp, the <a href="http://flatironschool.com/" target=_blank>Flatiron School</a>, as well as a sorority sister of <a href="https://www.dphie.org/Home" target=_blank>Delta Phi Epsilon</a>, I couldn't help but notice some similarities between the two.</p>
<h3>New Member Class</h3>
<p>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.</p>
<p><img class="center" src="https://scontent-lga1-1.xx.fbcdn.net/hphotos-xpf1/v/t1.0-9/1381481_732106783472536_1494142350_n.jpg?oh=130e32e1004e0c888cc99a607e733584&oe=5625FD31" width="400" height="215"></p>
<h3>Mentorship</h3>
<p>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.
<img class="center" src="https://scontent-lga1-1.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/1425686_10151765451339499_2088666953_n.jpg?oh=5b79ce8958dca8bbaab83dfc796c4a35&oe=56126F85" width="400" height="215"></p>
<h3>Getting Your Letters</h3>
<p>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.</p>
<p><img class="center" src="http://themonogramexpress.com/images/thumbnails/rts233.jpg" width="400" height="215"></p>
<h3>Crossover</h3>
<p>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.</p>
<p><img class="center" src="https://www.involvement.mtu.edu/images/native/0/noshadow/General/1c8e7ede684e43839507de555629904c.jpg" width="500"></p>
<h3>Conclusion</h3>
<p>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.</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/markdown-cheat-sheet/">Markdown Cheat Sheet</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-06-29T16:16:42-04:00'><span class='date'><span class='date-month'>Jun</span> <span class='date-day'>29</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>4:16 pm</span></time>
| <a href="/blog/markdown-cheat-sheet/#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>Markdown is used <em>a lot</em>, so I figured a cheat sheet could be useful, so here goes:</p>
<h3><a href="#headings">Headings</a></h3>
<h3><a href="#paragraphs">Paragraphs</a></h3>
<h3><a href="#horizontal-rule">Horizontal Rule</a></h3>
<h3><a href="#text-styling">Text Styling</a></h3>
<h3><a href="#links">Links</a></h3>
<h3><a href="#named-anchors">Named Anchors</a></h3>
<h3><a href="#images">Images</a></h3>
<h3><a href="#lists">Lists</a></h3>
<h3><a href="#quotes">Quotes</a></h3>
<h3><a href="#tables">Tables</a></h3>
<p><a id="headings"></a></p>
<h2>Headings</h2>
<p>Headings in Markdown are preceded by the octothorpe (<code>#</code>). You can also add trailing octothorpes, but this is optional.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1">#This is heading 1!</span>
</span><span class='line'><span class="c1">##This is heading 2!##</span>
</span><span class='line'><span class="c1">###This is heading 3!</span>
</span><span class='line'><span class="c1">####This is heading 4!</span>
</span><span class='line'><span class="c1">#####This is heading 5!</span>
</span><span class='line'><span class="c1">######This is heading 6!######</span>
</span></code></pre></td></tr></table></div></figure>
<p>Another way to create heading 1 and heading 2 are with equal signs (<code>=</code>) or dashes (<code>-</code>) under the text you want in the header.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='mxml'><span class='line'>I'm header 1
</span><span class='line'>============
</span><span class='line'>
</span><span class='line'>I'm header 2
</span><span class='line'>------------
</span></code></pre></td></tr></table></div></figure>
<p><a id="paragraphs"></a></p>
<h2>Paragraphs</h2>
<p>Paragraphs are determined based off a new line or at least two spaces at the end of a line.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='mxml'><span class='line'>This is the first paragraph, since there is no line separating it from the next sentences. I'm still in paragraph one.
</span><span class='line'>I'm also in paragraph 1, since there's no blank line.