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
@markmcdonald51
markmcdonald51 / gist:5feff60cd592f6063991
Created February 3, 2015 20:56
ActiveScaffoldStateMachine ... lib/as_aasm.rb
module ActiveScaffoldStateMachine
# add to controller
#config.action_links.member.add 'get_states', position: false
=begin
Then create a view called get_states.js.erb and put it in the view dir or
a common directory called active_scaffold_overrides which contains the following:
<%
@markmcdonald51
markmcdonald51 / gist:2ec948c542dcf97b2f56
Created May 13, 2015 12:39
Recreate a sqlite3 dev db from current pg_dump from production.
namespace :database_utilities do
desc "Recreate a sqlite3 dev db from current pg_dump from production."
# This task should only ever be run in a development environment.
task create_sqlite3_from_pg_dump: :environment do
# by Mark on Wed May 13 06:15:09 EDT 2015
# Based on the ideals from this webpage:
# http://manuel.manuelles.nl/blog/2012/01/18/convert-postgresql-to-sqlite/
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 )
#