This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def mergeArrays(arr,start_1,end_1,start_2,end_2) | |
| temp = Array.new(end_1 + end_2 - start_1 - start_2 + 2) | |
| index_1 = start_1 # Marks the index in the first sub-array, which needs to be put into the temporary array next | |
| index_2 = start_2 # Marks the index in the second sub-array, which needs to be put into the temporary array next | |
| index = 0 # Mark the index in the Temporary array which is being filled | |
| while ( index_1 <= end_1 ) || ( index_2 <= end_2 ) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Ruby doesn't provide an explicit 'stack' but for all practical purposes, the Array provided by Ruby can be treated as a full-fledged stack. | |
| # Based on the ideas from : http://macdevelopertips.com/ruby/using-a-stack-with-ruby.html | |
| # Stacks are a Last In First Out Data Structure | |
| class Stack | |
| def initialize | |
| @elements = [] | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Queues as provided by Ruby. | |
| require 'thread' | |
| # Queues are a First in First Out Data Structure | |
| # Ruby provides you with synchronoized/thread-safe queues | |
| testQueue = Queue.new | |
| testQueue.enq(10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Quick Example of a Self Referential Data Structure in Ruby | |
| # NODE -> contains a value and a pointer to (next_node) | |
| # LinkedList -> This class holds the linked list functions - adding a node, traversing and displaying the linked list | |
| class Node | |
| attr_accessor :value, :next_node | |
| def initialize val,next_in_line | |
| @value = val |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Example of Self-Referential Data Structures - A Binary Tree | |
| class TreeNode | |
| attr_accessor :value, :left, :right | |
| # The Tree node contains a value, and a pointer to two children - left and right | |
| # Values lesser than this node will be inserted on its left | |
| # Values greater than it will be inserted on its right | |
| def initialize val,left,right | |
| @value = val |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## More details: http://ruby.bastardsbook.com/chapters/recursion/ | |
| #1 | |
| def countdown(n) | |
| return if n.zero? # base case | |
| puts n | |
| countdown(n-1) # getting closer to base case | |
| end | |
| countdown(5) # > 5 4 3 2 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TO LEARN: https://curl.haxx.se/docs/httpscripting.html | |
| Why cURL? | |
| Because: http://code.tutsplus.com/tutorials/techniques-for-mastering-curl--net-8470 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HTML: | |
| <div class="hover_img"> | |
| <a href="http://ddeveloperr.github.io/p1/" target="_blank">Build a Simple Google Clone Website<span><img src="img/1_google_clone.jpg" alt="image" height="100" /></span></a> | |
| </div> | |
| CSS: | |
| .hover_img a { position:relative; } | |
| .hover_img a span { position:absolute; display:none; z-index:99; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Migration Overview | |
| Migrations are a convenient way to alter your database schema over time in a consistent and easy way. | |
| They use a Ruby DSL so that you don't have to write SQL by hand, allowing your schema and changes to be | |
| database independent. | |
| db:migrate runs (single) migrations that have not run yet. | |
| db:create creates the database | |
| db:drop deletes the database | |
| db:schema:load creates tables and columns within the (existing) database following schema.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Deep learning here: https://www.youtube.com/watch?v=y57OnWV6dRE | |
| https://gorails.com/episodes/the-params-hash?autoplay=1 |