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) What are the top 50 worst rated movies? The results should include the movie title and rating and be sorted by the worst rating first. | |
| SELECT movies.title, movies.rating FROM movies | |
| WHERE movies.rating < 5 | |
| ORDER BY movies.rating LIMIT 50; | |
| 2) What movies do not have a rating? The results should include just the | |
| movie titles in sorted order. | |
| SELECT movies.title FROM movies |
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
| class WordCount | |
| def initialize(sentence) | |
| @sentence = sentence | |
| end | |
| def frequency | |
| word_counter = Hash.new(0) | |
| @sentence.split(' ').each do |word| | |
| word_counter[word.downcase] += 1 | |
| 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
| class AnagramGenerator | |
| attr_accessor :word, :words, :letters | |
| def initialize(word) | |
| @word = word | |
| @words = [] | |
| end | |
| def generate | |
| if word == '' | |
| raise ArgumentError, "It can't be a blank string" |
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
| class TddWordAnalytics | |
| attr_reader :sentence | |
| def initialize(sentence) | |
| @sentence = sentence | |
| end | |
| def analytics | |
| analytic = [] | |
| word = word_count.sort { |a,b| b[1]<=>a[1] }[0..1] | |
| word = word.map do |word| |
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 compress(sequence) | |
| array = sequence.split | |
| hash = Hash.new(0) | |
| second_hash = Hash.new(0) | |
| array.each_with_index do |item, i| | |
| if hash[item] != 0 && array[i-1] != item | |
| second_hash[item] += 1 | |
| else | |
| hash[item] += 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
| @number = 0 | |
| print "How much should we add:" | |
| @number + gets.chomp.to_i | |
| puts "> #{@number}" | |
| print "How much should we subtract:" | |
| @number - gets.chomp.to_i | |
| puts "> #{@number}" | |
| print "How much should we multiply:" | |
| @number = gets.chomp.to_i * @number | |
| puts "> #{@number}" |
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
| -(void)moveItemAtIndex:(NSUInteger)fromIndex | |
| toIndex:(NSUInteger)toIndex | |
| { | |
| if(fromIndex == toIndex) { | |
| return; | |
| } | |
| BNRItem *item = self.privateItems[fromIndex]; | |
| //Remove item from array |
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
| # renders | |
| # { :json => 7 } |
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 add_some | |
| 1+1 = 2 | |
| puts "added" | |
| 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
| [alias] | |
| copr = "!f() { git fetch -fu origin refs/pull/$1/head:pr-$1; git checkout pr-$1; } ; f" | |
| prunepr = "!git for-each-ref refs/heads/pr-* --format='%(refname:short)' | while read ref ; do git branch -D $ref ; done" | |
| tree = log --pretty=oneline --abbrev-commit --graph --decorate |