Skip to content

Instantly share code, notes, and snippets.

View javierjulio's full-sized avatar
⚽

Javier Julio javierjulio

⚽
View GitHub Profile
@javierjulio
javierjulio / stream_read_file.rb
Created August 6, 2026 20:40
Stream and read massive file in Ruby
url = "" # URL for large file
# Use `copy_stream` and `foreach` to avoid loading the file into memory.
filepath = Rails.root.join("tmp", "some-file.txt")
IO.copy_stream(URI.parse(url).open, filepath)
ids = []
File.foreach(filepath) { |id| ids << id&.strip&.to_i } # returns nil, does not display anything
# If running this in IRB, avoid printing the result which is painfully slow
# (the slowest portion by far) by running a second expression on that line.
@javierjulio
javierjulio / Dockerfile
Last active July 15, 2026 23:01
Delete unnecessary gem files from Docker image
FROM ruby:4.0.2-alpine AS base
ENV BUNDLE_PATH="/usr/local/bundle"
# Delete unnecessary files in default gems that cause security vulnerability false positives
RUN find "/usr/local/lib/ruby/" -type f -iname "*Gemfile.lock" -delete
# Post install, delete unnecessary files in gems that cause security vulnerability false positives
RUN bundle config set without 'development test rubocop' && \
bundle install && \
@javierjulio
javierjulio / bugsnag-console
Created February 4, 2026 22:35
Bugsnag Data API Interactive Console
#!/usr/bin/env ruby
# Include this script with no file extension in your project's `bin` directory.
# Update the script with your organization slug.
ORGANIZATION_SLUG = "" # Your Bugsnag organization slug
require "io/console" # provides `STDIN.noecho` method
begin
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600">
<s:layout>
<s:HorizontalLayout gap="20" paddingTop="15" paddingLeft="15" />
</s:layout>