Skip to content

Instantly share code, notes, and snippets.

View erszcz's full-sized avatar

Radek Szymczyszyn erszcz

View GitHub Profile
$ make -j10 tests
test/check_name_clashes.sh
mkdir -p "test_data"
erlc +debug_info -o test_data test/known_problems/should_fail/arith_op.erl test/known_problems/should_fail/exhaustive_argumentwise.erl test/known_problems/should_fail/exhaustive_map_variants.erl test/known_problems/should_fail/exhaustive_remote_map_variants.erl test/known_problems/should_fail/guard_should_fail.erl test/known_problems/should_fail/infer_any_pattern.erl test/known_problems/should_fail/intersection_with_any_should_fail.erl test/known_problems/should_fail/lambda_wrong_args.erl test/known_problems/should_fail/map_refinement_fancy.erl test/known_problems/should_fail/poly_lists_map_should_fail.erl test/known_problems/should_fail/refine_ty_vars.erl test/known_problems/should_fail/rigid_type_variables_fail.erl test/known_problems/should_fail/sample.erl test/known_problems/should_fail/tuple_union_arg.erl test/known_problems/should_pass/any_doesnt_have_type_none_should_pass.erl test/known_problems/should_pass/arith_op_arg_types.erl test/kn
$ make -j10 tests
test/check_name_clashes.sh
mkdir -p "test_data"
erlc +debug_info -o test_data test/known_problems/should_fail/arith_op.erl test/known_problems/should_fail/exhaustive_argumentwise.erl test/known_problems/should_fail/exhaustive_map_variants.erl test/known_problems/should_fail/exhaustive_remote_map_variants.erl test/known_problems/should_fail/guard_should_fail.erl test/known_problems/should_fail/infer_any_pattern.erl test/known_problems/should_fail/intersection_with_any_should_fail.erl test/known_problems/should_fail/lambda_wrong_args.erl test/known_problems/should_fail/map_refinement_fancy.erl test/known_problems/should_fail/poly_lists_map_should_fail.erl test/known_problems/should_fail/refine_ty_vars.erl test/known_problems/should_fail/rigid_type_variables_fail.erl test/known_problems/should_fail/sample.erl test/known_problems/should_fail/tuple_union_arg.erl test/known_problems/should_pass/any_doesnt_have_type_none_should_pass.erl test/known_problems/should_pass/arith_op_arg_types.erl test/kn
@erszcz
erszcz / .gitignore
Last active May 3, 2023 14:45
Comparison of Erlang type checkers: Dialyzer, ETC, and Gradualizer
*.beam
*.erltypes
Gradualizer v0.1.3-150-gef2dbb7
_build/default/lib/aoc_erlang/ebin//aoc2019_day03.beam: Nonexhaustive patterns on line 35 at column 1
Example values which are not covered:
[]
_build/default/lib/aoc_erlang/ebin//aoc2019_day03.beam: The function call on line 62 at column 9 is expected to have type [T, ...] but it has type [B]
map_smallest(Fun, List) ->
lists:min(lists:map(Fun, List)).
^^^^^^^^^^^^^^^^^^^^
@erszcz
erszcz / Dockerfile
Last active January 24, 2022 16:07
Unable to set SCHED_FIFO in a container
FROM vectorized/redpanda:v21.10.2
USER root
RUN apt-get update \
&& apt-get install -y build-essential gcc g++ libcap2-bin \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives
COPY sched.cc sched.cc
@erszcz
erszcz / rebar3.14.3.log.md
Last active April 15, 2021 11:32
Rebar3 inconsistency between compiling and recompiling source files under src/ subdirs

Let's set the stage - we have a project with a source file under a subdir of src/. When we compile it the first time, everything looks good - the code returns the value defined by the macro:

$ cd /tmp
$ git clone https://github.com/erszcz/rebar_src_not_recompiled.git src_not_recompiled
$ cd src_not_recompiled
$ rg -C1 MACRO src/
src/subdir/m.erl
@erszcz
erszcz / gist:aed82f720c768646a532f1a0f16506df
Created March 31, 2021 09:24
Reproduce shell_docs glitch on gradualizer
Last login: Tue Mar 30 17:45:28 on ttys027
11:13:23 erszcz @ x6 : ~
$ cd work/josefs/gradualizer/
11:13:49 erszcz @ x6 : ~/work/josefs/gradualizer (record-field-zip-fix)
$ asdf local erlang 24.0-rc1
11:14:13 erszcz @ x6 : ~/work/josefs/gradualizer (record-field-zip-fix %)
$ cat > rebar.config
{edoc_opts, [{doclet, edoc_doclet_chunks},
> {layout, edoc_layout_chunks},
> {preprocess, true},
@erszcz
erszcz / about.md
Last active February 7, 2021 13:40
EDoc baseline and chunk errors on OTP and top Hex.pm libs

These are tests results of running EDoc from erlang/otp#2803 over all OTP and more than 20 top Hex.pm Erlang libraries.

See https://github.com/erszcz/non-otp-libraries and https://github.com/erszcz/otp/blob/edoc-chunk-support/lib/edoc/test/test_libs.sh for the tools.

Use test_libs.sh like this - see the script for more details:

VERBOSE=no LIB_DIR=/Users/erszcz/work/erlang/non-otp-libraries/_build/default/lib ERL_LIBS=/Users/erszcz/work/erlang/non-otp-libraries/_build/default/lib ERL_TOP=/Users/erszcz/work/erlang/otp EDOC=~/work/erlang/build.otp/lib/erlang/lib/edoc-0.12/bin/edoc ./test/test_libs.sh | tee non-otp-libs.log
@erszcz
erszcz / fu.ex.do_parse_spec.diff
Created March 15, 2019 14:43
Gradualizer fix for Membrane.Element.RTP.H264.FU
diff --git a/lib/rtp_h264/nal_formats/fu.ex b/lib/rtp_h264/nal_formats/fu.ex
index 873cf26..3811210 100644
--- a/lib/rtp_h264/nal_formats/fu.ex
+++ b/lib/rtp_h264/nal_formats/fu.ex
@@ -29,12 +29,25 @@ defmodule Membrane.Element.RTP.H264.FU do
| {:error, :packet_malformed | :invalid_first_packet}
| {:incomplete, t()}
def parse(data, seq_num, acc) do
- # actual code
- data

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost