Skip to content

Instantly share code, notes, and snippets.

View alazycoder101's full-sized avatar

Lazy coder alazycoder101

View GitHub Profile
@alazycoder101
alazycoder101 / frag.rb
Created February 23, 2022 16:39 — forked from mperham/frag.rb
memory fragmentation on ruby 2.5.1
=begin
This script attempts to reproduce poor glibc allocator behavior within Ruby, leading
to extreme memory fragmentation and process RSS bloat.
glibc allocates memory using per-thread "arenas". These blocks can easily fragment when
some objects are free'd and others are long-lived.
Our script runs multiple threads, all allocating randomly sized "large" Strings between 4,000
and 40,000 bytes in size. This simulates Rails views with ERB creating large chunks of HTML
to output to the browser. Some of these strings are kept around and some are discarded.
@alazycoder101
alazycoder101 / ruby-jemalloc-check.sh
Created February 23, 2022 16:39 — forked from kigster/ruby-jemalloc-check.sh
Detect if MRI Ruby is built with jemalloc library or not, download with `curl -fSL http://bit.ly/ruby-jemalloc-check > ruby-jemalloc-check.sh`
#!/usr/bin/env bash
# vi: ft=sh
#
# © 2019 Konstantin Gredeskoul, Inc., All rights reserved.
# MIT LICENSE
#
# ————————————————————————————————————————————————————————————————
# This script verifies that the current ruby (in PATH) is linked
# with libjemalloc library for efficient memory utilization.
# It works identically on Linux and Mac OSX.
@alazycoder101
alazycoder101 / yaml-load.md
Last active February 15, 2022 23:04
visit_Psych_Nodes_Alias': Unknown alias
# test-yaml.rb

require 'yaml'

# Psych is complaining about aliases
# YAML.load is safe_load now
# Psych.safe_load yaml, aliases: true
#

HTTP(S) Tools to help with API tests

Functions you might need

  1. simulate network conditions: speed and latency.
  2. API responses.
  3. monitoring https traffics.

Ways to simulate

  1. Proxy: mitmproxy, Fiddler, proxyman
brew install mutagen-io/mutagen/mutagen mutagen-io/mutagen/mutagen-compose

docker-compose.yml

# Define synchronization and forwarding sessions
x-mutagen:
  sync:
 defaults:

podman + podman-composer

podman machine init
Downloading VM image: fedora-coreos-35.20220116.2.0-qemu.aarch64.qcow2.xz: do…
Extracting compressed file
podman machine start
bundle exec rake zeitwerk:check

zeitwerk example

load_defaults "6.0 # use zeitwerk
config.autoloader = :classic # not use zeitwerk

::Digest::SHA256.hexdigest

echo 'hello'|md5
b1946ac92492d2347c6235b4d2611184

encoding

curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yq update && apt-get -yq install google-chrome-stable
CHROMEDRIVER_VERSION=$(curl -s http://chromedriver.storage.googleapis.com/LATEST_RELEASE) && \
cd /tmp/ && curl -L -O "http://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" && \
unzip chromedriver_linux64.zip && chmod +x chromedriver && mv chromedriver /usr/bin