Skip to content

Instantly share code, notes, and snippets.

View taylor's full-sized avatar
🐢
🌊

Taylor Carpenter taylor

🐢
🌊
View GitHub Profile
@taylor
taylor / adhearsion_outgoing_call.rake
Created September 13, 2011 12:11 — forked from cloudvoxcode/adhearsion_outgoing_call.rake
place & receive a phone call with Ruby (Adhearsion)
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
require 'adhearsion'
require 'adhearsion/initializer/asterisk'
require 'drb'
# http://help.cloudvox.com/faqs/getting-started/setup-for-ruby-adhearsion
desc "Make an outgoing phone call to number provided as 'call' (via Cloudvox)"
task :make_outgoing_call do
if ENV['call']
# Outgoing context from Cloudvox Switchboard, under "Outgoing settings (AMI)."
@taylor
taylor / x
Created September 15, 2011 05:10
mac="0800273B51A9"
# With reject
mac.split(/(..)/).reject {|c| c.empty?}.join(':')
# With Inject
mac.split(//).inject([]) do |nmac, e|
if x.nil? or x>0
nmac[nmac.size-1] = nmac[nmac.size-1] + e
def self.new(element_name, atts = {}, &block)
blk_proc = Proc.new do |new_node|
atts.each_pair { |k, v| new_node.send :"#{k}=", v }
block_return = new_node.instance_eval &block if block_given?
new_node << new_node.encode_special_chars(block_return) if block_return.is_a?(String)
end
case RUBY_VERSION.split(/\./)[0,2].join.to_i
when 18
super(element_name).tap do |n|
def self.new(element_name, atts = {}, &block)
blk_proc = Proc.new do |new_node|
atts.each_pair { |k, v| new_node.send :"#{k}=", v }
block_return = new_node.instance_eval &block if block_given?
new_node << new_node.encode_special_chars(block_return) if block_return.is_a?(String)
end
case RUBY_VERSION.split(/\./)[0,2].join.to_i
when 18
super(element_name).tap do |n|
case RUBY_VERSION.split(/\./)[0,2].join.to_i
when 18
super(element_name).tap do |new_node|
atts.each_pair { |k, v| new_node.send :"#{k}=", v }
block_return = new_node.instance_eval &block if block_given?
new_node << new_node.encode_special_chars(block_return) if block_return.is_a?(String)
end
else
super(element_name) do |new_node|
atts.each_pair { |k, v| new_node.send :"#{k}=", v }
@taylor
taylor / ahn
Created October 21, 2011 21:56
# This command will automatically be run when you run "ahn" with the Adhearsion gem installed from the root of your application.
require File.expand_path('../../config/environment', __FILE__)
require 'adhearsion'
require 'adhearsion/commands'
Adhearsion::CLI::AhnCommand.execute!
@taylor
taylor / gist:1305114
Created October 21, 2011 22:12
no cli_commands in Develop branch of Adhearsion after clone
taylor@lindqvist:src $ rm -rf adhearsion
taylor@lindqvist:src $ git clone git@github.com:mojolingo/adhearsion.git
Cloning into adhearsion...
remote: Counting objects: 10660, done.
remote: Compressing objects: 100% (2883/2883), done.
remote: Total 10660 (delta 7771), reused 10422 (delta 7534)
Receiving objects: 100% (10660/10660), 2.14 MiB | 1.26 MiB/s, done.
Resolving deltas: 100% (7771/7771), done.
taylor@lindqvist:src $ cd adhearsion
taylor@lindqvist:adhearsion $ git branch
#####
#
# $ git checkout --track -b <local name> origin/<remote name>
# Note: this creates a local branch <local name> based on the upstream branch and switches your working copy to that branch.
#
# Push a local branch remotely with this
#
# git push some_repo local_branch:refs/heads/new_branch
# example
# git push origin master:refs/heads/staging will create the branch staging in the origin repository by copying the local master branch
@taylor
taylor / gist:1322499
Created October 28, 2011 15:11
rake niceogiri
/Users/taylor/sw/depot/rvm/rubies/jruby-1.6.4/bin/jruby -I"lib:lib:spec" -I"/Users/taylor/sw/depot/rvm/gems/jruby-1.6.4@mojolingo/gems/rake-0.9.2.2/lib" "/Users/taylor/sw/depot/rvm/gems/jruby-1.6.4@mojolingo/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "spec/**/*_spec.rb"
Loaded suite /Users/taylor/sw/depot/rvm/gems/jruby-1.6.4@mojolingo/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
F.FE.........E.F....EFE............
Finished in 1.082000 seconds.
1) Failure:
test_0014_will_remove_a_child_with_a_specific_xmlns(NiceogiriXmlNodeSpec) [/Users/taylor/work/src/clients/mojolingo/niceogiri/spec/niceogiri/xml/node_spec.rb:108]:
Expected 1, not 2.
@taylor
taylor / gist:1322502
Created October 28, 2011 15:12
bundle exec rspec spec on niceogiri
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Failures:
1) Nokogiri::XML::Node aliases #name to #element_name
Failure/Error: node.must_respond_to :element_name
NameError:
uninitialized class variable @@current_spec in MiniTest::Spec
# (eval):6:in `must_respond_to'
# ./spec/niceogiri/core_ext/nokogiri_spec.rb:8:in `(root)'