Skip to content

Instantly share code, notes, and snippets.

View seebq's full-sized avatar
💭
working on @Greenzie

Charles Brian Quinn seebq

💭
working on @Greenzie
View GitHub Profile
def cool_action
if request.get?
render :text => "You called a get, didn't you?"
elsif request.post?
render :text => "You're a poster, you big poster you."
elsif request.xhr?
render :text => "Oh, AJAX XMLHTTPrequesting. Aren't you special."
else
render :text => "Man, what is this a PUT? a DELETE? How utterly 2001!"
require 'test_helper'
class FishTest < ActiveSupport::TestCase
# Replace this with your real tests.
def test_fish_belongs_to_pond
pond = Pond.create!
fish = pond.fishes.create!()
assert pond.fishes.member?(fish) # works
fish = Fish.create(:pond => pond)
assert pond.fishes.reload.member?(fish) # Does not work
require 'test_helper'
class FishTest < ActiveSupport::TestCase
# Replace this with your real tests.
def test_fish_belongs_to_pond
pond = Pond.create!
fish = pond.fishes.create!()
assert pond.fishes.member?(fish) # works
fish = Fish.create(:pond => pond)
assert pond.fishes.reload.member?(fish) # Does not work
require File.dirname(__FILE__) + '/../test_helper'
class HebrewReversalTest < Test::Unit::TestCase
def setup
@single_line_string = "I should be reversed."
@multi_line_string = "I should be reversed. \nAnd I should too. \nAlong with me!"
end
# helper to reverse strings if the language is rtl
<lwp>
<xml>
<userLocs>http://community.sparkfly.local:3000/lwp/locations</userLocs>
<mechants>http://community.sparkfly.local:3000/lwp/merchants</mechants>
<mechantInfo>http://community.sparkfly.local:3000/lwp/merchant_info</mechantInfo>
<geocode>http://community.sparkfly.local:3000/lwp/geocode</geocode>
<nearcount>http://community.sparkfly.local:3000/lwp/nearcount</nearcount>
<nearbymerchants>http://community.sparkfly.local:3000/lwp/nearby_merchants</nearbymerchants>
<editLink>http://community.sparkfly.local:3000/my/preferences/lwp</editLink>
polyglot:newstorefront-sparkfly cbq$ git push
Counting objects: 27, done.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (16/16), 23.31 KiB, done.
Total 16 (delta 12), reused 0 (delta 0)
error: unable to create temporary sha1 filename ./objects/tmp_obj_CHVPmT: Permission denied
fatal: failed to write object
error: unpack failed: unpacker exited with error code
To git@github.com:sthiel/storefront-sparkfly.git
@seebq
seebq / gist:38110
Created December 19, 2008 20:34 — forked from anonymous/gist:38108
class User < ActiveRecord::Base
# Paperclip
has_attached_file :photo,
:styles => {
:thumb=> "100x100#",
:small => "150x150>",
:medium => "300x300>",
:large => "400x400>" }
# Some default enhancements/settings for IRB, based on
# http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks
unless defined? ETC_IRBRC_LOADED
# Require RubyGems by default.
require 'rubygems'
# Activate auto-completion.
require 'irb/completion'
$ irb
>> omar = ["a", "b", "c"]
=> ["a", "b", "c"]
>> omar.to_s
=> "abc"
>> class Array
>> def to_s
>> output = "I am an Array. I contain: "
>> self.each {|x| output += " element: #{x} " }
>> return output
# Simple way to process incoming emails in ruby
#
# Emails can be pretty complex with their attachments. For example:
#
# email
# alternatives
# text
# HTML
# attachment
#