Skip to content

Instantly share code, notes, and snippets.

View americodls's full-sized avatar
:shipit:

Américo Duarte americodls

:shipit:
  • Dublin, Ireland
View GitHub Profile
@americodls
americodls / binary_to_ascii_html.js
Created February 24, 2022 15:28
Convert Binary to ASCII
(function(e){r=arguments.callee;(e.children.length!==0)?Array.from(e.children).map(c=>r(c)):(m=e.textContent.match(/([01]{8})/g))&&(e.innerHTML=m.map(b=>String.fromCharCode(parseInt(b,2))).join(''))
})(document.body);
@americodls
americodls / Dockerfile
Last active May 20, 2019 01:12
Docker & Docker Compose para aplicações rails
FROM ruby:2.5.1
ARG user
ARG uid
RUN test -n "$user"
RUN test -n "$uid"
ENV BUILD_DEPS="build-essential"
ENV RAILS_GEM_DEPS="tzdata less postgresql-client"

INCIDENT DATE - INCIDENT TYPE

Meeting

Waiving meetings

In some cases the IC might determine that a PM meeting for the incident isn't needed. If the IC decides to waive the meeting please replace the Meeting section with a note indicating the meeting has been waived (example: Meeting waived: Paul Mooring)

@americodls
americodls / function.rb
Created June 7, 2018 05:45
Create an object that is an improvement over Proc (curried by default and better inspection for debug)
class Function
attr_reader :arity, :source_location
def initialize(&block)
unless block_given?
message = "tried to create #{self.class.name} object without a block"
raise(ArgumentError, message)
end
@arity = block.arity
@americodls
americodls / rubocop.rb
Created November 10, 2017 22:34 — forked from skanev/rubocop.rb
A Rubocop wrapper that checks only added/modified code
#!/usr/bin/env ruby
# A sneaky wrapper around Rubocop that allows you to run it only against
# the recent changes, as opposed to the whole project. It lets you
# enforce the style guide for new/modified code only, as opposed to
# having to restyle everything or adding cops incrementally. It relies
# on git to figure out which files to check.
#
# Here are some options you can pass in addition to the ones in rubocop:
#
@americodls
americodls / rubocop_pre_commit_hook
Created October 31, 2017 19:34 — forked from mpeteuil/rubocop_pre_commit_hook
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
@americodls
americodls / sign_in.rb
Created February 17, 2015 00:17
Interface proposal for ServiceObject/Interactor/UseCase on rails
class SessionsController < ApplicationController
def create
ToDoList::SignIn.new(sign_in_params).call({
success: ->(message) { redirect_to dashboard_user_path, notice: t(message) },
failure: ->(message) { render :new, error: t(message) }
})
end
end
module ToDoList
@americodls
americodls / mediator.js
Last active September 22, 2015 21:24
Pub/Sub pattern using only jQuery.
window.mediator = $({});
$(function() {
mediator.on("foo:bar", fooBar);
mediator.trigger("foo:bar");
});
function fooBar(event) {
alert("Foo Bar");
}