Skip to content

Instantly share code, notes, and snippets.

View rsl's full-sized avatar
🏳️‍🌈
still a bad fish and free bird

Russell Norris rsl

🏳️‍🌈
still a bad fish and free bird
View GitHub Profile
## This will not raise an error
## This will merely give result you might not think
## [Happened to me by bad cut-and-paste]
self.foo = "foo",
self.bar = "bar",
self.baz = "baz"
require File.dirname(__FILE__) + '/../spec_helper'
describe Norman do
include ActionController::UrlWriter
before(:each) do
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
end
[15:48:37] <rsl> anyone understand why the API returns true for feed.publishUserAction but doesn't publish the feed? user enabled storys for the app.
[15:48:55] <stepcut> rsl: what size story?
[15:49:39] <rsl> the bundle has 2 sizes [one line and short story]. the api call returns true. all of nothing happens on the user's wall.
[15:50:09] <stepcut> rsl: has this code ever worked?
[15:50:34] <rsl> not sure what you mean by that... the api call returns true.
[15:50:39] <stepcut> rsl: let me rephrase. Was the code working, and then suddenly stopped? Or have you never had it working?
[15:51:31] <rsl> hrm... my code is calling the api. yes, my code works in that it calls the api. the api returns true for user.publishUserAction [instead of one of the multiple errors it has].
[15:51:38] <rsl> not sure what to answer there.
@rsl
rsl / snippet.txt
Created March 20, 2009 16:56 — forked from seivan/snippet.txt
class Person < ActiveRecord::Base
def self.find_recent
people = find(
:conditions => ["added_at > ? and deleted = ? and address is not null", Time.now.utc, false],
:order => "last_name, first_name")
end
# ...
end
# fuck.rb
require "rubygems"
require "rack"
class Fuck
puts "class definition loaded"
def new
puts "initialized instance"
end
describe "PUT /password_resets/update" do
before(:each) do
@user = mock_model(User)
User.stub!(:find).and_return(@user)
end
describe "when successful" do
before(:each) do
@user.stub!(:update_attributes).and_return(true)
end
>> "test [two]".gsub(/(\[)/, '\1')
=> "test [two]"
>> "test [two]".gsub(/(\[)/, '\\1')
=> "test [two]"
>> "test [two]".gsub(/(\[)/, '\\\1')
=> "test \\1two]"
# Replacement for Rails' default button_to helper
# using HTML button element rather than HTML input element
def button_to(name, options = {}, html_options = {})
html_options = html_options.stringify_keys
convert_boolean_attributes!(html_options, %w( disabled ))
method_tag = ''
if (method = html_options.delete('method')) && %w{put delete}.include?(method.to_s)
method_tag = tag('input', :type => 'hidden', :name => '_method', :value => method.to_s)
end
var select_string = "";
var select_string_last_updated = 0;
var select_options_hash = new Hash();
var select_options_hash_keys = new Array();
function initialize_select_data() {
$$("#indented_select_target option").each(function(el){
without_indents = el.value;
select_options_hash.set(el.value, el.id);
})
module Bar
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def bar
puts "bar's bar"
end
end