My Recent Pastes (39 and counting)

All Pasties (over 39 and counting)

Pages: 1 2

Below are summaries of the 15 most recent pasties by Duane Johnson.

September 05, 2007
12:24AM EDT
by Duane Johnson

1
2
3
4
5
module Merb
  module Admin
    module AdminTest
      # helpers deinfed here available to all views.
    end

September 05, 2007
12:09AM EDT
by Duane Johnson

1
2
3
4
5
      def remove_constant(const, base = nil)
        parts = const.to_s.split("::")
        base ||= parts.size == 1 ? Object : Object.full_const_get(parts[0..-2].join("::"))
        object = parts[-1].intern
        puts "Removing #{const} -- #{object} from #{base}"

September 04, 2007
11:52PM EDT
by Duane Johnson

1
2
3
4
5
      def remove_constant(const)
        parts = const.to_s.split("::")
        base = parts.size == 1 ? Object : Object.full_const_get(parts[0..-2].join("::"))
        object = parts[-1].intern
        # puts "Removing #{object} from #{base}"

September 04, 2007
8:41PM EDT
by Duane Johnson

1
2
3
4
5
      def reload
        return unless @@merb_opts[:reloader] == true
        # First we collect all files in the project (this will also grab newly added files)
        project_files = MERB_PATH_GLOBS.map { |glob| Dir[MERB_ROOT + glob] }.flatten.uniq
        project_mtime = mtime( project_files ) # Latest changed time of all project files

September 04, 2007
8:37PM EDT
by Duane Johnson

1
2
3
4
5
  # About 50% faster than string.split('/').map{ |s| s.camel_case }.join('::')
  def path_to_constant
    new_string = ""
    input = StringScanner.new(string)
    until input.eos?

September 04, 2007
2:56PM EDT
by Duane Johnson

1
2
3
4
--- 
sequel: 
  version: =0.2.0.1
  when: before

September 04, 2007
2:42PM EDT
by Duane Johnson

1
2
3
4
5
Started merb_init.rb ...
Loading Gems (before framework) ...
/opt/local/lib/ruby/site_ruby/1.8/rubygems/version.rb:307:in `parse': Illformed requirement [= =0.2.0.1] (ArgumentError)
        from /opt/local/lib/ruby/site_ruby/1.8/rubygems/version.rb:238:in `initialize'
        from /opt/local/lib/ruby/site_ruby/1.8/rubygems/version.rb:237:in `initialize'

September 03, 2007
9:28PM EDT
by Duane Johnson

1
2
3
4
5
puts "merb init called"

# $: << File.join(MERB_ROOT, "lib", "sequel", "lib")

Dir[MERB_ROOT+"/lib/*/lib/*.rb"].each               { |m| require m }

September 03, 2007
3:47PM EDT
by Duane Johnson

1
2
3
4
5
    #  url(:page => 2)                            # => /posts/show/1?page=2
    #  url(:new_post, :page => 3)                 # => /posts/new?page=3
    #  url('/go/here', :page => 3)                # => /go/here?page=3
    #
    def url(route_name = nil, new_params = {})

August 31, 2007
1:11PM EDT
by Duane Johnson

1
2
3
4
5
      def handle(request, response)
        begin
          start = Time.now
          
          status, headers = 200, {'Content-Type' =>'text/html'}

August 30, 2007
7:53PM EDT
by Duane Johnson

1
2
3
4
5
      # A simple route match, sends "/contact" to Info#contact
      # (i.e. the 'contact' method inside the 'Info' controller)
      r.match("/contact").
        to(:controller => "info", :action => "contact")
      

August 30, 2007
6:14PM EDT
by Duane Johnson

1
2
3
4
5
lambda { |request|
  cached_path = request.path
  cached_method = request.method.to_s
  if  # {:protocol=>"https"}
      (/https/ =~ request.protocol.to_s && (protocol = $~))

August 30, 2007
3:13PM EDT
by Duane Johnson

1
2
3
4
5
    Merb::Router.prepare do |r|
      r.later do |request|
        if request.path =~ %r[/([^/]+)/([^/]+)(/([^/]+))?]
          klass = $1.classify
          if klass.respond_to? $2

August 29, 2007
4:41PM EDT
by Duane Johnson

1
2
3
4
5
# Duane Johnson's Interactive Ruby Configuration File (~/.irbrc)
#
# Just put this file in ~/.irbrc and your irb experience will be much better!

# Include tab-completion in irb

August 29, 2007
4:39PM EDT
by Duane Johnson

1
2
3
4
5
# Include tab-completion in irb
require 'irb/completion'

# Modify the prompt so it looks nice and tidy. Taken from Programming Ruby 2.
IRB.conf[:IRB_RC] = proc do |conf|

Next page

Previous page