Skip to content

Instantly share code, notes, and snippets.

@Panmind
Panmind / redmine_notifier_helper.rb
Created July 21, 2010 09:41
A comfortable HTTP client to the redmine hoptoad server interface
# This module implements a comfortable HTTP client to Redmine to post a
# new issue using the HTTP interface exposed by the Hoptoad redmine plugin:
# http://github.com/vjt/redmine_hoptoad_server
# (C) 2010 Panmind - Released under the terms of the Ruby License
#
module PM
# Usage example:
#
# class UserFeedbacksController < ApplicationController
# include PM::RedmineNotifier
@Panmind
Panmind / disable_javascript_helpers.rb
Created July 21, 2010 09:36
You already know: obtrusive Javascript is evil and clumsy
# Because obtrusive JavaScript is evil, and the Joe developer must not
# be able to introduce it with an "innocent" :method => :delete option
# passed to a link_to.
# (C) 2010 Panmind - Released in the Public Domain
#
helper = ActionView::Helpers::JavaScriptHelper
keep = %w(javascript_tag javascript_cdata_section escape_javascript)
keep.map!(&:to_sym) if RUBY_VERSION.to_f >= 1.9
methods = helper.public_instance_methods - keep
@Panmind
Panmind / agnostic_sql_helpers.rb
Created July 21, 2010 09:30
AR helpers to easily write different queries on different backends
# ActiveRecord extension adding a "query_for" instance method to write
# different queries on different backends and an "rs_to_ary" helper to
# bypass AR completely. The DBMS often does the job better than AR :-)
# (C) 2010 Panmind - Released under the terms of the Ruby License
#
module PM
module AgnosticSQLHelpers
# Initializes the helpers on ActiveRecord::Base.
#
def self.included(ar)
@Panmind
Panmind / thinking_sphinx_updates.rb
Created July 21, 2010 09:23
Thinking Sphinx extension to dynamically update Sphinx attributes
# Simple interface to access sphinx dynamic attribute updates feature
# from ActiveRecord instances. Spinned off from http://panmind.org/
# (C) 2010 Panmind - Released under the terms of the Ruby license.
#
module PM
module ThinkingSphinxUpdates
def self.included(base)
base.extend ClassMethods
end
@Panmind
Panmind / recaptcha.rb
Created June 6, 2010 09:12
ReCaptcha plugin for Rails -- obsoleted by http://github.com/Panmind/recaptcha
### This gist is obsoleted by the full plugin release:
### http://github.com/Panmind/recaptcha - check it out :-)
require 'timeout'
require 'mocha'
module PM
module Recaptcha
PrivateKey = 'your private key'
PublicKey = 'your public key'
@Panmind
Panmind / application_helper.rb
Created May 28, 2010 13:10
Zendesk dropbox and remote authentication plugin for Rails -- obsoleted by http://github.com/Panmind/zendesk
### This gist is obsoleted by the full plugin release:
### http://github.com/Panmind/zendesk - check it out :-)
module ApplicationHelper
include PM::Zendesk::Helpers
# .... more helpers ....
end