Skip to content

Instantly share code, notes, and snippets.

View jmoon90's full-sized avatar

John Moon jmoon90

  • New York, NY
View GitHub Profile
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
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
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"
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|
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
@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}"
-(void)moveItemAtIndex:(NSUInteger)fromIndex
toIndex:(NSUInteger)toIndex
{
if(fromIndex == toIndex) {
return;
}
BNRItem *item = self.privateItems[fromIndex];
//Remove item from array
# renders
# { :json => 7 }
def add_some
1+1 = 2
puts "added"
end
@jmoon90
jmoon90 / git alias
Created April 18, 2016 05:49
Git alias.
[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