Skip to content

Instantly share code, notes, and snippets.

View renaehodgkins's full-sized avatar

Renae Hodgkins renaehodgkins

View GitHub Profile
# 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
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
# 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
def time_get
puts "Please hit Enter to start time tracking"
if gets.chomp == ""
Time.now
else
time_get
end
end
require 'yaml'
def time_get
puts "Please hit Enter to start time tracking"
if gets.chomp == ""
Time.now
else
time_get
end
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))
#!/usr/bin/env ruby -wKU
require 'yaml'
class TimeTrack
def initialize(project_name)
@project_name = project_name
@time_list = project_filename
#!/usr/bin/env ruby -wKU
require 'yaml'
class TimeTrack
attr_accessor :projects
FILENAME = 'timelog.yml'
def initialize
prepare_data_file
read_data
@renaehodgkins
renaehodgkins / halp
Created November 15, 2011 18:54
halp
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? %>
@renaehodgkins
renaehodgkins / admin post
Created November 15, 2011 18:56
admin post
<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,