Skip to content

Instantly share code, notes, and snippets.

View dmitryck's full-sized avatar

dmitryck dmitryck

  • krasava
View GitHub Profile
@dmitryck
dmitryck / chat.rb
Created December 19, 2020 16:09 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@dmitryck
dmitryck / gist:e11453bbc92eb9cbb2108be602de4fcc
Created September 8, 2020 13:08 — forked from tmm1/gist:329682
EM Chat Server Demo
require 'rubygems'
require 'eventmachine'
require 'em-http' # gem install em-http-request
require 'yajl' # gem install yajl-ruby
class String
def bold
"\033[1m#{self}\033[0m"
end
end
class MirandaService::ActualData
attr_reader :contacts
attr_reader :new_data
attr_reader :renamed_data
attr_reader :old_data
attr_reader :actual_contacts
attr_reader :new_contacts
@dmitryck
dmitryck / hash_by_path.rb
Last active February 1, 2019 08:20
Path-like accessing to hash nodes
TARGET = 4
INPUT = {
a: {
b: {
c: TARGET
}
}
}