-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed.xml
252 lines (196 loc) · 12.3 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
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Blog Name</title>
<subtitle>Blog subtitle</subtitle>
<id>http://blog.url.com/blog</id>
<link href="http://blog.url.com/blog"/>
<link href="http://blog.url.com/feed.xml" rel="self"/>
<updated>2015-01-03T19:00:00-05:00</updated>
<author>
<name>Blog Author</name>
</author>
<entry>
<title>Active Record</title>
<link rel="alternate" href="http://blog.url.com/blog/2015/01/04/active-record.html"/>
<id>http://blog.url.com/blog/2015/01/04/active-record.html</id>
<published>2015-01-03T19:00:00-05:00</published>
<updated>2015-09-08T18:20:56-04:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><h2>What is Active Record</h2>
<p>Active Record is an API which is part of the Ruby on Rails framework. It is the model in the &#39;MVC&#39; system. Active Record is responsible for all the business data and logic that is saved to the database.</p>
<h2>Why is it so awesome?</h2>
<p>Active Record allows rails developers to program all the business logic using Ruby without the need for SQL and works with almost all SQL relational databases. This means that Active Record can use one piece of code and it can work for different SQL Databases. Behind the scenes the API is making SQL queries on the database. Active Record uses the proper SQL query for whichever SQL database you choose. (Example: You may have a SQLite database for your UAT environment but a Oracle Database for Production. Active Record will use the correct queries for each environment without the need for duplicative code. )</p>
<h2>What else can it do?</h2>
<p>It can also help with assigning many to many or one to one relationships.</p>
<h2>Any Negatives?</h2>
<p>The only negative is that it requires you to read documentation about the Active Record API in Rails. The good news is if you want to use SQL queries you can still do so.</p>
</content>
</entry>
<entry>
<title>Blocs, Procs, and Lambdas</title>
<link rel="alternate" href="http://blog.url.com/blog/2014/12/07/blocs-procs-lambdas.html"/>
<id>http://blog.url.com/blog/2014/12/07/blocs-procs-lambdas.html</id>
<published>2014-12-06T19:00:00-05:00</published>
<updated>2015-09-08T18:20:56-04:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><h2>Block</h2>
<p>A Ruby Block is a way to to iterate through an array or hash using a method like .each. It can be confusing for programmers coming from different languages.
Block Code</p>
<pre><code class="ruby">array = [1,2,3,4,5]
array.each { |x| # The x parameter represents each item in the array but can be called anything like &#39;y&#39; or &#39;item&#39;
#Block
puts x # Will print each item of the array to the terminal screen.
}
</code></pre>
<p>The code above simply prints each item of the array in the terminal as shown below.</p>
<pre><code>1
2
3
4
5
</code></pre>
<h2>Procs</h2>
<p>A Proc or procedure allows you to make an object and call it later by using the <code>.call</code> method.
Procs Code</p>
<pre><code class="ruby">square = Proc.new{|n| n * n }
multiply = Proc.new {|x, y| x * y }
p square.call(3) # or you may use this syntax square[3]
p multiply.call(4, 3) # or you may use this syntax multiply[4, 3]
</code></pre>
<p>As you can see, in the first call <code>square.call(3)</code>. The number three is the parameter that is defined as &#39;n&#39; in the square method. But in the multiply method there are two parameters, 4 and 3 which are x and y in the method.</p>
<pre><code>9
12
</code></pre>
<h2>Lambdas</h2>
<p>Both procs and Lambdas are kinds of Proc classes. The only difference is how they return an object. I found a post here that has more info on their differences.
Lambdas Code</p>
<pre><code class="ruby">sentence = lambda {puts &quot;Hello Boys and Girls.&quot;} # same as sentence = proc {puts &quot;Hello Boys and Girls.&quot;}
sentence.call
puts &quot;Is sentence a lambda - #{sentence.lambda?}&quot;
</code></pre>
<p>Much like the Procs code, in the Lambdas Code, the method is called using <code>.call</code>.</p>
<pre><code>Hello Boys and Girls.
Is sentence a lambda - true
</code></pre>
</content>
</entry>
<entry>
<title>Ruby Classes 101</title>
<link rel="alternate" href="http://blog.url.com/blog/2014/11/30/ruby-classes.html"/>
<id>http://blog.url.com/blog/2014/11/30/ruby-classes.html</id>
<published>2014-11-29T19:00:00-05:00</published>
<updated>2015-09-08T18:20:56-04:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><h2>Best Use Cases for Classes</h2>
<p>The best way to use Classes is when working with data whose methods repeat and have similar data structure. Let&#39;s say we had a Sports statistics website. We can have a class that represents a player. Each player needs to be able to be able to have data about them stored (Height, age, stats, picture, rating) and also be able to have different methods like one that prints a graphical card image of the player.</p>
<pre><code class="ruby">class Player
attr_accessor :height, :dob, :stats, :picture, :rating, :name
def initialize(name,height,dob,rating)
@name = name
@height = height
@dob = dob
@stats = {}
@rating = rating
end
def printInfo
puts &quot;name: #{@name}&quot;
puts &quot;height: #{@height}&quot;
puts &quot;dob: #{@dob}&quot;
puts &quot;rating: #{@rating}&quot;
end
end
</code></pre>
<h2>Including Our Class File</h2>
<p>The <code>classes.rb</code> file above is a good example of when to use a classes. The initialize method stores info stores default info about each player. The printInfo method prints to the console some info about that player. Let&#39;s make a new Player and and then use the printInfo method to print player info.</p>
<pre><code class="ruby">require_relative &#39;classes.rb&#39;
p1 = Player.new(&quot;Rubin TI Jones&quot;,&quot;5&#39;11&quot;,&quot;01-13-1989&quot;,&quot;101&quot;) # (name,height,dob,rating)
p1.rating =&quot;105&quot;
p1.printInfo
</code></pre>
<p>The expected Output will be:</p>
<pre><code>name: Rubin TI
height: 5&#39;11
dob: 01-13-1989
rating: 101
</code></pre>
</content>
</entry>
<entry>
<title>Enumerables in Ruby</title>
<link rel="alternate" href="http://blog.url.com/blog/2014/11/23/enumerable-methods.html"/>
<id>http://blog.url.com/blog/2014/11/23/enumerable-methods.html</id>
<published>2014-11-22T19:00:00-05:00</published>
<updated>2015-09-08T18:20:56-04:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><h2>What is an Enumerable?</h2>
<p>This post will focus on explaining Enumerables for beginners and the map Enumerable works. Enumerable are built in methods that can be used on a string, array, or hash. Enumerables are useful because one doesn&#39;t have to write the method from scratch.</p>
<h2>Map</h2>
<p><code>&#39;map { |item| block } → new_ary&#39;</code> </p>
<p>Take for example the &#39;map&#39; Enumerable. This enumerable returns a new array with the values returned by the block. It&#39;s useful when one needs to iterate through an array and change a bunch of values. See example below. Each item is multiplied by 3.</p>
<pre><code class="ruby">def multiply(array)
array.map {|x|
x*2
}
end
array = [1,2]
newArray = multiply(array)
p newArray
</code></pre>
<h2>Conclusion</h2>
<p>The above code will make <code>p newArray</code> will output <code>[2, 4]</code> to the console.</p>
</content>
</entry>
<entry>
<title>Ruby Hashes and Arrays</title>
<link rel="alternate" href="http://blog.url.com/blog/2014/11/16/ruby-hashes-arrays.html"/>
<id>http://blog.url.com/blog/2014/11/16/ruby-hashes-arrays.html</id>
<published>2014-11-15T19:00:00-05:00</published>
<updated>2015-09-08T18:20:56-04:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><h2>Arrays</h2>
<p>An Array is represented by square brackets <code>[ ]</code>. Below is some sample code for an example of an array in ruby. The array index starts at 0 so to print the first item to the console one would type
puts <code>array1[0]</code>. To print the second item in the array one would type &quot;puts array1[1]&quot; and so on for the next sequential item in the array.</p>
<pre><code class="ruby">array1 = [&quot;hello&quot;,&quot;world&quot;,&quot;!!!&quot;]
</code></pre>
<h2>Hashes</h2>
<p>A hash is represented by squigly brackets <code>{ }</code>. Below is some sample code for an example of a hash in ruby. Each city is represented by a symbol or abbreviation for the city it represents. Example, <code>:bk</code> is the symbol for the city &quot;Brooklyn&quot;. To print each item in the hash you put the name of the hash followed by a square bracket with the key inside as show to the right. <code>location[:bk]</code>.</p>
<pre><code class="ruby">location = { :bk =&gt; &quot;Brooklyn&quot;, :si =&gt; &quot;Staten Island&quot;, :ma =&gt; &quot;Manhatten&quot;, :bx =&gt; &quot;The Bronx&quot;, :qu =&gt; &quot;Queens&quot; }
</code></pre>
<h2>Similarities between Arrays and Hashes.</h2>
<p>Both Arrays and Hashes are considered indexed collections. Both arrays and hashes store a series of objects like strings, numbers, or other arrays using a key. Also both, can expand to hold more objects.</p>
</content>
</entry>
<entry>
<title>Difference between Static, Absolute, Relative, Fixed Positioning.</title>
<link rel="alternate" href="http://blog.url.com/blog/2014/11/09/css-positioning.html"/>
<id>http://blog.url.com/blog/2014/11/09/css-positioning.html</id>
<published>2014-11-08T19:00:00-05:00</published>
<updated>2015-09-08T18:20:56-04:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><p>I wrote this post so beginners can easily figure out the difference between the various positiong types. Please let me know if you have questions or if anything in this post is not clear. I would be happy to help.</p>
<h2>Static</h2>
<p>This is the default positioning for every single page element. It just means the element flows in the order it appears on the page.</p>
<h2>Absolute</h2>
<p>This positoning type allows one put the element exactly where you want it to be on the page regardless of where the element is terms of its order on the page.</p>
<h2>Relative</h2>
<p>This poistioning allows you to move the element relative to where the element is in in its static state. An Example would be if you want to move 4 pixels to the left Like show below.</p>
<h2>Fixed</h2>
<p>This poistioning allows you to place an element anywhere you want and not have effected by scrolling. See Example below where header stays on top when user scrolls.</p>
<h2>Helpful Resources</h2>
<p><a href="http://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/">Helpful css-tricks.com post</a> </p>
<p><a href="http://www.codecademy.com/courses/advanced-css-positioning/0/1">Codecademy Positioning Excersise</a> </p>
</content>
</entry>
</feed>