Skip to content

Instantly share code, notes, and snippets.

View mod_set_presence_rest.lua
-- Recive a HTTP POST and relay it
-- Author: Waqas Hussain
-- Derived from mod_post_msg by Kim Alvefur <zash@zash.se>
-- Some code borrowed from mod_webpresence
--
-- Example usage:
-- curl http://example.com:5280/presence/user -d "Hello there"
-- or
-- curl http://example.com:5280/presence/user@example.com -d "Hello there"
@jamesgecko
jamesgecko / session_controller.rb
Created Apr 28, 2011
In which James learns that redirect_to is not instant.
View session_controller.rb
class SessionController < ApplicationController
def index_attempt_one
if !session[:unset_key]
redirect_to :action => 'login'
end
# Anything here gets executed too! D-:
end
def index_attempt_two
if !session[:unset_key]
View gist:959846
NoMethodError in Support_calls#new
Showing c:/Users/james/code/support/app/views/support_calls/_form.html.erb where line #28 raised:
undefined method `resolved' for #<SupportCall:0x1254fcd>
Extracted source (around line #28):
25: </div>
26: <div class="checkbox">
View controllers - support_calls_controller.rb
class SupportCallsController < ApplicationController
def new
@support_call = SupportCall.new
@customers = Customer.all
end
def create
@support_call = SupportCall.new(params[:support_call])
respond_to do |format|
View Error
NoMethodError in Support callsController#new
undefined method `set_employee_id' for #<SupportCall:0x7740f6>
Rails.root: c:/Users/denton/code/billing
Application Trace | Framework Trace | Full Trace
app/controllers/support_calls_controller.rb:4:in `new'
Request
@jamesgecko
jamesgecko / gist:964581
Created May 10, 2011
rails generate migration error
View gist:964581
c:\Users\james\code\test>rails generate migration RemoveDateCalled
NoMethodError: undefined method `[]=' for nil:NilClass
Application at c:/Users/james/code/test/config/application.rb:43
Test at c:/Users/james/code/test/config/application.rb:10
(root) at c:/Users/james/code/test/config/application.rb:9
require at org/jruby/RubyKernel.java:1038
(root) at c:/Users/james/code/test/config/application.rb:15
require at org/jruby/RubyKernel.java:1038
(root) at script/rails:6
View gist:965439
<h1><%= session[:employee_first_name] %>'s call queue</h1>
<%= @foo %>
<ul>
<% last_date = '' %>
<% @employee.support_calls.reverse.each do |call| %>
<% date = call.created_at.strftime('%x') %>
<% if last_date != date %>
<div class="date"><%= date %></div> The date should only appear when it's different from the last one.
<% end %>
<li><%= link_to call.customer.name + ' - ' + call.caller + ' - ' + call.problem.truncate(32), edit_support_call_path(call) %></li>
View app_controllers_vehicle_controller.rb
class VehiclesController < ApplicationController
# GET /vehicles
def index
@vehicles = Vehicles.all
end
end
@jamesgecko
jamesgecko / error
Created May 31, 2011
dm-sqlserver-adapter bug
View error
>jruby test-dm.rb
Connecting with DataMapper
DataObjects::URI.new with arguments is deprecated, use a Hash of URI components
(C:/dev/jruby-1.6.2/lib/ruby/gems/1.8/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:231:in `normalized_uri')
NoMethodError: undefined method `blank?' for "":String
select_statement at C:/dev/jruby-1.6.2/lib/ruby/gems/1.8/gems/dm-sqlserver-adapter-1.1.0/lib/dm-sqlserver-adapter/adapter.rb:48
read at C:/dev/jruby-1.6.2/lib/ruby/gems/1.8/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:137
read at C:/dev/jruby-1.6.2/lib/ruby/gems/1.8/gems/dm-core-1.1.0/lib/dm-core/repository.rb:162
lazy_load at C:/dev/jruby-1.6.2/lib/ruby/gems/1.8/gems/dm-core-1.1.0/lib/dm-core/collection.rb:1117
each at C:/dev/jruby-1.6.2/lib/ruby/gems/1.8/gems/dm-core-1.1.0/lib/dm-core/support/lazy_array.rb:409
View auth_test.py
from twisted.web.server import Site
from twisted.web.resource import Resource, IResource
from twisted.internet import reactor, task
class Customer(Resource):
def __init__(self, customer_id=100):
Resource.__init__(self, customer_id)
self.customer_id = customer_id
def render_GET(self, request):