Skip to content

Instantly share code, notes, and snippets.

View IgorMarques's full-sized avatar
🚀

Igor Marques IgorMarques

🚀
View GitHub Profile
@IgorMarques
IgorMarques / sidekiq_latency.rb
Last active December 20, 2016 18:19
A simple example on how to get the latency of a given queue in Sidekiq. Calling the new method without params will use the default queue. Extracted from Sidekiq's official API documentation: https://github.com/mperham/sidekiq/wiki/API#queue
Sidekiq::Queue.new('your_queue_name').latency
# => 10.0
@IgorMarques
IgorMarques / ftp_connection_creator.rb
Created November 7, 2016 18:22
How to create a ftp connection in ruby
require 'net/ftp'
class FTPConnectionCreator
def self.call
ftp = Net::FTP.new(ENV['FTP_URL'])
ftp.login(ENV['FTP_USER'], ENV['FTP_PASSWORD'])
# ftp.chdir('public')
@IgorMarques
IgorMarques / timer.rb
Created November 7, 2016 18:20
A timer that uses a redis DB to store the last time something was called
require 'time'
class Timer
def initialize(redis, time_key)
@redis = redis
@time_key = time_key
end
def get_last_call_time
time = @redis.get(@time_key)
@IgorMarques
IgorMarques / statsd-ruby_example.rb
Created May 16, 2016 00:03
A simple example of the gem StatsD (https://github.com/reinh/statsd) running
require 'statsd-ruby'
statsd = Statsd.new 'localhost', 8125
10.times do
statsd.increment 'hello.world'
sleep 1
end
@IgorMarques
IgorMarques / langs.js
Created August 23, 2015 03:56
A list of languages and its extensions
langs = {
'rb': 'ruby',
'js': 'javascript',
'py': 'python',
'c' : 'c',
'css' : 'css',
'html' : 'html',
'php': 'php',
'cpp': 'c++',
'rs': 'rust',
@IgorMarques
IgorMarques / commit-msg.rb
Last active August 29, 2015 14:23
Git hook that checks if the commit message mentions an issue with a specific label
#!/usr/bin/env ruby
require 'net/http'
require 'json'
#CONFIG YOUR STUFF HERE
@in_development_issue_label = "em implementação"
@issues = 'https://api.github.com/repos/IgorMarques/ATM-Exercise/issues'
@issue_not_in_development_message = "MENSAGEM DE COMMIT INVÁLIDA: A issue referenciada não existe ou não está marcada como \"#{@in_development_issue_label}\"."