Skip to content

Instantly share code, notes, and snippets.

View carimura's full-sized avatar

Chad Arimura carimura

  • San Francisco, CA
View GitHub Profile
@carimura
carimura / iron_mailer.rb
Created June 11, 2012 19:42
workers/iron_mailer.rb
# We included ActionMailer and our mailer models in the code package
# in the last step, but we still need to require them in our worker file.
require 'active_support/core_ext'
require 'action_mailer'
require 'models/mailer'
# Parse our config yaml file
config = YAML.load_file("settings.yml")
# A nifty Ruby line to set the AM settings from our loaded yaml file
@carimura
carimura / settings.yml
Created June 11, 2012 19:48
config/settings.yml
sendgrid:
address: "smtp.sendgrid.net"
port: '25'
authentication: :plain
domain:
user_name:
password:
@carimura
carimura / iron.json
Created June 11, 2012 19:52
workers/.iron.json
{
"token":"YOUR_TOKEN",
"project_id":"YOUR_PROJECT_ID"
}
@carimura
carimura / gist:3120905
Created July 16, 2012 05:51
Worker Callback URL
https://worker-aws-us-east-1.iron.io/2/projects/{PROJECT_ID}/tasks/webhook?code_name=TwilioWebhook&oauth={TOKEN}
worker_client.schedules.create('SendInsanity',
{
:number => number,
:config => worker_client.api.options
},
{
:start_at => Time.now,
:run_times => 5,
:run_every => 60
})
# Scheduling a task to be queued at a specific time (eg. 1 hour from now)
schedule = client.schedules.create('MyWorker', payload,
{:start_at => Time.now + 3600})
# Running a task repeatedly (eg. every hour)
schedule = client.schedules.create('MyWorker', payload,
{:run_every => 3600})
# Scheduling a task to run until a certain time (eg. run 3 hours then stop)
schedule = client.schedules.create('MyWorker', payload,
puts "Starting HelloWorker at #{Time.now}"
puts `curl http://ec2-184-72-163-60.compute-1.amazonaws.com --connect-timeout 10`
puts "done"
from tasks import add
import time
start=time.time()
for i in range(1000):
add.delay(1,i)
print "queued job %x" % (i)
print "finished in %x seconds" % (time.time() - start)
@carimura
carimura / tasks.py
Last active December 12, 2015 03:48
from celery import Celery
import iron_celery
celery = Celery('tasks', broker='amqp://guest@localhost//')
@celery.task
def add(x, y):
return x + y
@carimura
carimura / celery.py
Last active December 12, 2015 03:48
from celery import Celery
import iron_celery
celery = Celery('tasks',
broker='ironmq://{iron_project_id}:{iron_token}@')
@celery.task
def add(x, y):
return x + y