Skip to content

Instantly share code, notes, and snippets.

Alexander Emelin FZambia

Block or report user

Report or block FZambia

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
@FZambia
FZambia / bench.go
Created Mar 19, 2019
Gorilla Websocket Upgrade Benchmark
View bench.go
func BenchmarkUpgrade(b *testing.B) {
br := bufio.NewReaderSize(strings.NewReader(""), 4096)
bw := bufio.NewWriterSize(&bytes.Buffer{}, 4096)
upgrader := Upgrader{
ReadBufferSize: 0,
WriteBufferSize: 0,
}
resp := &reuseTestResponseWriter{
brw: bufio.NewReadWriter(br, bw),
@FZambia
FZambia / index.html
Last active Jun 5, 2019
Centrifuge library Habr example
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- Обратите внимание, что клиент тут импортируется из ветки c2 репозитория centrifuge-js -->
<script type="text/javascript" src="https://rawgit.com/centrifugal/centrifuge-js/c2/dist/centrifuge.min.js"></script>
</head>
<body>
<input type="text" id="input" />
<script type="text/javascript">
@FZambia
FZambia / nginx.conf
Created Mar 22, 2018
Nginx to proxy Websocket and GRPC traffix on the same port
View nginx.conf
events {
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';
map $http_upgrade $connection_upgrade {
default upgrade;
@FZambia
FZambia / main.js
Last active Mar 8, 2018
Connect to Centrifuge from client side.
View main.js
var centrifuge = new Centrifuge("ws://localhost:8000/connection/websocket");
centrifuge.on("connect", function() {
centrifuge.rpc({"input": "test"}).then(function(data){
console.log(data);
}, function(err) {
console.log(err);
})
});
@FZambia
FZambia / main.go
Last active Mar 8, 2018
Centrifuge library small example
View main.go
package main
import (
"context"
"log"
"net/http"
"github.com/centrifugal/centrifuge"
)
@FZambia
FZambia / client.proto
Last active Feb 14, 2018
Clean Centrifugo v2 client proto
View client.proto
syntax = "proto3";
package proto;
message Error {
uint32 Code = 1;
string Message = 2;
}
enum MethodType {
@FZambia
FZambia / reconnect.go
Created Jan 15, 2018
survive subscription error
View reconnect.go
package main
// Demonstrate how to reconnect.
import (
"fmt"
"log"
"time"
"github.com/centrifugal/centrifuge-mobile"
@FZambia
FZambia / gist:7ec1da90de45327605a3043d3891e2d3
Created Oct 25, 2017 — forked from klovadis/gist:5170446
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
View gist:7ec1da90de45327605a3043d3891e2d3
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v
@FZambia
FZambia / batch.go
Created Sep 11, 2017
Smartbatching go
View batch.go
package smartbatching
import (
"errors"
"sync"
)
// T is a type Batcher works with.
type T interface{}
@FZambia
FZambia / ViewController.m
Last active Apr 6, 2017
Gomobile Objective-C example
View ViewController.m
//
// ViewController.m
// CentrifugoObjectiveC
//
// Created by Alexander Emelin on 05/04/2017.
// Copyright © 2017 Alexander Emelin. All rights reserved.
//
#import "Centrifuge/Centrifuge.objc.h"
#import "ViewController.h"
You can’t perform that action at this time.