Skip to content

Instantly share code, notes, and snippets.

Xavier Noria fxn

Block or report user

Report or block fxn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View user_test.rb
require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "class names" do
uid = User.object_id
print "please modify the file and press ENTER "; gets
assert_equal uid, User.object_id
docker container ls -a -q | xargs docker container rm
docker image ls -a -q | xargs docker image rm
docker volume ls -q | xargs docker volume rm
docker network ls -q --filter type=custom | xargs docker network rm
View Overview of the Zeitwerk integration in Rails
View compare_tz_env_var.rb
require "benchmark/ips"
Benchmark.ips do |x|"without TZ") do |n|
ENV["TZ"] = nil
i = 0
while i < n
i += 1
View wdrift.c
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
int main(void)
struct timeval now;
double seconds;
gettimeofday(&now, NULL);
View m.ex
defmodule M do
@x N.f()
find . -name '*.ex' -or -name '*.exs' | xargs perl -ni -le 'print unless /^\s*(\@doc|\@moduledoc) """/ ... /^\s*"""/'

Four solutions

I have worked first with the file downloaded to make sure I got the result right. Those drafts are not here.

After that we have four solutions:

  1. A simple one that fetches the entire payload in one request.
  2. An streamed one, same idea, but processing by chunks.
  3. A parallel approach that speeds up the download using HTTP range requests.
  4. A variant of the previous one that parallelizes the computation as well.
View inspect_current_mfa.ex
{_, mfa} = :erlang.process_info(self(), :current_function)
IO.inspect(mfa) #=> {:elixir_compiler_0, :__FILE__, 1}
View events_loader.rb
class EventsLoader
def initialize(...)
def load
load_job_creation_events +
load_drivers_on_duty_events +
load_drivers_off_duty_events +
You can’t perform that action at this time.