This file contains 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
== SubUser | |
=== Creating client object: | |
client = SendGridWebApi::Client.new("user_name", "password") | |
client.sub_user | |
== Modules |
This file contains 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 'oauth' | |
require 'json' | |
module Yahoo | |
CONSUMER_KEY = "...." | |
CONSUMER_SECRET = "...." | |
class GeoLoc | |
def initialize(consumer_key = CONSUMER_KEY, consumer_secret = CONSUMER_SECRET) |
This file contains 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 'sendgrid_webapi' | |
require "fakeweb" | |
require 'vcr' | |
VCR.configure do |c| | |
c.cassette_library_dir = 'spec/cassettes' | |
c.hook_into :fakeweb | |
c.configure_rspec_metadata! | |
end |
This file contains 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
= SendGrid WEB API gem for Rails 3 | |
SendGrid WEB API gem allow you to retrieve information such as statistics, bounces, spam reports, unsubscribes, send email and other information. | |
== Rails 3 configuration | |
In your Gemfile: | |
gem 'sendgrid_webapi' |
This file contains 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
= SendGrid SMTP API gem for Rails | |
SendGrid SMTP API gem provides ActionMailer::Base extensions to use SendGrid API features in you emails. | |
It extends ActionMailer with next methods: | |
substitute(patters_string, array_of_substitunion_strings) | |
uniq_args(hash_of_unique_args) | |
category(category_string) | |
open_tracking(enabled = true) | |
add_filter_setting(filter_name, setting_name, value) |
This file contains 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
#test_helper.rb | |
....code.... | |
class ActionController::TestCase | |
include Devise::TestHelpers | |
end | |
....code.... | |
#test_integration_helper.rb | |
require File.expand_path("../../helper/test_helper", __FILE__) |
This file contains 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
$ git verify-pack -v .git/objects/pack/pack-4d5c6dc98db773d7df9c01d5d645ff954bfa2e49.idx | sort -k 3 -n | tail -3 | |
61cad2a1f34f09b77e127e0a7f0748917d7d5c78 blob 557568 555456 492171 | |
d655b4e185c0e2853bf946121cb96a55bc95bd65 blob 2436608 2435171 143444913 | |
3541fcf92467242889f0b5a574405650dc461341 blob 140146688 140186258 1644162 | |
$ git rev-list --objects --all | grep 3541fcf92 | |
3541fcf92467242889f0b5a574405650dc461341 pkg/youtube_it-1.2.7.gem |
This file contains 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
tmp_dir = "#{RAILS_ROOT}/tmp/" | |
original_file = "file.csv" | |
#create temporary dir | |
sh "mkdir #{tmp_dir}" | |
# create a temporary file containing the header without | |
# the content: | |
sh "head -n 1 #{original_file} > #{tmp_dir}/header.csv" | |
# create a temporary file containing the content without |
This file contains 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
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
tip "Ruby 1.9 supports named captures in regular expressions!" | |
p "hello 2011!".match(/(?<year>\d+)/)[:year] # => "2011" | |
tip "Ruby 1.9 uses Oniguruma as a new regex engine, and @pragprog has a fantastic (and free!) PDF on it: http://bit.ly/hIzvOi" | |
tip "Ruby 1.9 allows default arguments at the beginning of a method!" | |
def f(a=1, b); p [a,b]; end; | |
p f(2) # => [1, 2] |
This file contains 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
#monkey patch for duplicates | |
module Enumerable | |
def dups | |
inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys | |
end | |
end | |
== Usage | |
[1, 2, 3, 3].dups |