Skip to content

Instantly share code, notes, and snippets.

View edgurgel's full-sized avatar

Eduardo Gurgel edgurgel

View GitHub Profile
@mansueli
mansueli / testing_rls_supabase.mdx
Last active June 12, 2025 22:16
Testing Row Level Security (RLS) policies @supabase

Testing RLS policies

To test policies on the database itself (i.e., from the SQL Editor or from psql) without switching to your frontend and logging in as different users, you can utilize the following helper SQL procedures (credits):

grant anon, authenticated to postgres;

create or replace procedure auth.login_as_user (user_email text)
    language plpgsql
    as $$
@ityonemo
ityonemo / start_peer.exs
Created December 13, 2022 15:34
starts a BEAM peer node
:net_kernel.start([:"[email protected]"])
:erlang.set_cookie(:cook)
{:ok, peer, peername} =
:peer.start(%{connection: 0, name: :peer, host: ~C'127.0.0.1'})
:peer.call(peer, :erlang, :set_cookie, [:cook])
Node.connect(peername)
# add code paths
:rpc.call(peername, :code, :add_paths, [:code.get_path()])
@ikuz
ikuz / nix-notes.md
Last active February 9, 2022 03:30
Nix Notes

Nix notes

Nix concepts

packages (and derivations)

  • package: a software package
  • derivation: a specific version of a software package
    • identified by a hash
@alissonsales
alissonsales / redis-protocol-awk
Last active August 7, 2018 03:54
Redis protocol in awk
awk '{ print "*" NF "\r"; for(i = 1; i <= NF; i++) { print "$" length($i) "\r\n" $i "\r" } }'
@lrascao
lrascao / gist:6880485b8dc4c51c74392b0fa5b9d358
Last active December 29, 2023 12:29
Build Erlang statically linked with OpenSSL
sudo yum install gcc gcc-c++ make libxslt fop ncurses-devel openssl-devel *openjdk-devel unixODBC unixODBC-devel
KERL_CONFIGURE_OPTIONS="--with-ssl=/home/ec2-user/openssl/releases/1.0.2h --disable-dynamic-ssl-lib" kerl build 18.3 18.3
# without ECC
KERL_CONFIGURE_OPTIONS="CFLAGS=-DOPENSSL_NO_EC=1" kerl build 18.3 18.3
@crcastle
crcastle / kafka-from-cli.md
Last active August 26, 2021 13:02
Kafka CLI example using Apache Kafka on Heroku
@josevalim
josevalim / watcher.sh
Last active May 22, 2024 10:06
A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance
# You will need fswatch installed (available in homebrew and friends)
# The command below will run tests and wait until fswatch writes something.
# The --stale flag will only run stale entries, it requires Elixir v1.3.
fswatch lib/ test/ | mix test --stale --listen-on-stdin
@tam7t
tam7t / gist:86eb4793e8ecf3f55037
Last active April 14, 2022 10:57
Securing Ruby's OpenSSL

Are your Ruby HTTPS API calls secure?

Let's check:

2.0.0-p481 :001 > OpenSSL::SSL::SSLContext::DEFAULT_PARAMS
 => {:ssl_version=>"SSLv23", :verify_mode=>1, :ciphers=>"ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW", :options=>-2147482625}
2.0.0-p481 :002 > rating = JSON.parse(RestClient::Resource.new("https://www.howsmyssl.com/a/check" ).get)['rating']
 => "Bad"
@darrencauthon
darrencauthon / 1_install_erlang.sh
Created August 28, 2014 14:27
Install Elixir v0.14.2
apt-get -y install build-essential m4 libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxgtk2.8-dev libglu1-mesa-dev fop xsltproc default-jdk
apt-get -y install make
apt-get -y install libncurses5-dev
mkdir -p /src/erlang
cd /src/erlang
wget http://www.erlang.org/download/otp_src_17.0.tar.gz
tar -xvzf otp_src_17.0.tar.gz
chmod -R 777 otp_src_17.0
cd otp_src_17.0
./configure
@edgurgel
edgurgel / wth.rb
Created March 28, 2014 02:02
WTH 0.0.3 formula
require "formula"
# https://github.com/Homebrew/homebrew/blob/master/Library/Formula/elixir.rb
class ErlangInstalled < Requirement
fatal true
default_formula 'erlang'
env :userpaths
satisfy {
erl = which('erl') and begin