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
| possible_words = ["seek", "find", "ignore", "pursue", "covet"] | |
| available_letters = [ "w5","g6","f7","s2","e1","l3","h8","n1","f7","b8","r12","u3","g6","i4","q9","o3","d2","s2","f7"] | |
| words = Array[possible_words].flatten | |
| available_letters = tiles.map {|e| e[0]} | |
| available_letters.each {|e| words = words.map {|w| w.sub(e, '')}} | |
| viable_words = words.each_with_index.collect {|w,k| possible_words[k] if w==""}.compact | |
| letter_value_hash = Hash[tiles.map {|l| [l.slice(0), l.slice(1..3).to_i]}] | |
| word_as_values = viable_words.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
| @new_array = %w(fun apple dance Zebra goose teenager) | |
| def choose_a_random_word some_array | |
| word = some_array[rand(0...some_array.size)] | |
| some_array.delete_if do |w| | |
| w == word | |
| end | |
| word | |
| 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
| Dir.chdir #add your music directory here | |
| all_music = (Dir['**/*.mp3'].shuffle) | |
| puts "what do you want to name your playlist?" | |
| answer = gets.chomp | |
| File.open "#{answer}.m3u",'w' do |file| | |
| all_music.each do |mp3_file_name| | |
| file.write "#{mp3_file_name}\n" | |
| end | |
| 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
| grep -rh '^[[:space:]]*\(class\|module\)\b' app lib --include='*.rb' | | |
| sed 's/^[[:space:]]*//' | | |
| cut -d ' ' -f 2 | | |
| while read class; do | |
| echo "`grep -rl "\b$class\b" app lib --include="*.rb" | wc -l` $class"; | |
| done | | |
| sort -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
| #create a file (here called "file.txt") to paste the cap output into, run this file to clean the output. | |
| require 'fileutils' | |
| require 'tempfile' | |
| t_file = Tempfile.new('sources.txt') | |
| File.open("file.txt", 'r+') do |f| | |
| f.each_line do |line| | |
| line = line.to_s | |
| line = line.strip |
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 'csv' | |
| def remove_dupes | |
| uniq_csv = [] | |
| CSV.foreach("input.csv","r+") {|csv| uniq_csv << csv } | |
| uniq_csv.uniq!.compact.compact | |
| end | |
| CSV.open("ouput.csv","w+") do |csv| |
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
| scope :search, lambda{|query| | |
| return scoped if query.blank? | |
| tokens = query.split(/ |\+|,/).collect {|c| "%#{c.downcase}%"} | |
| joins(:user).where(["#{(["(lower(user.first_name) like ? \ | |
| or lower(user.last_name) like ? \ | |
| or lower(user.social_security_digits) like ? \ | |
| or lower(users.email) like ? \ | |
| or user.date_of_birth like ? \ | |
| or user.id like ? \ |
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 'oauth_util.rb' | |
| require 'net/http' | |
| o = OauthUtil.new | |
| o.consumer_key = 'examplek9SGJUTUpocjZ5QjBJmQ9WVdrOVVFNHdSR2x1TkhFbWNHbzlNQS0tJnM9Y29uc3VtkZXJzZWNyZXQmeD0yYg--'; | |
| o.consumer_secret = 'exampled88d4109c63e778dsadcdd5c1875814977'; | |
| url = 'http://query.yahooapis.com/v1/yql?q=select%20*%20from%20social.updates.search%20where%20query%3D%22search%20terms%22&diagnostics=true'; |
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 'fis/test' | |
| require_relative 'student' | |
| include Fis::Test | |
| test 'should create a table' do | |
| assert Student.drop | |
| assert !Student.table_exists?('students') | |
| assert Student.create_table | |
| assert Student.table_exists?('students') |
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/INSTANCE METHODS AND VARIABLES PRACTICE: | |
| # ADD YOUR CODE TO THIS FILE | |
| # | |
| #1. Class/Methods | |
| # -create a class called Project | |
| # -create a class variable called count | |
| # -create a instance method called "say_class_name" that prints name of the class | |
| #2.Instance Variables/Class Variables/Constants | |
| # - create a class method to return @@count | |
| # - give it the instance variables title, description, role, date created and date updated |
OlderNewer