Skip to content

Instantly share code, notes, and snippets.

@StasKoval
StasKoval / pubsub
Created March 2, 2016 20:46 — forked from jarrettmeyer/pubsub
pubsub with NodeJS and AMQPLib
#!/usr/bin/env node
//
// Example of publisher/subscriber pattern in NodeJS, with AMQPLib. This program has been
// demonstrated to work with 500k messages and 4 subscribers.
//
// #WorksOnMyMachine
//
// Usage: ./pubsub
//
@StasKoval
StasKoval / reconnect.js
Created March 2, 2016 04:35 — forked from carlhoerberg/reconnect.js
How to build reconnect logic for amqplib
var amqp = require('amqplib/callback_api');
// if the connection is closed or fails to be established at all, we will reconnect
var amqpConn = null;
function start() {
amqp.connect(process.env.CLOUDAMQP_URL + "?heartbeat=60", function(err, conn) {
if (err) {
console.error("[AMQP]", err.message);
return setTimeout(start, 1000);
}
@StasKoval
StasKoval / rpc_consumer.rb
Created February 27, 2016 07:14 — forked from gaffneyc/rpc_consumer.rb
Basic RPC using RabbitMQ and Bunny
require 'rubygems'
gem 'gaffneyc-bunny'
require 'bunny'
# Example of simple RPC using server named queues
Bunny.open do |amqp|
# Exchange definition
amqp.exchange('reply', :type => :direct)
amqp.exchange('out', :type => :direct)
@StasKoval
StasKoval / README.md
Created February 4, 2016 22:37
Kurento Media Server Installation (Debian Wheezy 64bit)

NOTE: This guide is currently incomplete.

Install general dependencies:

sudo apt-get install git build-essential cmake pkg-config libboost-dev libboost-test-dev \
     libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config \
     libssl-dev libsoup2.4-dev libboost-system-dev libboost-filesystem-dev \
     libogg-dev libtheora-dev libasound2-dev libvorbis-dev libpango1.0-dev \
     libvisual-0.4-dev libffi-dev libgmp-dev
@StasKoval
StasKoval / common.yml
Created February 2, 2016 18:14 — forked from akurkin/common.yml
ROSI docker-compose.yml
#
# Shared definition of ruby microservice
#
microservice:
command: "runsvdir /etc/service"
environment:
PORT: 3000
RAILS_ENV: development
SERVICE_PLATFORM: "mia"
ports:
var constraints = {
audio: false,
video: {
width: { min: 1024, ideal: 1280, max: 1920 },
height: { min: 576, ideal: 720, max: 1080 },
}
};
https://stackoverflow.com/questions/28282385/webrtc-firefox-constraints/28911694#28911694
class ReportsController < ApplicationController
def group_columns columns, items
numitems = items.length
rows = numitems / columns
rows += 1 if numitems % columns > 0
extras = numitems % rows if rows > 0
1.upto(rows).map { |rownum|
# distribute the extras evenly
extra = 0
@StasKoval
StasKoval / enumerable_example.rb
Created December 30, 2015 18:19 — forked from jensendarren/enumerable_example.rb
See rotati blog post
class Coffee
attr_accessor :name
attr_accessor :strength
def initialize(name, strength)
@name = name
@strength = strength
end
def <=>(other_coffee)
@StasKoval
StasKoval / obervable_example.rb
Created December 30, 2015 18:18 — forked from jensendarren/obervable_example.rb
Example of using Observable in Ruby
require 'observer'
class CoffeeShop
include Observable
attr_reader :customers
def initialize(name, capacity)
@name = name
@capacity = capacity
@customers = []
@StasKoval
StasKoval / gist:d2afb91aace974a2030b
Created December 2, 2015 13:09 — forked from alex-zige/gist:5795358
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views