Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am romeuhcf on github.
* I am romeuhcf (https://keybase.io/romeuhcf) on keybase.
* I have a public key ASACRh7aWrFw-4nozzqCZeE7Cp8a9Dh4vhZQciZyUr8-Wwo
To claim this, I am signing this object:
@romeuhcf
romeuhcf / rest.rb
Created December 17, 2019 13:53
Multi verb http
require 'net/http'
require 'uri'
def call(method:, host:, path: '/', query_parameters: {})
method = method.to_s.downcase
method = method[0].upcase + method[1..]
uri = URI(File.join(host, path))
uri.query = URI.encode_www_form(query_parameters)
# TODO POST raw payload
@romeuhcf
romeuhcf / sidekiq clean
Created June 26, 2019 01:09
Safely remove every empty sidekiq queue.
redis-cli EVAL 'local n = 0 ; local qs = redis.call("smembers","queues"); for _,q in ipairs(qs) do local qname = "queue:"..q ;if redis.call("llen", qname) == 0 then redis.call("srem", "queues", q) ; redis.call("del", qname); n = n+1 end end ; return n' 0
@romeuhcf
romeuhcf / basegame.js
Created February 26, 2019 18:37
Basic game loop
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext("2d");
canvas.width = 400; canvas.height = 300;
var mousePos = {x: 0, y:0};
var lastFrameTimeMs = 0,
maxFPS = 60,
@romeuhcf
romeuhcf / rubocop.1.yml
Created November 15, 2018 14:22
Rubocop 2.5 config maturity level 1
AllCops:
TargetRubyVersion: 2.5
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Include:
- '**/*.podspec'
- '**/*.jbuilder'
- '**/*.rake'
- '**/*.opal'
git fetch; git log --pretty=oneline production...origin/HEAD master --first-parent --merges | grep -v master..of | sed "s/.*branch '//; s/'.*//"
@romeuhcf
romeuhcf / gist:e59c397b100432543652eeeccd565ffd
Created November 1, 2018 23:37
template-spec-fixture-file.html
<h1>OI {{name}}</h1>
<h2>Hello, {{email}}</h2>
<img src="a.gif"/>
set -e
tee /etc/logrotate.d/bluepill << END
/var/log/bluepill.log {
rotate 7
daily
missingok
notifempty
sharedscripts
@romeuhcf
romeuhcf / csv_with_bom.rb
Last active November 14, 2021 00:30
Ruby 2.5 support for opening csv with bom|utf-8
class CSV
def self.open(file, options={}, &block)
encoding = options.delete(:encoding)
File.open(file, "r:#{encoding}") do |fd|
yield CSV.new(fd, options)
end
end
end
alert('oi');