Skip to content

Instantly share code, notes, and snippets.

View ronualdo's full-sized avatar

Ronualdo Augusto Maciel ronualdo

View GitHub Profile
FROM ruby:3.0.2-alpine3.14
ARG UID
ARG GID
ARG BUNDLE_PATH="vendor/bundle"
ARG BUNDLE_DEPLOYMENT=true
ARG BUNDLE_WITHOUT="test development"
ENV BUNDLE_PATH $BUNDLE_PATH
ENV BUNDLE_DEPLOYMENT $BUNDLE_DEPLOYMENT
ENV BUNDLE_WITHOUT $BUNDLE_WITHOUT
@ronualdo
ronualdo / frontend_api.rb
Last active July 10, 2018 15:41 — forked from ErvalhouS/frontend_api.rb
A read-only frontend API abstraction applicable to any application.
# frozen_string_literal: true
module Api
module V1
# Controller to consume read-only data to be used on client's frontend
class FrontEndController < ActionController::API
prepend_before_action :set_root_resource
before_action :set_object, except: %i[index schema]
append_before_action :set_nested_resource, only: %i[nested_index]
append_before_action :set_records, only: %i[index nested_index]
defmodule FlattenTest do
use ExUnit.Case
doctest Flatten
test "flats an empty array" do
assert Flatten.flat([]) == []
end
test "flats an array with just one element" do
assert Flatten.flat([1]) == [1]
@ronualdo
ronualdo / flatten.ex
Last active August 1, 2017 17:52
A small exercise in elixir. Just a function to flatten an array. Tests for this function can be found in https://gist.github.com/ronualdo/66e2339a17a7c33229ca61bda977765e
defmodule Flatten do
def flat(list=[]) do
list
end
def flat([head|tail]) when is_list(head) do
flat(head) ++ flat(tail)
end
def flat([head|tail]) do
@ronualdo
ronualdo / robot.js
Created December 7, 2012 06:29
Proto1
var cannonRotation = 5;
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
robot.turn(360 - robot.angle);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(10);