Skip to content

Instantly share code, notes, and snippets.

View aristotelesbr's full-sized avatar
🏠
Working from home

Aristóteles Coutinho aristotelesbr

🏠
Working from home
View GitHub Profile
# Deve criar no banco de dados de um valor(despesa) parcelado, onde
# o valor de cada parcela será cobrado nos messes subsequentes.
def create_invoices
interval = 1.month
cicles = self.quantity
start_date = Date.today
current_date = start_date
cicles.times do
class Expense < ActiveRecord::Base
validates :value, presence: true
belongs_to :user
has_many :portions
accepts_nested_attributes_for :portions, reject_if: :all_blank, allow_destroy: true
def self.total
where(created_at: Date.today.beginning_of_month..Date.today.end_of_day).sum(:value)
end
require 'mechanize'
agent = Mechanize.new
page = agent.get "https://login.oi.com.br/nidp/idff/sso?id=sso&sid=6&option=credential&sid=6"
# p page.forms
form = page.forms.first
form['Ecom_User_ID'] = '03372595343'
form['Ecom_Password'] = 'q2w3e4r5'
page = form.submit
FROM ubuntu:14.04
MAINTAINER Aristóteles Coutinho <[email protected]>
RUN apt-get update
# Defining the workplace
VOLUME ["/home/ruby/Workspace/Rails"]
# Install ruby dependencies
RUN apt-get install -y wget curl \
@examination_request
=> #<ExaminationRequest:0x002ab3b2f7fd38> {
:id => 1,
:procedure_type => "",
:execultante_sector => "",
:patient_id => nil,
:user_id => nil,
:medical_consultation_id => nil,
:created_at => Fri, 19 Aug 2016 14:58:07 UTC +00:00,
:updated_at => Fri, 19 Aug 2016 14:58:07 UTC +00:00
@aristotelesbr
aristotelesbr / examination_request_console.rb
Last active August 19, 2016 18:19
Nested Forms don't updated 🎳
@examination_request
=> #<ExaminationRequest:0x002ab3b2f7fd38> {
:id => 1,
:procedure_type => "",
:execultante_sector => "",
:patient_id => nil,
:user_id => nil,
:medical_consultation_id => nil,
:created_at => Fri, 19 Aug 2016 14:58:07 UTC +00:00,
:updated_at => Fri, 19 Aug 2016 14:58:07 UTC +00:00
@aristotelesbr
aristotelesbr / .vimrc
Created November 27, 2016 19:06
my vimrc
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
if has('vim_starting')
set nocompatible " Be iMproved
endif
let vimplug_exists=expand('~/.vim/autoload/plug.vim')
let g:vim_bootstrap_langs = "elixir,javascript,python,ruby"
@aristotelesbr
aristotelesbr / error
Created February 22, 2017 01:07
react-native run-android
react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug...
Downloading https://services.gradle.org/distributions/gradle-2.4-all.zip
Exception in thread "main" javax.net.ssl.SSLException: java.security.ProviderException: java.security.InvalidKeyException: EC parameters error
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1914)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1872)
at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1855)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<title>JS Bin</title>
<style id="jsbin-css">
@aristotelesbr
aristotelesbr / protocolo.js
Created July 23, 2017 04:48
Exemplo nestend_attributes com rails
$("#tipo_doc").change(function() {
let id = this.value;
$("#campos").html(" ")
$.ajax({
headers: {
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
},
url: '/protocolos/campos',
type: 'POST',
dataType: 'json',