Skip to content

Instantly share code, notes, and snippets.

View renatodex's full-sized avatar
🦑
Release the Kraken, but test it please!

Renato Alves renatodex

🦑
Release the Kraken, but test it please!
  • Everlane
  • São Paulo - Brazil
View GitHub Profile
@renatodex
renatodex / sidekiq_cleaner.rb
Created March 8, 2023 16:49
Clean Sidekiq Queues and Remove/Invalidate Batches
def clean_sidekiq_and_invalidate_batches
Sidekiq::BatchSet.new.each { |batch| Sidekiq::Batch.new(batch.bid).invalidate_all }
Sidekiq::Queue.all.each(&:clear)
end
def clean_sidekiq_and_delete_batches
Sidekiq::BatchSet.new.each { |batch| Sidekiq::Batch::Status.new(batch.bid).delete }
Sidekiq::Queue.all.each(&:clear)
end
@renatodex
renatodex / debug_log.rb
Last active November 11, 2022 23:10
Debug Log
require 'singleton'
class DebugLog < Logger
include Singleton
def initialize(log_file = 'debug')
super(Rails.root.join("log/#{log_file}.log"))
self.formatter = formatter()
self
end
@renatodex
renatodex / docker-compose.yml
Created October 29, 2021 21:00 — forked from everpeace/docker-compose.yml
kafka cluster in docker-compose.
# WARNING: This docker-compose.yml is only for testing purpose.
# Parameters:
# - name: CONFLUENT_PLATFORM_VERSION
# default: 3.0.0
# reference: https://hub.docker.com/u/confluentinc/
# Ports:
# - description: Major ports are exposed to host computer
# - zookeeper: 2181
# kafka1: 9091
# kafka2: 9092
class UnpublishMovies
def call
movies_to_unpublish = Movies.where_not(
unpublish_at: nil,
)
series_to_unpublish = Series.where_not(
unpublish_at: nil,
)
shows_to_unpublish = Shows.where_not(
unpublish_at: nil,
class UnpublishMovies
def call
movies_to_unpublish = Movies.where_not(
unpublish_at: nil,
)
series_to_unpublish = Series.where_not(
unpublish_at: nil,
)
shows_to_unpublish = Shows.where_not(
unpublish_at: nil,
def parse_bizarre_time(year, month, day, hour, minute, second)
Time.parse("#{year}-#{month}-#{day} #{hour}:#{minute}:#{second}")
end
parse_bizarre_time(*["2020", "10", "06", "10", "20", "30"])
class UnpublishMovies
def call
to_unpublish_list = [
{
field: :unpublish_at,
klasses: [Movies, Series, Shows],
},
{
field: :date_to_unpublish_podcast,
klasses: [Podcast],
class UnpublishMovies
def call
movies_to_unpublish = Movies.where_not(
unpublish_at: nil,
)
series_to_unpublish = Series.where_not(
unpublish_at: nil,
)
shows_to_unpublish = Shows.where_not(
unpublish_at: nil,
const Random = require("random-js").Random;
function deckProbabilityTest(cycles = 1) {
let random = new Random();
let results = []
let originalDeck = [1,2,3,4,5,6]
let totalCards = originalDeck.length
let desiredCardAtEnd = 5
@renatodex
renatodex / scrapper.js
Created July 14, 2018 00:05
Instagram Comment Scrapper
// Adicionando jQuery
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type (or see below for non wait option)
jQuery.noConflict();
// Função Recursiva que faz o Scrap
function scrap_comments(nodeset = [], query_hash, variables) {
result = []