Skip to content

Instantly share code, notes, and snippets.

View hayduke19us's full-sized avatar
🐙

matthew sullivan hayduke19us

🐙
View GitHub Profile
require "Nokogiri"
require 'active_support/core_ext/hash/conversions'
puts "type in the full path to the file to be parsed."
file = gets.chomp.to_s
# Grab the file that needs to be parsed
f = File.open(file)
def sort some_array
recursive_sort some_array, []
end
def recursive_sort unsorted_array, sorted_array
first_word = unsorted_array.first
temp = []
temp << first_word
def recursive_sort unsorted_array, sorted_array
first_word = unsorted_array.first
temp = []
temp << first_word
unsorted_array.shift
unsorted_array.each do |words|
if words.length > temp[0].length
def sort unsorted_array, sorted_array
while unsorted_array.count >= 2
temp = unsorted_array.shift
counter = unsorted_array.count
unsorted_array.cycle(counter) do |word|
if temp.length < word.length
temp = temp
elsif temp.length > word.length
unsorted_array << temp
def shuffle sorted_array, unsorted_array
counter = sorted_array.count - 1
rand_number = (rand(counter))
temp = sorted_array[rand_number]
sorted_array.delete_at(rand_number)
unsorted_array << temp
if sorted_array.count >= 1
shuffle sorted_array,unsorted_array
class SessionsController < ApplicationController
def index
if current_user
token = current_user.access_token
secret = current_user.access_secret
#for browsing the info
filename = '.access_token.yml'
File.open filename, 'w' do |f|
f.write token
class Life
attr_reader :age, :name, :span
def initialize(args)
@age = args[:age]
@name = args[:name]
@span = args[:span]
end
end
<% if options.orientation == :vertical %>{<% end %>
<table border="0" align="center" cellspacing="0.5" cellpadding="0" width="<%= NODE_WIDTH + 4 %>">
<tr><td align="center" valign="bottom" width="<%= NODE_WIDTH %>"><font face="Arial-BoldMT" point-size="11"><%= entity.name %></font></td></tr>
</table>
<% if attributes.any? %>
|
<table border="0" align="left" cellspacing="2" cellpadding="0" width="<%= NODE_WIDTH + 4 %>">
<% attributes.each do |attribute| %>
<tr><td align="left" width="<%= NODE_WIDTH %>" port="<%= attribute %>"><%= attribute %> <font face="Arial-ItalicMT" color="grey60"><%= attribute.type_description %></font></td></tr>
<% end %>
# encoding: utf-8
require "rails_erd/diagram"
require "graphviz"
require "erb"
# Fix bad RegEx test in Ruby-Graphviz.
GraphViz::Types::LblString.class_eval do
def output # @private :nodoc:
if /^<.*>$/m =~ @data
@data
module VotingGame
class Playlist
attr_reader :group
attr_accessor :attributes, :point_adjuster
def initialize(args)
@attributes = args[:attributes]
@group = args[:group]
@point_adjuster = args[:point_adjuster]
@members = (@group.friends.count + 1)/@attributes.tracks.count.to_f
@total_votes = lambda {|track| total = track.votes_for - track.votes_against}