-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfeed.xml
671 lines (514 loc) · 53 KB
/
feed.xml
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
<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title></title>
<link>http://kodermine.com</link>
<atom:link href="http://kodermine.com/feed.xml" rel="self" type="application/rss+xml" />
<description></description>
<language>en-us</language>
<pubDate>Mon, 23 Jun 2014 17:58:18 +0000</pubDate>
<lastBuildDate>Mon, 23 Jun 2014 17:58:18 +0000</lastBuildDate>
<item>
<title>Cool stuff with Git</title>
<link>http://kodermine.com/git/2014/05/19/cool_stuff_with_git/</link>
<pubDate>Mon, 19 May 2014 00:00:00 +0000</pubDate>
<author></author>
<guid>http://kodermine.com/git/2014/05/19/cool_stuff_with_git</guid>
<description><script async class="speakerdeck-embed" data-id="02e036909a5e01312ce96e104d561c21" data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js"></script>
</description>
</item>
<item>
<title>Ruby basics and more</title>
<link>http://kodermine.com/ruby/2014/05/18/ruby_basics_and_more/</link>
<pubDate>Sun, 18 May 2014 00:00:00 +0000</pubDate>
<author></author>
<guid>http://kodermine.com/ruby/2014/05/18/ruby_basics_and_more</guid>
<description><script async class="speakerdeck-embed" data-id="32da8170891e0131712b6e502952b505" data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js"></script>
</description>
</item>
<item>
<title>Git Basics</title>
<link>http://kodermine.com/git/2014/05/18/git_basics/</link>
<pubDate>Sun, 18 May 2014 00:00:00 +0000</pubDate>
<author></author>
<guid>http://kodermine.com/git/2014/05/18/git_basics</guid>
<description><h1>Koding Ruby Git Basics</h1>
<p>Hello Everyone, this is the shownotes that comes with the Git Basics hangout that we just did</p>
<h2>What we learned</h2>
<ul>
<li>Git explained, timelines, commits, staging, timecapsules</li>
<li>VCS Concept</li>
<li>Adding configurations</li>
<li>Generating SSH keys</li>
<li><p>Basic Commands</p>
<ul>
<li><code>git init</code></li>
<li><code>git status</code></li>
<li><code>git add</code></li>
<li><code>git commit</code></li>
<li><code>git remote</code></li>
<li><code>git push</code></li>
<li><code>git stash</code></li>
<li><code>git diff</code></li>
<li><code>HEAD</code></li>
<li><code>git reset</code></li>
<li><code>git checkout</code></li>
<li><code>git branch</code></li>
</ul></li>
<li><p>Git Tips</p>
<ul>
<li>using wildcards</li>
<li>Separate commits</li>
<li>branching</li>
<li>merge conflicts &quot;OH NO T_T&quot;</li>
</ul></li>
</ul>
<h2>Version Control Systems</h2>
<p>Version control(VCS) is a system that records changes to a file or a set of files in a repository. In the programming world a version control system is very useful. Its very convenient to have a tool that keeps track of the changes we&#39;ve made overtime in the lifecycle of our project, if ever we made a mistake in our code we could easily reset a file back to a version where it was working.</p>
<p>On top of all that a VCS is not just limited for programmers, writers, artists and basically anyone who uses a computer that makes changes to files can use this.</p>
<p>Having a version controll is also great for work that requires collaboration since everyone&#39;s changes are tracked and if we are to merge them all together we can do it easily using git.</p>
<h2>Git - a distributed Version Control System</h2>
<blockquote>
<p>Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. [^1]</p>
</blockquote>
<p>Git is actually one of many version control systems out there, and what makes git different from other version control systems is that it&#39;s &quot;distributed&quot;</p>
<p><strong>So what does distributed version control mean?</strong></p>
<p>Version control systems have different types:</p>
<p><strong>Local Version Control System</strong></p>
<blockquote>
<p>Many people’s version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they’re clever). This approach is very common because it is so simple, but it is also incredibly error prone. It is easy to forget which directory you’re in and accidentally write to the wrong file or copy over files you don’t mean to.</p>
<p>To deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control.</p>
<p>defenition from <a href="http://git-scm.com/book/en/Getting-Started-About-Version-Control">git-cm</a></p>
</blockquote>
<p><img src="http://git-scm.com/figures/18333fig0101-tn.png" alt="image"></p>
<blockquote>
<p>Image from git-scm.com</p>
</blockquote>
<p><strong>Centralized Version Control System</strong></p>
<blockquote>
<p>The next major issue that people encounter is that they need to collaborate with developers on other systems. To deal with this problem, Centralized Version Control Systems (CVCSs) were developed. These systems, such as CVS, Subversion, and Perforce, have a single server that contains all the versioned files, and a number of clients that check out files from that central place. For many years, this has been the standard for version control.
defenition from <a href="http://git-scm.com/book/en/Getting-Started-About-Version-Control">git-cm</a></p>
</blockquote>
<p><img src="http://git-scm.com/figures/18333fig0102-tn.png" alt="image"></p>
<blockquote>
<p>Image from git-scm.com</p>
</blockquote>
<p><strong>Distributed Version Control System</strong></p>
<blockquote>
<p>This is where Distributed Version Control Systems (DVCSs) step in. In a DVCS (such as Git, Mercurial, Bazaar or Darcs), clients don’t just check out the latest snapshot of the files: they fully mirror the repository. Thus if any server dies, and these systems were collaborating via it, any of the client repositories can be copied back up to
the server to restore it. Every checkout is really a full backup of all the data.</p>
<p>defenition from <a href="http://git-scm.com/book/en/Getting-Started-About-Version-Control">git-cm</a></p>
</blockquote>
<p><img src="http://git-scm.com/figures/18333fig0103-tn.png" alt="image"></p>
<blockquote>
<p>Image from git-scm.com</p>
</blockquote>
<h2>Configuring our git</h2>
<p>We want git to recognize who we are, so let&#39;s configure it to do so by running the following commands in our terminal.</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">git config --global user.name &quot;Your User Name&quot; # this will set the username
git config --global user.email [email protected] # this will set your email address
</code></pre></div>
<p>git config --global actually just stores these configuration in a separate file in your home directory. You can view it by typing:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">cat ~/.gitconfig
</code></pre></div>
<p>We can actually do looots of things with git config, but for now, let&#39;s just use it to add our email and username.</p>
<p><strong>CONFIG BONUS</strong>
Let&#39;s add pretty colors to our git &lt;3</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">git config --global color.ui true
</code></pre></div>
<p>This will make our git interface have color syntax (e.g. red for lines removed and green for lines added)</p>
<h2>Setting up SSH KEYS</h2>
<p>In our hangouts I simply demonstrated a tutorial provided by <a href="https://help.github.com/articles/generating-ssh-keys">Github</a>. Please follow that link to learn how to generate SSH keys for your machine and add them to github. Alternatively you can download the client for your machine and this will automatically add ssh keys and add them to github.</p>
<h2>Git timelines</h2>
<p>Git creates a timeline for us that will contain time capsules or snapshots of our folder. The green marks below represent the snapshots. We will discuss what they are below</p>
<p><img src="https://www.evernote.com/shard/s217/sh/4165756c-a8e9-4f5a-9c03-2496ac5c0828/575891ce6d6a3415406823969b9b21bb/res/c016613c-5a7f-4810-9bcd-d99db9bef8c4/skitch.jpg" alt="image"></p>
<h2>Basic Git Commands</h2>
<h3><code>git init</code></h3>
<p><code>git init</code> initializes a git repository in whatever folder we&#39;re located in. It enables the folder we&#39;re in to be version controlled.</p>
<p>Without initializing git, we cannot run any git commands in our folder. Let&#39;s try it out.</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">git status #running git command in a folder is not git enabled
output: fatal: Not a git repository (or any of the parent directories): .git
git init # to initialize git
output: Initialized empty Git repository in /Users/shopify/test/.git/
</code></pre></div>
<h3><code>git status</code></h3>
<p><code>git status</code> displays if there&#39;s any differences between the current files we have and the last commit/snapshot that was in our repository. It also displays if there&#39;s anything currently staged in our repository.</p>
<h3><code>git add</code></h3>
<p><code>git add</code> adds files to our <em>stage</em>. Git add accepts a filename as an argument, or a wild card. We can do <code>git add .</code> to add all the files. We can also pass it the name of the extension + a wild card so that it will add all the files with that extension <code>git add ‘*.txt’</code> will add all the files that have <code>txt</code> as an extension.</p>
<h4>What is staged?</h4>
<p>So let&#39;s imagine an actual stage, and snapshots as actual pictures. When we add new files to our stage they are not necessarily in a snapshot yet, just think that they&#39;re getting ready for a photoshoot and they&#39;re posing right now. When we take the picture it&#39;s the actual snapshot and the files that are in the stage are the only ones included in it.</p>
<p><img src="https://www.evernote.com/shard/s217/sh/a540e82c-f5db-4c0a-a515-00ae8bf11904/9483f62530491fed6fe416757a8039e1/res/10d307fb-7053-42d0-b763-e782bf45eaf0/skitch.jpg" alt="image"></p>
<h3><code>git commit</code></h3>
<p><code>git commit</code> records the changes or takes the &quot;snapshot&quot; of the files on the stage. <code>git commit</code> accepts the option <code>-m</code> and a message parameter that will serve as the title of the snapshot.</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">git commit -m &quot;fixed the typo &#39;asdf&#39; to &#39;qwerty&#39;&quot;
</code></pre></div>
<p><strong>Tip:</strong> It&#39;s a good practice to pass short but detailed messages of what we did for the commit.</p>
<h3><code>git remote</code></h3>
<p>We used <code>git remote</code> to connect with our github repo. Git remote allows us to add a remote repositorie from the cloud that will be connected to our current repository.</p>
<p>Usually it is best to keep our original repository in the cloud just in case something happens to our devices.</p>
<p>In the hangout we passed 3 parameters to <code>git remote [action] [name-of-remote-repository] [url-of-the-repository]</code></p>
<h4>Adding Repositories</h4>
<p><code>action</code> - we can pass either <code>add</code> or <code>rm</code> to add or remove our remote repository.</p>
<p><code>name-of-repository</code> - here we will pass the name we would like to assign to our remote repository. It&#39;s common to name our remote cloud repository &quot;origin&quot;.</p>
<p><code>url-of-the-repository</code> - We&#39;ve used github to get the url of our repository.</p>
<p><strong>Steps to get the remote url</strong></p>
<ol>
<li>Navigate to http://github.com</li>
<li>Go to the repository that you want to use, and get the <em>SSH clone url</em></li>
</ol>
<p><img src="http://i.gyazo.com/cc6b82746633400c20769fb2599074e1.gif" height="500px"></p>
<p><strong>This is what our git command looks like</strong></p>
<p><code>git remote add origin [email protected]:your-user-name/git-basics.git</code></p>
<h4>Removing repositories</h4>
<p>Removing remote repositories is <em>easy</em>. All we need to do is this: <code>git remote rm [name-of-repository]</code>. That&#39;s it.</p>
<p>So if I want to remove <code>origin</code> I will do <code>git remote rm origin</code>.</p>
<h3>Git push</h3>
<p>Git push allows us to <code>push</code> and copies our last changes into the remote repository that we created. The changes that are going to be copied are only the ones that are commited.</p>
<h3>Git stash.</h3>
<p>There may be times that we want git to remember the files we&#39;ve added to the stage, but we also want to undo it and maybe try something else.</p>
<p>Git let&#39;s us <code>stash</code> the files on our stage and keeps it, until we are ready to <code>apply</code> it again.</p>
<p>Let&#39;s try it out.</p>
<ol>
<li><p>First let&#39;s create 2 sample files</p>
<p><code>$ touch sample1.txt sample2.txt</code></p></li>
<li><p>Then let&#39;s add them to our stage.</p>
<p><code>$ git add sample1.txt sample2.txt</code></p></li>
<li><p>Let&#39;s check our status. We can see that we&#39;ve added the files and that it&#39;s ready to be commited.</p></li>
</ol>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="nv">$ </span>git status
&gt; <span class="c"># Changes to be committed:</span>
&gt;# <span class="o">(</span>use <span class="s2">&quot;git reset HEAD &lt;file&gt;...&quot;</span> to unstage<span class="o">)</span>
&gt;#
&gt;# new file: sample1.txt
&gt;# new file: sample2.txt
&gt;#
</code></pre></div>
<ol>
<li>Now let&#39;s do a <code>git stash</code> and check the <code>status</code>. We can see that the files we created are gone.</li>
</ol>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="nv">$ </span>git stash
&gt; Saved working directory and index state WIP on gh-pages: 8741e43 fix date
&gt; HEAD is now at 111111 fixing things
<span class="nv">$ </span>git status
&gt; <span class="c"># On branch origin</span>
&gt; nothing to commit, working directory clean
</code></pre></div>
<ol>
<li><p>In this step you guys free to add/change/modify any files.</p></li>
<li><p>Now let&#39;s do a <code>git stash apply</code>. Now we can see that the files have been added</p></li>
</ol>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="nv">$ </span>git stash apply
&gt;# On branch gh-pages
&gt;# Changes to be committed:
&gt;# <span class="o">(</span>use <span class="s2">&quot;git reset HEAD &lt;file&gt;...&quot;</span> to unstage<span class="o">)</span>
&gt;#
&gt;# new file: sample1.txt
&gt;# new file: sample2.txt
&gt;#
</code></pre></div>
<p>https://help.github.com/articles/generating-ssh-keys
http://git-scm.com/
http://git-scm.com/book/en/Getting-Started-About-Version-Control
http://en.wikipedia.org/wiki/Revision_control</p>
</description>
</item>
<item>
<title>Ruby Basics</title>
<link>http://kodermine.com/ruby/2014/04/27/intro_to_ruby/</link>
<pubDate>Sun, 27 Apr 2014 00:00:00 +0000</pubDate>
<author></author>
<guid>http://kodermine.com/ruby/2014/04/27/intro_to_ruby</guid>
<description><p>Hello Ruby Koders,</p>
<p>These are our first shownotes from our Google Hangout session that we had on March 1, 2014.
This also doesn&#39;t include the quiz stuff that we worked on, I&#39;m gonna write a seperate article for that</p>
<p>In our session we discussed the following topics:</p>
<p><strong>Brief Introduction</strong></p>
<ul>
<li><a href="#what-is-ruby">What is Ruby</a>
<ul>
<li><a href="#everything-is-an-object-in-ruby">OMG! Everything in Ruby is an object!</a></li>
</ul></li>
<li><a href="#ruby-version-managers">Ruby Version Managers</a></li>
<li><a href="#gems">Gems</a></li>
</ul>
<p><strong><a href="#code-begins-here">Coding Time</a></strong></p>
<ul>
<li><a href="#simple-iterations-with-ruby">How to do simple iterations</a></li>
<li><a href="#comments">Comments</a></li>
<li><a href="#variables">Variables</a>
<ul>
<li><a href="#constants">Constants</a></li>
</ul></li>
<li><a href="#conditionals">Conditionals</a>
<ul>
<li><a href="#if-statement">If statement</a></li>
<li><a href="#unless-statement">Unless statement</a></li>
</ul></li>
<li><a href="#nil-nils">nil == nada</a></li>
<li><a href="#range">Range</a>
<ul>
<li><a href="#simple-shorthand-trick">Converting a range to an array</a></li>
</ul></li>
<li><a href="#arrays">Arrays</a>
<ul>
<li><a href="#shorthand-bonus"><code>&quot;&lt;&lt;&quot;</code> <code>Array#push</code> short hand</a></li>
<li><a href="#arraypush"><code>Array#push</code></a></li>
<li><a href="#arraypop"><code>Array#pop</code></a></li>
<li><a href="#arraydelete"><code>Array#delete</code></a></li>
<li><a href="#arraydelete_at"><code>Array#delete_at</code></a></li>
</ul></li>
</ul>
<h2>What is Ruby</h2>
<p>Ruby is a programming language created by an <em>awesome</em> Programmer from Japan named <a href="http://en.wikipedia.org/wiki/Yukihiro_Matsumoto">Yukihiro Matusumoto</a>(or Matz). He had a vision of creating a scripting language that was more powerful than pearl and more object oriented than python. He wanted to make the language human readable and often said &quot;natural, not simple&quot; in a way that it mirrors life.</p>
<h3>Everything is an object in Ruby</h3>
<blockquote>
<p>In Ruby, just like in real life, our world is filled with objects. Everything is an object - integers, characters, text, arrays - everything. - <a href="https://rubymonk.com/learning/books/1-ruby-primer/chapters/6-objects/lessons/35-introduction-to-objects">Ruby Monk</a></p>
</blockquote>
<p><em>This will be discussed later on when we tackle OOP more in the future</em></p>
<h2>Ruby Version Managers</h2>
<p>We need version managers because a Ruby version might have a specific syntax that has been deprecated in another and using another version of Ruby to run an application or script that requires a specific version of Ruby could result to multiple syntax errors.</p>
<p>To solve this we use a tool called version manager, version managers allows us to install and work with different Ruby environment, interpreters and gems.</p>
<p>The following are the most notable ruby version managers out there</p>
<ul>
<li><a href="http://rbenv.org">rbenv</a></li>
<li><a href="https://rvm.io/">RVM</a></li>
</ul>
<h1>Gems</h1>
<p>A gem is a module or a library that you can install in your ruby projects so that you are able to use these inside your projects. Gems provide extensions and additional features that extends the capabilities or the Ruby language.</p>
<p>Throughout our hangouts we will be making use of different gems.</p>
<h2>Code begins here.</h2>
<hr>
<h2>Simple iterations with Ruby</h2>
<p>If you were to write a loop in Java it would probably look like this:</p>
<div class="highlight"><pre><code class="java language-java" data-lang="java"><span class="kd">class</span> <span class="nc">HelloWorld</span> <span class="o">{</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span><span class="o">(</span><span class="kt">int</span> <span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="o">;</span><span class="n">i</span><span class="o">&lt;</span><span class="mi">3</span><span class="o">;</span><span class="n">i</span><span class="o">++)</span>
<span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&quot;Hello World!&quot;</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
</code></pre></div>
<p>This will return:</p>
<p>Hello World!
Hello World!
Hello World!</p>
<p>in Ruby we can do the same thing, with a simple and readable(for beginners) line of code.</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="mi">3</span><span class="o">.</span><span class="n">times</span> <span class="p">{</span> <span class="nb">puts</span> <span class="s2">&quot;Hello World!&quot;</span> <span class="p">}</span>
</code></pre></div>
<p>Short and sweet, and it returns the same as above. This is what makes Ruby such a likeable language for most people.</p>
<h2>Comments</h2>
<p>Comments are just words or phrases that you want to put into your code but you don&#39;t really want them to be executed as Ruby code. These could be either used in debugging by commenting out lines that are having problems or documenting. To write a variable in Ruby just add the pound key <code>#</code> before the text</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="c1"># This line doesn&#39;t work I wonder why</span>
<span class="c1"># int i = 0</span>
<span class="c1">#</span>
<span class="c1"># Maybe I&#39;ll have a sandwich today.</span>
<span class="c1"># Nope.. coffee will do just fine.</span>
<span class="c1"># This will print out hello world</span>
<span class="nb">puts</span> <span class="s2">&quot;Hello world&quot;</span>
<span class="nb">puts</span> <span class="s2">&quot;I like sushi&quot;</span>
<span class="c1"># Hi ruby</span>
</code></pre></div>
<p>you can also write comments with multiple lines using this syntax</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="cm">=begin</span>
<span class="cm">I&#39;m just commenting.. right here.</span>
<span class="cm">None of this will be executed.</span>
<span class="cm">Don&#39;t believe me?</span>
<span class="cm">puts &quot;Believe me!&quot;</span>
<span class="cm">=end</span>
</code></pre></div>
<h2>Variables</h2>
<p>Since Ruby is a dynamic programming language we don&#39;t have to declare variable types anymore! Goodbye <code>int i = 0</code> and hello</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="c1"># we can assign an integer to a variable</span>
<span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
<span class="c1"># replace it with a string</span>
<span class="n">i</span> <span class="o">=</span> <span class="s2">&quot;a string! wow!&quot;</span>
<span class="c1"># replace it with a boolean</span>
<span class="n">i</span> <span class="o">=</span> <span class="kp">true</span>
<span class="c1"># replace it with a string again.... with a heart shape because everyone likes hearts</span>
<span class="n">i</span> <span class="o">=</span> <span class="s2">&quot;dynamic &lt;3&quot;</span>
</code></pre></div>
<p>Ruby programmers like to use the &quot;Ruby Convention&quot; or the &quot;Ruby Way&quot; . We like using <strong>underscores, NOT ~~camel case~~</strong> (sorry programmers from other languages TT_TT we don&#39;t hate you I promise &lt;3)</p>
<p>So instead of writing something like: <code>myFirstVariableInRuby</code> we want to see something like <code>my_first_variable_in_ruby</code></p>
<p>I would advise you all to follow this convention, it&#39;s still acceptable if you use camel case but that&#39;s just not the &quot;Ruby Way&quot;</p>
<h3>Constants</h3>
<p>Constants are variables that contain values that you do not expect to change. Consonants must start with a capital letter, and just like the &quot;Ruby Way&quot; we do it with underscores</p>
<p><em>Unlike some languages, Ruby will let you change the values in constants by assigning a new value to them</em></p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="no">MINIMUM_CUPS_OF_COFFEE_EVERYDAY</span> <span class="o">=</span> <span class="mi">1</span>
<span class="no">NUMBER_OF_FINGERS_IN_ONE_HAND</span> <span class="o">=</span> <span class="mi">5</span>
<span class="c1"># I&#39;m changing it, haha!</span>
<span class="no">MINIMUM_CUPS_OF_COFFEE_EVERYDAY</span> <span class="o">=</span> <span class="mi">2</span> <span class="c1"># YESSSS!!!!!!</span>
<span class="no">NUMBER_OF_FINGERS_IN_ONE_HAND</span> <span class="o">=</span> <span class="mi">6</span> <span class="c1"># WHAAAATTTTTT?????!!!!</span>
</code></pre></div>
<h2>Conditionals</h2>
<h3>If statement</h3>
<p>Our first conditional! yay!</p>
<p>if-statement is a condtional statement that will execute if the condition is true and it also has an option to execute another code if it returns false. The condition is passed as an argument to the if statement.</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="c1"># here we have a variable set to true</span>
<span class="n">you_like_ruby</span> <span class="o">=</span> <span class="kp">true</span>
<span class="c1"># we pass the variable to the if statement</span>
<span class="k">if</span> <span class="p">(</span><span class="n">you_like_ruby</span><span class="p">)</span>
<span class="c1"># when the value is true this will be executed</span>
<span class="nb">puts</span> <span class="s2">&quot;We can be friends&quot;</span>
<span class="k">else</span>
<span class="c1"># when the value is false this will be executed</span>
<span class="nb">puts</span> <span class="s2">&quot;We can still be friends&quot;</span>
<span class="k">end</span>
</code></pre></div>
<p>and we can see how natural it feels to read the code.</p>
<blockquote>
<p>If you like Ruby we can be friends, if not, we can still be friends</p>
</blockquote>
<h3>Unless statement</h3>
<p>This statement is pretty unique to Ruby, the syntax is similar to the <code>if</code> statement but it works the opposite(because unless is the opposite of if). If the passed value returns <code>false</code> the first statement will run, <code>unless</code> also supports <code>else</code> so if it returns true it will run the code inside the <code>else</code></p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">time_to_drink_coffee</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">unless</span> <span class="n">time_to_drink_coffee</span>
<span class="c1"># keep programing with ruby</span>
<span class="k">else</span>
<span class="c1"># go get coffee</span>
<span class="k">end</span>
</code></pre></div>
<p>Did you notice that i didn&#39;t put <code>()</code> for passing arguments? Ruby allows us to leave out the parenthesis! :) Isn&#39;t it cool?</p>
<p>Let&#39;s read this like the if statement</p>
<blockquote>
<p>Unless it&#39;s time to drink coffee then keep programming with Ruby, if yes(time to drink coffee) then go get coffee</p>
</blockquote>
<p>I admit sometimes unless statements gets pretty confusing sometimes. This is how I would use <code>if</code> and <code>unless</code></p>
<p>Instead of doing</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">time_to_go_out</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">if</span> <span class="o">!</span><span class="n">time_to_go_out</span>
<span class="c1"># stay in</span>
<span class="k">end</span>
</code></pre></div>
<p>I would prefer to use <code>unless</code></p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">time_to_go_out</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">unless</span> <span class="n">time_to_go_out</span>
<span class="c1"># just stay inside</span>
<span class="k">end</span>
</code></pre></div>
<p>BUT</p>
<p>I wouldn&#39;t use an <code>unless</code> <code>else</code> because it could be confusing @_@. I would just use an if statement</p>
<p>Not this</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">time_to_go_out</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">unless</span> <span class="n">time_to_go_out</span>
<span class="c1"># stay inside</span>
<span class="k">else</span>
<span class="c1"># go run</span>
<span class="k">end</span>
</code></pre></div>
<p>But this</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">time_to_go_out</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">if</span> <span class="n">time_to_go_out</span>
<span class="c1"># go run</span>
<span class="k">else</span>
<span class="c1"># stay inside</span>
<span class="k">end</span>
</code></pre></div>
<p><em>I won&#39;t put case statements here, lets do that next time alrighty</em></p>
<h2>Nil nils.</h2>
<p>What is nil? You might be familiar with NULL or nothing/nada. Let&#39;s say we want to perform an operation in an object, but we don&#39;t know if it exists.</p>
<p>We can simply do</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="c1"># .nil is a method that you can call any object to check if they have no value or if they have a value.</span>
<span class="c1"># it can get oretty tricky because it doesn&#39;t necessarily mean empty.</span>
<span class="c1"># &quot;&quot; this is an empty string, it&#39;s not nil, but it&#39;s empty</span>
<span class="k">if</span> <span class="n">cool_object</span><span class="o">.</span><span class="n">nil?</span>
<span class="nb">puts</span> <span class="s2">&quot;cool object doesn&#39;t exist&quot;</span>
<span class="k">else</span>
<span class="nb">puts</span> <span class="n">cool_object</span><span class="o">.</span><span class="n">inspect</span>
<span class="k">end</span>
</code></pre></div>
<h2>Range</h2>
<p>A range represents an interval or a set of values with a beginning and an end.</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="c1"># let&#39;s create a range from 1-20</span>
<span class="c1">#to do that we can simply do</span>
<span class="n">my_first_range</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="mi">20</span><span class="p">)</span>
</code></pre></div>
<p>Yay! we created a range, but hmm, what can we do with it? ...
Well let&#39;s try going through <code>each</code> of them and print out their values!</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">my_first_range</span><span class="o">.</span><span class="n">each</span> <span class="p">{</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span> <span class="nb">puts</span> <span class="n">x</span> <span class="p">}</span>
<span class="c1">## or optionally</span>
<span class="n">my_first_range</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
<span class="nb">puts</span> <span class="n">x</span>
<span class="k">end</span>
</code></pre></div>
<p>awesome! that will return</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="mi">1</span>
<span class="mi">2</span>
<span class="mi">3</span>
<span class="mi">4</span>
<span class="mi">5</span>
<span class="mi">6</span>
<span class="mi">7</span>
<span class="mi">8</span>
<span class="mi">9</span>
<span class="mi">10</span>
<span class="mi">11</span>
<span class="mi">12</span>
<span class="mi">13</span>
<span class="mi">14</span>
<span class="mi">15</span>
<span class="mi">16</span>
<span class="mi">17</span>
<span class="mi">18</span>
<span class="mi">19</span>
<span class="mi">20</span>
</code></pre></div>
<h3>Simple shorthand trick</h3>
<p>If you&#39;re familiar with arrays, this is a trick that I showed to turn a range into an array</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">range_array</span> <span class="o">=</span> <span class="o">*</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="mi">5</span>
<span class="c1"># yup that&#39;s pretty much it.</span>
<span class="c1"># that will return [1,2,3,4,5] (which is an array)</span>
</code></pre></div>
<h2>Arrays</h2>
<p><em>Yay our first collection</em></p>
<p>Arrays are a collection of objects that are in order with index values that start with zero.</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="c1"># I mentioned that arrays have positions that start with zero.</span>
<span class="c1"># here are positions|0|1|2|3|4|</span>
<span class="n">one_to_five_array</span> <span class="o">=</span> <span class="o">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="o">]</span>
</code></pre></div>
<p><strong>Methods we used in the hangout</strong></p>
<h3>Array#push</h3>
<p>the <code>push</code> method takes in an argument and this will be added to the array.</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">x</span> <span class="o">=</span> <span class="o">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="o">]</span>
<span class="c1"># push for to the array</span>
<span class="n">x</span><span class="o">.</span><span class="n">push</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span>
<span class="c1"># now the x array now has [1,2,3,4]</span>
</code></pre></div>
<h4>shorthand bonus</h4>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="c1"># the code does the same thing as the code above! :)</span>
<span class="n">x</span> <span class="o">&lt;&lt;</span> <span class="mi">4</span>
</code></pre></div>
<h3>Array#pop</h3>
<p>The <code>pop</code> method deletes the last object in the array. So the object goes.. POP! ... get it? no..? Ok..</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">x</span> <span class="o">=</span> <span class="o">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="o">]</span>
<span class="n">x</span><span class="o">.</span><span class="n">pop</span>
<span class="c1"># 3 has been &#39;popped&#39; so the x array now contains [1,2]</span>
</code></pre></div>
<h3>Array#delete</h3>
<p>The <code>delete</code> method accepts an argument and it finds it in the array and deletes it.</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">x</span> <span class="o">=</span> <span class="o">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="o">]</span>
<span class="c1"># hmmm. too much 1s.. let&#39;s delete them ALL!!!</span>
<span class="n">x</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="c1"># now all the 1s are gone [2,3,4,5,6]</span>
</code></pre></div>
<h3>Array#delete_at</h3>
<p>Last command we used was <code>delete_at</code>, <code>delete_at</code> takes in an argument, the argument that we will pass must be the index/position of the object we want to delete in the array</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">x</span> <span class="o">=</span> <span class="o">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">7</span><span class="o">]</span>
</code></pre></div>
<p>also I noticed i just kept on using numbers but an array can hold anything. Watch!</p>
<div class="highlight"><pre><code class="ruby language-ruby" data-lang="ruby"><span class="n">so_many_types</span> <span class="o">=</span> <span class="o">[</span> <span class="mi">0</span><span class="o">.</span><span class="mo">0123</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">&quot;Hello Ruby Koding!&quot;</span><span class="p">,</span> <span class="kp">true</span><span class="p">,</span> <span class="kp">false</span><span class="p">,</span> <span class="p">{</span> <span class="ss">message</span><span class="p">:</span> <span class="s2">&quot;hello I&#39;m a hash, i will be introduced later&quot;</span> <span class="p">}</span><span class="o">]</span>
</code></pre></div>
<h2>Sources &amp; Resources:</h2>
<ul>
<li><a href="https://www.ruby-lang.org/en/about/">About Ruby</a></li>
<li><a href="http://en.wikipedia.org/wiki/Yukihiro_Matsumoto">Yukihiro Matsumoto Wiki</a></li>
<li><a href="http://rbenv.org">rbenv</a></li>
<li><a href="http://rvm.io">RVM</a></li>
<li><a href="http://rubymonk.com">Ruby Monk</a></li>
<li><a href="http://guides.rubygems.org/what-is-a-gem/">What is a ruby gem</a></li>
<li><a href="http://www.ruby-doc.org/">Ruby Docs</a></li>
<li><a href="http://www.ruby-doc.org/core-1.9.3/Array.html">Arrays</a></li>
<li><a href="http://www.ruby-doc.org/core-1.9.3/Range.html">Ranges</a></li>
</ul>
</description>
</item>
</channel>
</rss>