This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'net/sftp' | |
require 'faster_csv' | |
# Load our constants | |
host = "my.server.com" | |
user = "my_username" | |
password = "my_password" | |
port = 12345 | |
dirs_to_create = "dirs_to_create.txt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## vendor/extensions/database_form/app/models/database_form_page.rb | |
# Save form data | |
def save_form | |
form_response = FormResponse.new(:name => form_name) | |
form_response.content = form_data | |
if !form_response.save | |
@form_error = "Error encountered while trying to submit form. #{$!}" | |
false | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reorder(things, ids) | |
ordered_things = Array.new(things.size) | |
unless things.size == ids.size | |
(ids - (things.collect{|x| x.id})).collect{|missing| ids[ids.index(missing)] = nil} | |
ids = ids.compact | |
end | |
raise "Out of sync! Found #{ids.size} items in index, but only #{things.size} were found in database! Remove #{(ids - (things.collect{|x| x.id})).to_sentence}." unless things.size == ids.size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'open-uri' | |
require 'net/http' | |
require 'hpricot' | |
require 'atom/entry' | |
require 'atom/collection' | |
#Declare your variables | |
urls_to_import = "urls.txt" | |
wp_blog_host = "livinglife.sweetperceptions.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## a simple remarkable test script | |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |
describe Feedback, 'A Feedback instance' do | |
VALID = { | |
:name => "firstname lastname", | |
:email => "[email protected]", | |
:topic => "some topic", | |
:message => "some message" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Controller for Blackbook fix [ruby] | |
if (request.post?) or (!params["contact_type"].nil?) | |
#get contacts | |
@contacts = [] | |
@type = params["contact_type"] | |
if ["gmail", "yahoo", "hotmail", "aol"].include?(params["contact_type"]) | |
begin | |
username = "#{params["username"]}@#{params["contact_type"]}.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Think Geek Code (controller) [ruby] | |
def thinkGeek | |
require 'rss' | |
rss = RSS::Parser.parse(open('http://www.thinkgeek.com/xml/app/wishlist/id/').read, false) | |
@output = "" + rss.channel.description + "" | |
@output += "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def smiley(str) | |
str = str.sub(':)', "<img src='/images/emoticons/1.gif' alt='smile'/>") | |
str = str.sub(':(', "<img src='/images/emoticons/2.gif' alt='sad'/>") | |
str = str.sub(';)', "<img src='/images/emoticons/3.gif' alt='wink'/>") | |
str = str.sub(':D', "<img src='/images/emoticons/4.gif' alt='grin'/>") | |
str = str.sub(':P', "<img src='/images/emoticons/5.gif' alt='tongue'/>") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails g model StreamzooPhotos url:string | |
##lib/tasks/streamzoo.rake | |
require 'hpricot' | |
require 'open-uri' | |
namespace :streamzoo do | |
desc "refresh thumbnails" | |
task :update_thumbs => :environment do |
OlderNewer