Skip to content

Instantly share code, notes, and snippets.

View mindplace's full-sized avatar
🎯
Focusing

Esther Leytush mindplace

🎯
Focusing
View GitHub Profile
def insertion_sort(array)
sorted = false
while sorted == false
array.each_index do |i|
next if i == 0
a = array[i]
b = array[i - 1]
if a < b
sorted = false
if [ -s $@ ]
then
echo
echo "Let's test to make sure you have all the software you need!"
echo "You can pass this file as many items of software as you want"
echo "to check, like so:"
echo
echo " ./software_tester ruby git sqlite3"
echo
echo "You should first try it out with the following items, because"
def bubble_sort(array)
sorted = false
while sorted == false
array.each_index do |i|
a = array[i]
b = array[i + 1]
if b == nil
sorted = true
break
class Adventure
attr_reader :user, :gender
def initialize(name)
@user = name
@gender = set_gender
end
def set_gender
print "Art thou a she, a he, or sommat else? (she, he, else) "
def shorten_url(message)
puts "Shortening links..."
urls = Hash.new(0)
url = message.split.select{|item| item.include?("http") || item.include?("www")}
text = message.split.select{|item| !url.include?(item)}.join(" ")
url.each do |item|
url_index = message.split.index(item)
require 'jumpstart_auth'
require 'bitly'
class MicroBlogger
attr_reader :client
def initialize
@client = JumpstartAuth.twitter
end
if __FILE__ == $PROGRAM_NAME
blogger = MicroBlogger.new
puts "\nWelcome to the JSL Twitter client!"
puts "Available commands:"
puts " q => quit"
puts " dm => direct message "
puts " t => tweet"
puts " g => see all the latest tweets from friends\n\n"
command = ""
commands = {"dm" => "route_dm", "t"=>"tweet", "q"=>"quit",
class ToDoList
attr_reader :list
def initialize
@list = []
end
def get_the_items
puts "Your to-do list!"
puts "Enter each item. When you've put in your last item,"
class ThoughtCounter
attr_reader :thoughts
def initialize
@thoughts = {}
end
def translate_time(seconds)
return "#{seconds} seconds" if seconds < 60
def quick_sort(array, pivot=-1)
if array.empty? || array.length == 1
return array
end
slice_left = []
slice_right = []
pivot_slices = []
array.each_index do |j|