Skip to content

Instantly share code, notes, and snippets.

View FZambia's full-sized avatar

Alexander Emelin FZambia

View GitHub Profile
@FZambia
FZambia / compression_test.go
Created January 13, 2017 07:37
Gorilla websocket compression benchmarks
package websocket
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"testing"
)
@FZambia
FZambia / timer.go
Created January 6, 2017 18:48
Timer pool for Go language
package pools
import (
"sync"
"time"
)
var timerPool sync.Pool
// AcquireTimer returns time from pool if possible.
@FZambia
FZambia / main.go
Created December 31, 2016 17:51
Proof of eventual consistency of Redis PUBSUB CHANNELS * command
package main
// Proof of eventual consistency of Redis PUBSUB CHANNELS * command.
import (
"fmt"
"strconv"
"time"
"github.com/garyburd/redigo/redis"
@FZambia
FZambia / test.go
Created December 24, 2016 10:48
benchmark how fast we can subscribe on channels in Redis
func BenchmarkSubscribe(b *testing.B) {
c := dial()
defer c.close()
num := 100000
batchSize := RedisSubscribeBatchLimit
b.ResetTimer()
for i := 0; i < b.N; i++ {
j := 0
@FZambia
FZambia / sockjs.js
Created November 17, 2016 19:07
Attempt to fix Sockjs
/* sockjs-client v1.1.1 | http://sockjs.org | MIT license */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.SockJS=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (global){
'use strict';
var transportList = require('./transport-list');
module.exports = require('./main')(transportList);
// TODO can't get rid
@FZambia
FZambia / api_test.go
Created November 11, 2016 17:05
Jsonparser GJSON Benchmarks
package apiv1
import (
"encoding/json"
"testing"
"github.com/buger/jsonparser"
"github.com/centrifugal/centrifugo/libcentrifugo/proto"
"github.com/centrifugal/centrifugo/libcentrifugo/raw"
"github.com/tidwall/gjson"
@FZambia
FZambia / server.go
Last active October 20, 2016 14:39
fasthttp api handler for Centrifugo
package fasthttpserver
import (
"encoding/json"
"errors"
"sync"
"github.com/FZambia/go-logger"
"github.com/centrifugal/centrifugo/libcentrifugo/api/v1"
"github.com/centrifugal/centrifugo/libcentrifugo/node"
@FZambia
FZambia / restore.js
Created September 23, 2016 17:02
Adblock Websocket restore
var native = function () {
var initialized = false;
return {
restore: function () {
if (initialized) {
return;
}
initialized = true;
@FZambia
FZambia / redis.go
Created August 24, 2016 07:17
Centrifugo Redis proto support
package libcentrifugo
import (
"encoding/json"
"strings"
"github.com/FZambia/go-logger"
"github.com/tidwall/redcon"
)
@FZambia
FZambia / main.go
Last active December 12, 2021 18:33
Verify armored GPG signature using Go language
package main
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"golang.org/x/crypto/openpgp/armor"