Skip to content

Instantly share code, notes, and snippets.

View treeder's full-sized avatar
🥌

Travis Reeder treeder

🥌
View GitHub Profile
@treeder
treeder / find.rb
Created September 6, 2012 19:00 — forked from jpsilvashy/find()
Snippets from IronCache blog post
def self.find(name)
@name = name
@messages = JSON.parse(settings.ironcache.cache(@name).get('messages').value)
Channel.new(@name, @messages)
end
@treeder
treeder / call.rb
Created September 27, 2012 22:12
Scheduling with Twilio blog post samples
@call = @client.account.calls.create(
:from => '+14159341234',
:to => '+18004567890',
:url => 'http://example.com/call-handler'
)
{"host":"smtp.sendgrid.net", "domain":"MY DOMAIN eg: yahoo.com", "port":587, "username":"MY USERNAME", "password":"MY PASSWORD", "from":"MY EMAIL", "to":"EMAIL TO SEND TO", "subject":"SUBJECT", "body":"BODY"}
@treeder
treeder / get_github_message.rb
Created December 31, 2012 22:02
For IronMQ webhooks blog post.
require 'rest'
rest = Rest::Client.new
response = rest.get("https://mq-aws-us-east-1.iron.io/1/projects/MY_PROJECT_ID/queues/github-webhook-queue/messages?oauth=MY_TOKEN")
# Parse IronMQ json
parsed = JSON.parse(response.body)
raise "No message found!" if parsed['messages'].length == 0
parsed['messages'].each do |m|
curl -H "Authorization: OAuth TOKEN" -H "Content-Type: application/json" \
-d '{"push_type":"multicast", "subscribers": [{"url": "http://mysterious-brook-1807.herokuapp.com/ironmq_push_1"}, {"url": "http://mysterious-brook-1807.herokuapp.com/ironmq_push_2"}], "error_queue": "pushq-demo-1-errors"}' \
"https://mq-aws-us-east-1.iron.io/1/projects/PROJECT_ID/queues/pushq-demo-1"
curl -H "Content-Type: application/json" -H "Authorization: OAuth TOKEN" \
-d '{"messages":[{"body":"hello world!"}]}' \
"http://mq-aws-us-east-1.iron.io/1/projects/PROJECT_ID/queues/pushq-demo-1/messages"
curl -H "Authorization: OAuth TOKEN" -H "Content-Type: application/json" \
"http://mq-aws-us-east-1.iron.io/1/projects/PROJECT_ID/queues/pushq-demo-1/messages/MESSAGE_ID/subscribers"
{"subscribers":[
{
"retries_delay":60,
"retries_remaining":2,
"status_code":200,
"status":"deleted",
"url":"http://mysterious-brook-1807.herokuapp.com/ironmq_push_2",
"id":"5831237764476661217"
},{
"retries_delay":60,
{
"ids":["5831237764476661216"],
"msg":"Messages put on queue."
}
@treeder
treeder / queue_subscribers.json
Last active December 20, 2015 02:58
For Fan out post
{
"subscribers": [
{"url": "ironmq:///q2"},
{"url": "ironmq:///q3"},
{"url": "ironmq:///q4"},
{"url": "ironworker:///my_awesome_worker"},
{"url": "http://my.domain.com/do_some_action"}
]
}