Skip to content

Instantly share code, notes, and snippets.

View akinsgre's full-sized avatar

Greg Akins akinsgre

View GitHub Profile
it "should return Saved when passed params" do
post :update, :content => {"content", "Seniors"}
response.should contain("Saved")
end
if (NON_NEGATIVE.containsInteger(startRecord)
&& NON_NEGATIVE.containsInteger(endRecord)
&& olbRequest.isDirtyFlag())
{
String orderBy = olbRequest.getOrderBy();
if (NON_NEGATIVE.containsInteger(categoryId)
&& customerId != null)
{
results = getAcctHistoryByCategory(tpc, startDate, endDate, orderBy, startRecord, endRecord, categoryId, customerId, aid);
class CommentsController < ApplicationController
include UrlHelper
OPEN_ID_ERRORS = {
:missing => "Sorry, the OpenID server couldn't be found",
:canceled => "OpenID verification was canceled",
:failed => "Sorry, the OpenID verification failed" }
before_filter :find_post, :except => [:new]
def index
def authenticate_with_open_id(identifier = nil, options = {}, &block) #:doc:
raise "Test"
OpenID::Util.logger.info "Authenticating with open id" + identifier
identifier ||= open_id_identifier
if request.env[Rack::OpenID::RESPONSE]
complete_open_id_authentication(&block)
else
begin_open_id_authentication(identifier, options, &block)
end
@akinsgre
akinsgre / test.html
Created August 19, 2011 13:34
Assigning click events to dynamically loaded content.
<html>
<head>
<script src="javascripts/jquery-1.6.2.js" type="text/javascript" ></script>
<script type="text/javascript">
$(function() {
$('input').click(function(event) {
alert("This worked ..." + event.type);
});
$("#content").html("<input type='button' value='Loaded later'/>");
});
@akinsgre
akinsgre / Thing.java
Created August 19, 2011 14:49
Java object for DynaTree
public class Thing {
private String title ;
private List<Thing> children ;
public Thing(String title) { this.title = thing );
// getters and settors accordingly
}
List<Thing> things = new ArrayList<Thing>() ;
things.add(new Thing("One"));
@akinsgre
akinsgre / test.rb
Created September 2, 2011 13:38
JSON generation
#ruby 1.9.2
require 'json'
class Item
def initialize(name, description )
@name = name
@description = description
end
def to_json(*a)
{"name" => @name, "description" => @description}.to_json(*a)
@akinsgre
akinsgre / gist:1405687
Created November 29, 2011 17:46
Trouble getting routes & link_to working
routes.rb
=================
resources :groups do
member do
post 'join'
put 'add_contact'
end
end
When I do "bundle exec rake routes" I get "add_contact_group" -> /groups/:id/add_contact
@akinsgre
akinsgre / form_for.rb
Created December 8, 2011 14:29
Problems with Rails form_for tag
#This form "should" create a new contact and a new group_contact record. What I really
# want to do is to add an existing contact to a group. But can't figure out
# how to build a form_for that will let me do that.
#
# If I were creating my own form, I'd just put the group_id in a hidden field and let
# the user pick a contact from a select. Then I'd post to a groups_controller
# to add the contact to group.contacts.
#
# I'm just not seeing how to do that in a form_for
#
class ContactMethod < ActiveRecord::Base
validates_presence_of :name
def self.select_options
descendants.map { |c| c.to_s }.sort
end
end
class Phone < ContactMethod
end