Skip to content

Instantly share code, notes, and snippets.

@imDaniX
imDaniX / README Антимат.md
Last active December 9, 2025 12:41
Мат фильтр | Регулярка антимат

Регулярное выражение для нахождения русского мата в тексте. Использовать следует только для первичной модерации, ибо обходится нажатием в одну клавишу. Если вам требуется полноценный фильтра мата, советую прибегнуть к программному пути создания такового, найти третье API, или просто остановиться на ручной модерации.

Выражение писалось в первую очередь с оглядкой на регулярки Java - для других языков может потребоваться адаптация.

Основа регулярного выражения

\b(
((у|[нз]а|(хитро|не)?вз?[ыьъ]|с[ьъ]|(и|ра)[зс]ъ?|(о[тб]|п[оа]д)[ьъ]?|(.\B)+?[оаеи-])-?)?(
  [её](б(?!о[рй]|рач)|п[уа](ц|тс))|
  и[пб][ае][тцд][ьъ]
@seriyps
seriyps / epgsql_cmd_eequery.erl
Last active November 1, 2021 18:58
Single - roundtrip version of epgsql:equery
%% Single-roundtrip version of epgsql:equery/3
%%
%% It does parse-bind-execute sequence in 1 network roundtrip.
%% The cost is that user should manually provide the datatype information for
%% each bind-parameter.
%% Another potential problem is that connection will crash if epgsql does not
%% have a codec for any of result columns. Explicit type casting may save you
%% in this case: `SELECT my_enum::text FROM my_tab'. Or you can implement the
%% codec you need.
%%
@stolen
stolen / sendsock.escript
Last active September 25, 2019 09:53
demo: sending open TCP socket to another BEAM over UNIX socket
#!/usr/bin/env escript
%%% You need an OTP with fixes for sendmsg types
%%% see https://github.com/erlang/otp/pull/2400
-module(sendsock).
-mode(compile).
-export([main/1]).
@maxlapshin
maxlapshin / systemd.erl
Last active December 24, 2022 17:28
Systemd support
-module(systemd).
% This is what you need to adopt systemd in erlang
%
% Do whatever you want license. If you want, you can take this code under terms of MIT license.
-export([ready/0, reloading/0, stopping/0, watchdog/0]).
-export([start_link/0]).
-export([init/1, handle_info/2, terminate/2]).

Весь список блокируемых РКН адресов умещается в 64K префиксов для linux ipset(8). С таким объемом точно справляется хилый intel linux box в качестве внешнего маршрутизатора, и, возможно, справится SOHO железка с OpenWRT (не проверял).

Для обхода блокировок понадобится:

  • linux box в качестве маршрутизатора между внутренней сетью (интерфейс $INT_IF, сеть $INT_NET)
  • vpn на какую-нибудь площадку (интерфейс $VPN_IF -- предполагается, что VPN делает NAT сама)
  1. Сначала надо преобразовать список адресов в формат, приемлимый для ipset(8):
@seriyps
seriyps / rf.erl
Last active February 1, 2018 15:43
Print erlang records as records, not tuples; print function source code
%% Prints source code of a function.
%%
%% Requires debug_info
%% Will not work for modules mocked by meck
%%
%% > io:format("~s~n", [rf:print_function(dict, new, 0)]).
%% new() ->
%% Empty = mk_seg(16),
%% #dict{empty = Empty, segs = {Empty}}.
@stolen
stolen / timetop.erl
Created January 18, 2018 16:08
top processes by scheduled time
-module(timetop).
-export([top/2]).
top(Duration, Count) ->
OldPrio = erlang:process_flag(priority, high),
Result = scheduled_time_top(Duration),
erlang:process_flag(priority, OldPrio),
lists:sublist(Result, Count).
@voluntas
voluntas / sysctl.conf
Created October 14, 2017 13:07 — forked from techgaun/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
Originally from: http://erlang.org/pipermail/erlang-questions/2017-August/093170.html
For a safe and fast Erlang SSL server, there's a few
configuration values you might want by default:
[{ciphers, CipherList}, % see below
{honor_cipher_order, true}, % pick the server-defined order of ciphers
{secure_renegotiate, true}, % prevent renegotiation hijacks
{client_renegotiation, false}, % prevent clients DoSing w/ renegs
{versions, ['tlsv1.2', 'tlsv1.1']}, % add tlsv1 if you must
@JLarky
JLarky / encode_uri_rfc3986_binary.erl
Last active April 8, 2018 14:06
Erlang url encode with unicode/utf8 support working on binary instead of lists/strings
-module(encode_uri_rfc3986_binary).
-author('Renato Albano <[email protected]>').
-author('JLarky <[email protected]>').
-export([encode/1]).
%% Taken from <http://erlangexamples.com/>,
%% from <http://github.com/CapnKernul/httparadise>
%% and <http://www.erlang.org/doc/man/edoc_lib.html>