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 'scamp' | |
scamp = Scamp.new(:api_key => "YOUR API KEY", :subdomain => "yoursubdomain", :verbose => true) | |
scamp.behaviour do | |
# Simple matching based on regex or string: | |
match "ping" do | |
say "pong" | |
end | |
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
class Scamp | |
def say str | |
puts "BOT: #{str.inspect}" | |
end | |
def behaviour &block | |
instance_eval(&block) | |
end | |
def plugin klass |
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 'scamp/plugin' | |
class MyPlugin < Scamp::Plugin | |
match /^ping$/, :say_pong | |
def say_pong context, msg | |
context.say "pong" | |
end | |
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
class TestAdapter < Scamp::Adapter | |
class Context | |
def say msg | |
puts msg | |
end | |
end | |
def connect! | |
EventMachine::PeriodicTimer.new(@opts[:delay]) do | |
msg = Scamp::Message.new(self, :body => "help") |
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
Scamp.new do |bot| | |
bot.adapter :test, TestAdapter, :delay => 1 | |
bot.adapter :another, TestAdapter, :delay => 5 | |
bot.plugin PingPlugin, :on => [:test] | |
bot.connect! | |
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
jQuery -> | |
$('#password_prompt_form').submit (e) -> | |
$.post(this.action, { passcode: $('#passcode').val() }) -> | |
$('#passcode_response').html(data) | |
e.preventDefault() |
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
$ bin/shef | |
Loading Node Data | |
Ohai2u! | |
chef > recipe | |
=> :recipe | |
chef:recipe > file "/tmp/foo" | |
=> #<Chef::Resource::File:0x1c3cd2c @provider=nil, @not_if=nil, @params={}, @recipe_name=nil, @action="create", @source_line="/Users/danielsdeleo/ruby/shef/(irb) line 2", @actions={}, @ignore_failure=false, @name="/tmp/foo", @cookbook_name=nil, @enclosing_provider=nil, @resource_name=:file, @before=nil, @supports={}, @backup=5, @allowed_actions=[:nothing, :create, :delete, :touch, :create_if_missing], @path="/tmp/foo", @only_if=nil, @noop=nil, @updated=false, @node=eigenstate.local, @collection=#<Chef::ResourceCollection:0x1c4f328 @insert_after_idx=nil, @resources=[#<Chef::Resource::File:0x1c3cd2c ...>], @resources_by_name={"file[/tmp/foo]"=>0}>> | |
chef:recipe > run_chef | |
[Tue, 03 Nov 2009 22:16:27 -0700] DEBUG: Processing file[/tmp/foo] | |
[Tue, 03 Nov 2009 22:16:27 -0700] DEBUG: file[/tmp/foo] using Chef::Provider::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
ActionView::Template::Error (can't dump anonymous class Class): | |
1: <h3>Rack request env</h3> | |
2: <h3>Rails request object</h3> | |
3: <pre><%= h(@request_obj.to_yaml).gsub(" ", " ").html_safe %></pre> | |
app/views/headers/index.html.erb:3:in `_app_views_headers_index_html_erb___1006215901_77896010__270781548' |
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
Foursquare *foursquare = [[Foursquare alloc] initWithAccessToken:accessToken]; | |
[foursquare getUserwithCallback:^(BOOL success, id result){ | |
if (success) { | |
NSLog(@"%@", (NSDictionary*)result); | |
} else { | |
NSLog(@"%@", [(NSError *)result localizedDescription]); | |
} | |
}]; |
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
on_app_servers do | |
run("mkdir -p #{shared_path}/config/thinkingsphinx") | |
run("ln -nfs #{shared_path}/config/thinkingsphinx #{release_path}/config/thinkingsphinx") | |
end |