Skip to content

Instantly share code, notes, and snippets.

Robin Percy rbnpercy

Block or report user

Report or block rbnpercy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gosyntax.go
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
for i := 0; i < 10; i++ {
View clojure-threads.clj
(ns async-example.core
(:require [clojure.core.async :refer :all])
(:gen-class))
(defn -main [& args]
(doseq [i (range 10)]
(go
(Thread/sleep (rand-int 1000))
(println i)))
View rabbit_consumer.rb
require "rubygems"
require "bunny"
require "json"
# Returns a connection instance
conn = Bunny.new ENV['CLOUDAMQP_URL']
# The connection will be established when start is called
conn.start
# Create a channel in the TCP connection
View rabbit_publisher.rb
require "rubygems"
require "bunny"
require "json"
# Returns a connection instance
conn = Bunny.new ENV['CLOUDAMQP_URL']
# The connection will be established when start is called
conn.start
# create a channel in the TCP connection
View kafka_producer.rb
require "kafka"
logger = Logger.new($stderr)
brokers = ENV.fetch("KAFKA_BROKERS")
# Make sure to create this topic in your Kafka cluster or configure the
# cluster to auto-create topics.
topic = "text"
kafka = Kafka.new(
View kafka_consumer.rb
require "kafka"
# We don't want log output to clutter the console. Replace `StringIO.new`
# with e.g. `$stderr` if you want to see what's happening under the hood.
logger = Logger.new(StringIO.new)
brokers = ENV.fetch("KAFKA_BROKERS").split(",")
# Make sure to create this topic in your Kafka cluster or configure the
# cluster to auto-create topics.
View irommq.json
curl -X PUT -H "Authorization: OAuth TOKEN" -H "Content-Type: application/json" \
-d '{
"queue" : {
"type": "multicast",
"push": {
"subscribers": [
{"name": "some-url", "url": "https://example.com/accept/notification/here"},
{"name": "worker-url", "url": "ironworker://my-project:xxxxx@xxxxx/process-data"}
],
"retries": 5,
View photo_controller.ex
def store(conn, file, album) do
case Images.create_photo(%{album_id: album, image: file}) do
{:ok, photo} ->
header = [{"Content-Type", "application/json"}]
body = "{\"height\": \"250\", \"width\": \"250\", \"bucket\": \"#{album_id}\" }"
HTTPotion.post("https://worker-aws-us-east-1.iron.io/2/projects/{Project ID}/tasks", [body: body, headers: header])
conn
|> put_flash(:info, "Photos created successfully.")
View imageproc.rb
require_relative 'bundle/bundler/setup'
require 'iron_worker'
require "mini_magick"
require 'aws-sdk'
require 'uri'
Aws.config.update({
region: 'us-east-1',
credentials: Aws::Credentials.new('AWS_KEY', 'SECRET')
View show.html.eex
<h2><%= @album.name %></h2>
<ul>
<%= for photo <- @album.photos do %>
<li>
<img src=<%= "https://s3.amazonaws.com/#{photo.album_id}/" <> photo.image %> />
</li>
<% end %>
</ul>
You can’t perform that action at this time.