Skip to content

Instantly share code, notes, and snippets.

View mauricioklein's full-sized avatar

Mauricio Klein mauricioklein

View GitHub Profile
@mauricioklein
mauricioklein / docker-compose.yml
Created May 27, 2015 16:20
Exemple of docker-compose.yml with port forwarding
api:
image: ruby
links:
- db
ports:
- "3000:3000"
db:
image: postgres
@mauricioklein
mauricioklein / Admin.rb
Last active November 29, 2021 01:17
Has Many :through polymorphic problem
class Admin < ActiveRecord::Base
has_many :favorites, as: :favoritable
has_many :favorite_services, through: 'favorites', source: 'service'
end
@mauricioklein
mauricioklein / .travis.yml
Last active August 29, 2015 14:27
Travis file causing permission denied when trying to stop container
language: ruby
sudo: required
dist: trusty
services:
- docker
script:
@mauricioklein
mauricioklein / zssn.md
Last active April 16, 2024 14:12
Zombie Survival Social Network

ZSSN (Zombie Survival Social Network)

Descrição do Problema

O mundo finalmente atingiu o seu estado apocalíptico, onde uma pandemia causada por um virus de laboratório transforma seres humanos e animais em zumbis, seres sedentos por carne.

Você, como membro da resistência (e último sobrevivente com conhecimentos em desenvolvimento de software) foi incubido à desenvolver um sistema para compartilhamento de recursos entre os humanos não infectados.

Funcionalidades

@mauricioklein
mauricioklein / wallet_transfer_with_transaction.rb
Last active April 23, 2016 17:19
Wallet transfer example
def transfer
amount = params[:amount]
Wallet.transaction do
@client1.withdrawal(amount)
@client2.deposit(amount)
end
render status: :ok
end
def transfer
amount = params[:amount]
@client1.withdrawal(amount)
@client2.deposit(amount)
render status: :ok
end
@mauricioklein
mauricioklein / command.rb
Last active July 16, 2016 00:17
Rom-SQL error
module Persistence
module Commands
class CreateUserCompany < ROM::Commands::Create[:sql]
input Dry::Data['hash'].schema(
user_id: 'int',
company_id: 'int'
)
relation :user_company
register_as :create
@mauricioklein
mauricioklein / friend.rb
Created September 12, 2016 14:05
Rom Repository relation
require 'equalizer'
require 'dry/data'
module Entities
class Friend < Dry::Data::Struct
include Equalizer.new(:id, :source_id, :target_id)
attribute :id, 'int'
attribute :source_id, 'int'
attribute :target_id, 'int'
@mauricioklein
mauricioklein / anagram.rb
Last active October 6, 2016 16:14
Anagram generator
#
# ANAGRAM GENERATOR
#
# Author: Mauricio Klein (mauricio [dot] klein [dot] msk [at] gmail [dot] com)
# Date: October 6th, 2016
#
#
# USAGE:
# $ ruby anagram.rb <a word>
@mauricioklein
mauricioklein / routes.js
Last active November 21, 2016 17:27
Server side rendering <noscript>
import React from 'react';
import {Route, Redirect} from 'react-router';
import {
App,
NotFound,
Panel
} from 'containers';
export default () => {
return (