Skip to content

Instantly share code, notes, and snippets.

View FZambia's full-sized avatar

Alexander Emelin FZambia

View GitHub Profile
@FZambia
FZambia / batch.go
Created September 11, 2017 10:48
Smartbatching go
package smartbatching
import (
"errors"
"sync"
)
// T is a type Batcher works with.
type T interface{}
@FZambia
FZambia / ViewController.m
Last active April 6, 2017 06:46
Gomobile Objective-C example
//
// 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"
@FZambia
FZambia / compression.go
Created April 2, 2017 14:20
Create many compression connections
package main
// Subscribe many clients, publish into channel, wait for all messages received.
// Supposed to run for channel which only have `publish` option enabled.
import (
//"encoding/json"
"log"
"strconv"
"sync"
@FZambia
FZambia / playoff.py
Last active March 15, 2017 12:36
Play-off simulation
import sys
import math
import uuid
import random
import pprint
def _get_random_game_score():
max_score = 5
score1 = score2 = None
@FZambia
FZambia / cpu.svg
Created March 14, 2017 20:13
Centrifugo + Gorilla WebSocket profiles
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@FZambia
FZambia / AppMessageHandler.java
Last active April 18, 2017 19:39
Using centrifuge-mobile gomobile-generated library from Java (for Android development)
package com.example.fz.centrifugoandroid;
import android.app.Activity;
import android.content.Context;
import android.widget.TextView;
import centrifuge.Message;
import centrifuge.MessageHandler;
import centrifuge.Sub;
@FZambia
FZambia / ViewController.swift
Last active April 18, 2017 19:39
Using centrifuge-mobile gomobile-generated library from Swift (for iOS development)
import UIKit
import Centrifuge
class MessageHandler : NSObject, CentrifugeMessageHandlerProtocol {
var l: UILabel!
func setLabel(l: UILabel!) {
self.l = l
}
@FZambia
FZambia / queue.go
Created February 16, 2017 07:01
Unbounded queue for Go language
package queue
import (
"sync"
)
type Item interface {
Len() int
}
@FZambia
FZambia / server.go
Last active February 7, 2017 16:25
Simple Go TLS server with Let's Encrypt automatic certificates
package main
import (
"crypto/tls"
"fmt"
"net/http"
"golang.org/x/crypto/acme/autocert"
)
@FZambia
FZambia / shared.js
Created February 6, 2017 22:05
Centrifugo SharedWorker notes
/*********************************************************************/
rtm.worker = false; // тут живёт воркер, если удалось его создать.
rtm.createWorker = function () {
if (typeof SharedWorker === 'undefined') {
return false; // значит, что браузер не умеет такой тип воркеров
}
try {
rtm.worker = new SharedWorker("/rtm/ww.js"); // это урл воркера, его идентификатор
rtm.worker.port.addEventListener("message", function (msg) {
rtm.onMessage(msg); // это мой обработчик сообщений от воркера