Skip to content

Instantly share code, notes, and snippets.

@smaximov
smaximov / README.md
Last active August 22, 2019 09:36
HTTP и WebSocket Reverse Proxy

Background: это было написано для "фронт-энд" сервиса, который должен был проксировать HTTP и WebSocket-запросы на несколько внутренних сервисов.

Для того, чтобы переопределить то, как Phoenix обрабатывает вебсокеты, надо поменять настройки HTTP сервера (Cowboy), а именно настройки роутинга (:dispatch) — см. config.exs. Тут мы указываем, что для любого хоста: а) для пути "/aaa/websocket" вызывается хендлер API.Gateway.WSReverseProxy, б) для любого другого пути вызывается дефолтный хэндлер Phoenix.

API.Gateway.WSReverseProxy — это хэндлер Cowboy, для подробной информации о р

{
"plugins": [
["transform-runtime", {
"polyfill": false,
"regenerator": true
}],
"transform-decorators-legacy"
],
"presets": [
[
@smaximov
smaximov / lor-geo.csv
Created August 23, 2018 11:03 — forked from shaman007/lor-geo.csv
LOR geo 30 days
Country Users New Users Sessions Bounce Rate Pages / Session Avg. Session Duration Goal Conversion Rate Goal Completions Goal Value
Russia 455,130 361,894 842,799 72.62% 2.18 00:02:55 0.00% 0 $0.00
Ukraine 111,825 92,044 191,960 74.10% 1.94 00:02:29 0.00% 0 $0.00
Belarus 26,265 21,756 46,632 72.57% 2.28 00:03:12 0.00% 0 $0.00
Kazakhstan 14,601 12,488 23,079 76.86% 1.93 00:02:26 0.00% 0 $0.00
United States 11,277 10,261 15,529 79.13% 1.89 00:01:44 0.00% 0 $0.00
Germany 8,362 6,826 15,053 64.39% 3.23 00:03:53 0.00% 0 $0.00
Moldova 3,570 2,998 6,259 72.15% 1.79 00:02:35 0.00% 0 $0.00
Uzbekistan 3,278 2,786 4,797 78.09% 1.50 00:01:41 0.00% 0 $0.00
France 2,613 2,352 3,358 74.33% 2.49 00:02:40 0.00% 0 $0.00
class MessageMatcher < Module
def initialize(pattern)
@pattern = pattern
end
def ===(exception)
exception.message.match?(@pattern)
end
end
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'forwardable'
require 'optparse'
module Hurkle
VERSION = '0.1.0'
InvalidInput = Class.new(StandardError)

Keybase proof

I hereby claim:

  • I am smaximov on github.
  • I am smaximov (https://keybase.io/smaximov) on keybase.
  • I have a public key ASChLF-MgLkFeK4acSAAGGGCuwP02yOcJzMoIFaiKAVSIAo

To claim this, I am signing this object:

// ==UserScript==
// @name Imagefy
// @namespace https://www.linux.org.ru
// @include https://www.linux.org.ru/*
// @version 0.4.0
// @grant none
// ==/UserScript==
const css = `
.embedded-image-container {
// ==UserScript==
// @name Linkify user remarks
// @namespace https://linux.org.ru/userscripts
// @include https://www.linux.org.ru/*
// @version 0.1.0
// @grant none
// ==/UserScript==
const URL_REGEX = /(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?/gi
const URL_REPLACEMENT = '<a href="$&">$&</a>'
@smaximov
smaximov / Build log
Created January 24, 2016 15:23
Rust FFI
Compiling sample v0.1.0 (file:///tmp/sample)
main.rs:11:23: 11:26 error: cannot borrow immutable local variable `str` as mutable
main.rs:11 unsafe { foo(&mut str) };
^~~
error: aborting due to previous error
Could not compile `sample`.
To learn more, run the command again with --verbose.