Skip to content

Instantly share code, notes, and snippets.

View mauricioklein's full-sized avatar

Mauricio Klein mauricioklein

View GitHub Profile
@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 / 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 (
@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
import request from 'superagent';
export const getWeatherForCity = (city, country) => {
return new Promise((resolve, reject) => {
request
.get('http://api.openweathermap.org/data/2.5/weather')
.query({
q: `${city},${country}`,
units: 'metric',
APPID: 'ABC123'
[
{
"action": "talk",
"text": "Hello! This is an automated call from ACME company.",
"voiceName": "Brian",
"bargeIn": false
},
{
"action": "talk",
"text": "Please confirm the service request for Max Mustermann, PNR: B, C, X, 4, 5, 1, 3.",