This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Automatic interactive installer for mtproto proxy https://github.com/seriyps/mtproto_proxy | |
# Supported OS: | |
# - Ubuntu 18.xx | |
# - Ubuntu 19.xx | |
# - Ubuntu 20.xx | |
# - Ubuntu 21.xx | |
# - Ubuntu 22.xx | |
# - Debian 11 bullseye | |
# - Debian 10 buster |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
Created on 2012-09-24 | |
@author: Sergey <me@seriyps.ru> | |
How to test: | |
$ head -c 100M /dev/urandom > static_file.bin | |
$ python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(epgsql_cmd_prepared_query_oom_protection). | |
-behaviour(epgsql_command). | |
-export([init/1, execute/2, handle_message/4]). | |
-export_type([response/0]). | |
-type response() :: {ok, Count :: non_neg_integer(), Cols :: [epgsql:column()], Rows :: [tuple()]} | |
| {ok, Count :: non_neg_integer()} | |
| {ok, Cols :: [epgsql:column()], Rows :: [tuple()]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(phase)] | |
#[phase(plugin, link)] extern crate log; | |
extern crate green; | |
extern crate rustuv; | |
use std::io; | |
use std::os; | |
use std::io::{Listener,Acceptor,TcpStream}; | |
#[start] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Send plaintext email using gen_smtp https://github.com/Vagabond/gen_smtp | |
% This function sends email directly to receiver's SMTP server and don't use MTA relays. | |
% | |
% Example plaintext email: | |
% Mail = mail_plain(<<"Bob <sender@example.com>">>, <<"Alice <receiver@example.com>">>, <<"The mail subject">>, <<"The mail body">>), | |
% send_email(Mail). | |
% | |
% Example email with image attachment: | |
% ImgName = "image.jpg", | |
% {ok, ImgBin} = file:read_file(ImgName), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% If we have some amount of PostgreSQL instances and want to transfer data between them, | |
% in case when model has 'timeatamp' fields, we should check that both instances configured with the | |
% same timezone | |
on_same_timezone(Connections) -> | |
Tests = | |
[%% Check using TimeZone connection parameter | |
{fun(Conn) -> | |
{ok, TZ} = pgsql:get_parameter(Conn, <<"TimeZone">>), | |
TZ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-export([uptime/0, uptime/1, uptime_string/0]). | |
%% @doc uptime in native time units | |
uptime() -> | |
erlang:monotonic_time() - erlang:system_info(start_time). | |
%% @doc uptime in specified time units | |
uptime(Unit) -> | |
erlang:convert_time_unit(uptime(), native, Unit). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%% @author Sergey Prokhorov <me@seriyps.ru> | |
%%% @copyright (C) 2013, Sergey Prokhorov | |
%%% @doc | |
%%% @license Apache License Version 2.0 | |
%%% | |
%%% Walker alias method - efficient random selection with defined probabilities. | |
%%% <http://en.wikipedia.org/wiki/Alias_method> | |
%%% | |
%%% > ProbabilityValueList = [{10, a}, {20, b}, {30, c}, {40, d}], | |
%%% > WalkerVectors = walker_alias:build(ProbabilityValueList), |
NewerOlder