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
| 1) Backup PG | |
| $ pg_dump -U postgres -F t sdf2_development > db/csv/pg_backups/sdf2_development.psql | |
| $ pg_dump -F c -v -U postgres -h localhost sdf2_development -f db/csv/pg_backups/sdf2_development.tar | |
| 2) Restore PG: | |
| $ pg_restore -U postgres db/csv/pg_backups/sdf2_development.psql | |
| $ pg_restore -c -C -F c -v -U postgres db/csv/pg_backups/sdf2_development.tar | |
| ############ Progress ############ | |
| bundle exec tail -f log/development.log |
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 word_formatter(word) | |
| word_chars = word.downcase.chars.sort | |
| word_chars.join('') | |
| end | |
| def find_anagrams(possible_anagrams, word) | |
| input_word = word_formatter(word) | |
| detect = false |
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
| require 'pry' | |
| def convert_to_roman(arabic_number, modern = false) | |
| modern ? convert_to_modern(arabic_number) : convert_to_classic(arabic_number) | |
| end | |
| def convert_to_classic(arabic_number) | |
| answer = arabic_number / 1000 # 1 | |
| remainder = arabic_number % 1000 # 1 | |
| thousands = "M" * answer |
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
| # Look at the tests in `spec/social_security_numbers_spec.rb` | |
| # to see a description of how these methods should behave. | |
| # Determine whether a string contains a Social Security Number. | |
| def has_ssn?(string) | |
| arr = string.scan(/\d{3}-\d{2}-\d{4}/) | |
| if arr == nil || arr == [] | |
| false | |
| else | |
| string.include?(arr[0]) |
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 most_frequent_words(filename, count = 5) | |
| # file_parser(filename) | |
| # end | |
| file_path = 'text-files/osiris_myth.txt' | |
| def string_count_sorter(string_count_hash) | |
| rankings = string_count_hash.sort_by {|_key, value| value} | |
| puts rankings.inspect | |
| 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
| # def straight_line_include?(word, puzzle) | |
| # end | |
| # | |
| # def snaking_include?(word, puzzle) | |
| # end | |
| ############################################ | |
| puzzle = [ | |
| ["a", "w", "o", "l", "v", "e", "s"], | |
| ["s", "o", "a", "w", "a", "h", "p"], |
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
| # EXERCISE 1 | |
| # <Your code here> | |
| first_name = 'Adam' | |
| last_name = 'Booth' | |
| greeting = "My name is #{first_name} #{last_name}." | |
| puts greeting | |
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 fac(n) # => Calculates factorial of number. | |
| if n < 1 | |
| 1 | |
| else | |
| n * fac(n - 1) | |
| end | |
| end | |
| def find_subsets(n, r) | |
| fn = fac(n) |
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 shuffle(array) | |
| input = array.clone | |
| output = [] | |
| len = input.length | |
| while len > 0 | |
| r = Random.rand(0..len-1) | |
| output << input[r] | |
| input.delete_at(r) | |
| len = input.length |
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 linear_search(target, arr) | |
| i = 0 | |
| while i < arr.length | |
| if arr[i] == target | |
| return i | |
| else | |
| nil | |
| end |