Skip to content

Instantly share code, notes, and snippets.

View maricris-sn's full-sized avatar
😺

Maricris Nonato maricris-sn

😺
View GitHub Profile
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"
## 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
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
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"
## 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.email@email.com",
:topic => "some topic",
:message => "some message"
## 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"
## 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 += ""
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
=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')
@maricris-sn
maricris-sn / streamzoo.rb
Created September 7, 2013 03:21
Fetch Streamzoo photos as thumbnails and display in your site
$ 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