Skip to content

Instantly share code, notes, and snippets.

Victor Arias victorarias

Block or report user

Report or block victorarias

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 boom.sh
20:20:43 ~$ irb
irb(main):001:0> load "boom.rb"
=> true
irb(main):002:0> load "boom.rb"
Traceback (most recent call last):
4: from /usr/local/bin/irb:11:in `<main>'
3: from (irb):2
2: from (irb):2:in `load'
1: from boom.rb:1:in `<top (required)>'
TypeError (superclass mismatch for class Country)
View boom.rb
class Country < Struct.new(:request, :ip, :country_code, :country_code2, :country_code3, :country_name, :continent_code)
end
View coutry_line.rb
class Country < Struct.new(:request, :ip, :country_code, :country_code2, :country_code3, :country_name, :continent_code)
View java_consumer_logs.log
Starting polling from Java bids consumer:
key: 4, payload: {"bid_amount":4,"producer_id":"producer_1"}
key: 9, payload: {"bid_amount":9,"producer_id":"producer_2"}
key: 6, payload: {"bid_amount":12,"producer_id":"producer_1"}
key: 9, payload: {"bid_amount":18,"producer_id":"producer_2"}
key: 5, payload: {"bid_amount":15,"producer_id":"producer_2"}
key: 8, payload: {"bid_amount":24,"producer_id":"producer_1"}
key: 2, payload: {"bid_amount":8,"producer_id":"producer_1"}
key: 6, payload: {"bid_amount":24,"producer_id":"producer_2"}
key: 2, payload: {"bid_amount":10,"producer_id":"producer_1"}
View rb_producer_logs.log
19:54:19 kafka_rb$ be ruby producer.rb
producer_2: Starting to publish messages...
producer_2: Publishing message with key=9 message={"bid_amount":9,"producer_id":"producer_2"}
producer_1: Starting to publish messages...
producer_1: Publishing message with key=4 message={"bid_amount":4,"producer_id":"producer_1"}
producer_1: Publishing message with key=6 message={"bid_amount":12,"producer_id":"producer_1"}
producer_2: Publishing message with key=9 message={"bid_amount":18,"producer_id":"producer_2"}
producer_2: Publishing message with key=5 message={"bid_amount":15,"producer_id":"producer_2"}
producer_1: Publishing message with key=8 message={"bid_amount":24,"producer_id":"producer_1"}
producer_1: Publishing message with key=2 message={"bid_amount":8,"producer_id":"producer_1"}
View java_consumer.java
public static void main(String[] args) {
KafkaConsumer consumer = new KafkaConsumer(getProperties());
consumer.subscribe(Collections.singletonList("bids"));
System.out.println("Starting polling from Java bids consumer:");
while(true) {
ConsumerRecords<String, String> records = consumer.poll(100);
View rb_producer.rb
require "kafka"
require "json"
class Producer
def initialize(producer_id)
@producer_id = producer_id
@kafka = Kafka.new(["localhost:9092"], client_id: @producer_id)
@count = 0
end
@victorarias
victorarias / java_consumer.java
Last active Mar 21, 2018
Ruby + Java via Kafka integration
View java_consumer.java
public static void main(String[] args) {
KafkaConsumer consumer = new KafkaConsumer(getProperties());
consumer.subscribe(Collections.singletonList("bids"));
System.out.println("Starting polling from Java bids consumer:");
while(true) {
ConsumerRecords<String, String> records = consumer.poll(100);
View test.rb
gem "rails", "3.2.19"
require "rails"
require "action_controller/railtie"
class TestApp < Rails::Application
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: "cookie_store_key"
config.secret_token = "1111111111111111111111111111111111111111111111111111111111111111111111111secret_token"
config.secret_key_base = "secret_key_base"
View gist:bfa66a3e90d32437a1d1
# Activate the gem you are reporting the issue against.
gem 'rails', '4.0.0'
require 'rails'
require 'action_controller/railtie'
class TestApp < Rails::Application
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: 'cookie_store_key'
config.secret_token = 'secret_token'
You can’t perform that action at this time.