This file contains 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
# http://sheelkapur.com/2008/09/22/ruby-insertion-sort/ | |
def insertion_sort (list) | |
list.each_with_index do |element, index| | |
index.downto(0) do |j| | |
if (j > 0 && element < list[j-1]) then | |
list[j] = list[j-1] | |
else | |
list[j] = element | |
break | |
end |
This file contains 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 insertion_sort(words) | |
words.each_with_index do |word, index| | |
index.downto(0) do |placement| | |
if (placement > 0 && word < words[placement-1]) | |
words[placement] = words[placement-1] | |
else | |
words[placement] = word | |
break | |
end |
This file contains 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
# http://en.wikibooks.org/wiki/Algorithm_implementation/Sorting/Merge_sort | |
def mergesort(list) | |
return list if list.size <= 1 | |
mid = list.size / 2 | |
left = list[0, mid] | |
right = list[mid, list.size] | |
merge(mergesort(left), mergesort(right)) | |
end | |
This file contains 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 time_get | |
puts "Please hit Enter to start time tracking" | |
if gets.chomp == "" | |
Time.now | |
else | |
time_get | |
end | |
end | |
This file contains 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 'yaml' | |
def time_get | |
puts "Please hit Enter to start time tracking" | |
if gets.chomp == "" | |
Time.now | |
else | |
time_get | |
end |
This file contains 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 'yaml' | |
class TimeTrack | |
def initialize | |
@time_list = 'times.yml' | |
#Storing all of the time entries in a yml file and reading them into an array | |
prepare_file(@time_list) | |
all_times = YAML.load(open(@time_list)) |
This file contains 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
#!/usr/bin/env ruby -wKU | |
require 'yaml' | |
class TimeTrack | |
def initialize(project_name) | |
@project_name = project_name | |
@time_list = project_filename | |
This file contains 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
#!/usr/bin/env ruby -wKU | |
require 'yaml' | |
class TimeTrack | |
attr_accessor :projects | |
FILENAME = 'timelog.yml' | |
def initialize | |
prepare_data_file | |
read_data |
This file contains 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
NoMethodError in Admin/posts#show | |
Showing app/views/shared/_post.html.erb where line #24 raised: | |
Attempt to call private method | |
Extracted source (around line #24): | |
21: | |
22: <div class='body'> | |
23: <%= link_to image_tag(post.image(:large), :class => "post_image_large"), post.image(:large) if post.image? %> |
This file contains 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
<div class='post<%= " post-#{post.blog.name}" rescue nil %>'> | |
<p class='title'><%= @preview ? post.title : link_to(post.title, post_link(post, blog)) %></p> | |
<div class='meta'> | |
<span class='author'><%= post.user.name || post.user.login %></span> <span class='date_wrap'>on <span class='publish_date'><%= post.published_on.strftime("%b. %d") %></span></span> | |
<div class='clearfix'></div> | |
</div> | |
<% if current_user && @preview %> | |
<div class="admin_links"> | |
<%= link_to 'Edit this post', edit_admin_post_path(post), :class => 'edit_post' %> | |
<%= link_to 'Delete this post', admin_post_path(post), :method => :delete, |
OlderNewer