Skip to content

Instantly share code, notes, and snippets.

View markmcdonald51's full-sized avatar

Mark The Spot markmcdonald51

  • hdp
  • Portland, Oregon
View GitHub Profile
require 'rubygems'
require 'irb/completion'
require 'map_by_method'
require 'what_methods'
require 'pp'
require 'hirb'
require 'irb/completion'
require 'irb/ext/save-history'
# Tell irb how much it should remember and where
require 'rubygems'
gem 'scrapi'
require 'scrapi'
# Parse bens bargains!
URL = 'http://bensbargains.net/'
scraper = Scraper.define do
array :posts
process '.newsText', :posts => Scraper.define {
export PS1="\[\033[01;34m\] \w \[\033[31m\]\`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`\[\ 033[37m\]$\[\033[00m\] "
rake("gems:install", :sudo => true)
gem 'install_theme'
#gem 'haml'
#run 'haml --rails .'
gem 'mislav-will_paginate', :lib => 'will_paginate'
#gem 'rubyist-aasm'
plugin 'resource_controller',
############## plugin commands #################
# RSpec is the original Behaviour Driven Development framework for Ruby.
plugin 'rspec',
:git => "git://github.com/dchelimsky/rspec.git"
# The world's greatest templating system
plugin 'haml',
:git => "git://github.com/nex3/haml.git"
module ApplicationHelper
def link_to_remove_fields(name, f)
f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
end
def link_to_add_fields(name, f, association)
new_object = f.object.class.reflect_on_association(association).klass.new
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
render(association.to_s.singularize + "_fields", :f => builder)
end
# polyline_decoder.rb by George Lantz August 2007
# Usage Example:
#
# line = "{b~zEdruxPT?L|@PP"
#--
#
# Utility for creating Google Maps Encoded GPolylines
#
# License: You may distribute this code under the same terms as Ruby itself
#
# Author: Joel Rosenberg
#
# ( Drawing from the official example pages as well as Mark McClure's work )
#
-------- class SubscriptionTransaction
named_scope :today,
:conditions => ['created_at > ? and created_at < ?',
Time.new.beginning_of_day, Time.new.tomorrow.beginning_of_day]
--------class Subscription
named_scope :due_today,
#:include => [:customer],
module AasmAddons
def self.included(base_class)
base_class.class_eval do
def aasm_fire_event(*args)
line_items.each do |li|
#li.send("#{args.first.to_s}!")
li.update_attributes(:state => args.first.to_s)
end
state_logs.create!(:state => args.first.to_s, :user => current_user)
super(*args)