Skip to content

Instantly share code, notes, and snippets.

View valterbarros's full-sized avatar
馃憡
Code makes me happy

Valter Barros valterbarros

馃憡
Code makes me happy
View GitHub Profile
class Days
attr_reader :day, :fck_tests
def initialize(day, fck_tests = [])
@day = day
@fck_tests = fck_tests
end
end
class DaysBuilder
def calculate_scheduled_for_the_month
sum = 0.0
return sum if @planning.empty?
where_for_planning = clause_where_for_planning
i = 0
@planning.where(where_for_planning).each do |p|
p.preenchimentos.each_with_index do |obj, index|
obj.dth_inicio = Time.now - index.days
obj.dth_fim = Time.now + index.days
class ApplicationController; end
module Planning; end
class PlanningContoller < ApplicationController
def index
Planning::Index.new(planning_params).run do |parameters|
create_planning(parameters)
render :index, status: 200
end
end
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'normalize.css/normalize.css'
import Vue from 'vue'
import App from './App'
import './assets/basic_styles.css'
import lang from 'element-ui/lib/locale/lang/en'
import locale from 'element-ui/lib/locale'
import { Checkbox, Collapse, CollapseItem, Button, Input, Form, FormItem, Slider, Select, Option } from 'element-ui'
import router from './router'
@valterbarros
valterbarros / Observer object
Created August 23, 2018 14:07
A feature that know lives only in my mind not in my company production
function update_total(data) {
data.total = data.value * data.quantity
}
var registryProxy
// Go through each of our data properties
registry_observer = function(data) {
track_keys = ['value', 'quantity']
track_keys.forEach(function(key) {
require 'pp'
$group_management = []
class CalculateValue
attr_reader :totalValueOfFriendship
def initialize(friendshipsLookupTable)
@friendshipsLookupTable = friendshipsLookupTable
@additionalLinks = 0
window.onscroll = function(ev) {
if ((document.defaultView.innerHeight + document.defaultView.scrollY) == document.body.scrollHeight) {
$('.item.number.active').next('.item').find('a').get(0).click()
}
};
// HTML
<div class="inspection-imagecontainer">
<img src="http://oneimage.com"/>
</div>
// CSS
.inspection-imagecontainer{
display: inline-block;
width: 33%;
validateRules: {
number: {
presence: true,
message: 'O n煤mero do processo 茅 obrigat贸rio'
},
processTypeId: {
presence: true,
message: '脡 obrigat贸rio preencher uma das op莽玫es'
},
debt: {
# https://stackoverflow.com/questions/28670159/rspec-factory-girl-without-rails
# https://stackoverflow.com/questions/3661546/how-to-require-active-record-working-outside-of-rails
# https://stackoverflow.com/questions/1755665/get-names-of-all-files-from-a-folder-with-ruby
require 'active_record'
require 'pg'
ActiveRecord::Base.establish_connection(
adapter: 'postgresql',
database: 'stant_test',
username: 'stant',