Skip to content

Instantly share code, notes, and snippets.

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

M. Bellucci delbetu

🏠
Working from home
View GitHub Profile
@delbetu
delbetu / uncle_bob_clean_code_intro.md
Last active February 7, 2022 00:24
Uncle bob does clean code matter ?

#Why messy code kill companies ?

##Example story At the start of a project when everything is clean you are going fast!

People ask for new things you could get that done in a matter of hours or days.

A year later things had to slow

The harder and harder you work the slower and slower things seems to go, why ??

@delbetu
delbetu / angular_factory.md
Created December 13, 2016 15:12
Angular Factory Test Example

##Example Service

  angular.module('sportAdmin')
    .factory('Tournament', function($resource, $q) {

      var baseUrl = '/api/tournaments/:tournamentId'

      var service = $resource(baseUrl, {tournamentId: '@id'})
@delbetu
delbetu / angular_controller.md
Last active December 13, 2016 15:35
Angular Controller Test Example

Example Controller

    angular.module('sportAdmin')
      .controller('TournamentListController', function ($scope, Tournament, Sports, Alerts) {

        this.getTournaments = function(){
          this.tournaments = Tournament.all()
          this.sports = Sports.all()
          this.organization = $scope.organization
        }
@delbetu
delbetu / xss-injection.md
Created December 14, 2016 17:51
Cros Site Scripting

Cross-Site Scripting (XSS)

User injects client side executable code. User can add js-malicious code within user input boxes, parameters or cookies

HTML/JS injection

this
<script>alert('Hello');</script>
is the same as this
@delbetu
delbetu / 01paradigms.rb
Last active October 11, 2022 08:02
Notes from - Gary Bernhardt boundaries talk.
# Procedural (Mutation and data separated from code)
# OO (Mutation and data combined with code)
# Functional Version (Imutability and data separated from code)
# FauxO Version (Immutability and data combined with code)
#Procedural-we have knowledge of the internals
def feeding_time
walruses.each do |walrus|
walrus.stomach << Cheese.new
end

Comments

every time you write a comment you failed. commented out code is an abomination that must be destroy before it spreads.

Formatting

white space discipline is important Be consistent horizontal scrolls will not be tolerated(between 40 and 120 columns) keep file sizes under control average between 100 lines and never exceed 500

context 'Test all instance methods' do
let(:test_user) { create(:th_user) }
let(:superbadge) do
create(
:th_superbadge,
api_name: 'test_super_badge',
first_ascent_points: 1000,
completion_points: 1000
)
@delbetu
delbetu / uniqueness_validator_spec.rb
Created November 6, 2017 18:55
Ruby Rspec - Class example
class UniquenessValidator
def initialize(sources: [])
@sources = sources
end
def run
# 'admin_intro_crm_basics', 'lex_migration_introduction', 'admin_intro_crm_basics'
top_level_ids = sources.map(&:find_all_top_level_ids).flatten
calculate_repeated!(top_level_ids)
self
@delbetu
delbetu / initial_solution_controller.rb
Created February 15, 2019 18:49
These gists show a refactor which objective is isolate code that is part of a controller.
class IsolatedCode
def initialize(release_being_sent = { state: 'published' },
release)
@release_being_sent = release_being_sent
@release = release
end
def foo
ActiveRecord::Base.transaction do
if publishing?
class BarService
def foo(input_data)
...
if input_data.page
num = 45
output_data.notified_at_offset = notification_data_access.notified_at(input_data.page)
else
num = 10
end
output_data.notifications =