This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Colors | |
| NO_COLOR="\[\e[0m\]" | |
| BLACK="\[\033[0;30m\]" | |
| RED="\[\033[0;31m\]" | |
| GREEN="\[\033[0;32m\]" | |
| YELLOW="\[\033[0;33m\]" | |
| BLUE="\[\033[0;34m\]" | |
| MAGENTA="\[\033[0;35m\]" | |
| CYAN="\[\033[0;36m\]" | |
| WHITE="\[\033[0;37m\]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| +----------------------+-------+-------+---------+---------+-----+-------+ | |
| | Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | |
| +----------------------+-------+-------+---------+---------+-----+-------+ | |
| | Controllers | 233 | 203 | 3 | 19 | 6 | 8 | | |
| | Helpers | 4 | 4 | 0 | 0 | 0 | 0 | | |
| | Models | 93 | 71 | 6 | 8 | 1 | 6 | | |
| | Libraries | 651 | 554 | 24 | 79 | 3 | 5 | | |
| | Integration tests | 0 | 0 | 0 | 0 | 0 | 0 | | |
| | Functional tests | 7 | 3 | 1 | 0 | 0 | 0 | | |
| | Unit tests | 99 | 66 | 7 | 0 | 0 | 0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| allowed_dirs = Dir["/Users/homedir/Pictures/*"].select { |dir| dir if dir.match(/(au)/) } | |
| allowed_dirs.each do |current_directory| | |
| allowed_dirs.each do |another_directory| | |
| next if current_directory == another_directory | |
| Dir["#{current_directory}/*"].each do |current_photo| | |
| Dir["#{another_directory}/*"].each do |another_photo| | |
| puts ">> Current: #{current_photo} == Another: #{another_photo}" if current_photo == another_photo | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #start a rails app without activerecord | |
| rails new app_name --skip-active-record | |
| # Start rspec configuration | |
| rails g rspec:install | |
| # Generate mongo configuration | |
| rails g mongoid:config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ToolParser | |
| def to_json | |
| self.to_json | |
| end | |
| def to_hash # or attributes | |
| self.to_hash | |
| end | |
| def execute(xml) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ToolParserWorker | |
| include Sidekiq::Worker | |
| def perform(scan) | |
| ## On a near futute NessusParser will die an become a ParserFactory based on scan tool type | |
| report = NessusParser.execute(self.file.current_path) # execute returns a Report object | |
| scan.update_parsed_report(report.to_json) # scan is mongo document | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| desc 'Run factory specs.' | |
| RSpec::Core::RakeTask.new(:factory_specs) do |t| | |
| t.pattern = './spec/factories_spec.rb' | |
| end | |
| task spec: :factory_specs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## | |
| # Raises error if missing translation key | |
| ## | |
| config.before(:all, type: :controller) do | |
| @_i18n_exception_handler = I18n.exception_handler | |
| I18n.exception_handler = lambda { |*args| raise args.first.to_s } | |
| end | |
| config.after(:all, type: :controller) do | |
| I18n.exception_handler = @_i18n_exception_handler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Game | |
| #... | |
| def print_average_game_rating | |
| if ratings_count == 0 | |
| "Nota média:" | |
| else | |
| "Nota média: #{average_game_rating}" | |
| end | |
| end | |
| end |