puts 'hello world'
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
| #ruby 2.3.1 recomended | |
| class Graph | |
| attr_reader :graph, :nodes, :previous, :distance #getter methods | |
| INFINITY = 1 << 64 | |
| def initialize | |
| @graph = {} # the graph // {node => { edge1 => weight, edge2 => weight}, node2 => ... | |
| @nodes = Array.new | |
| 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
| // ==UserScript== | |
| // @name Aliexpress_Billy_edit | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description try to take over the world! | |
| // @author You | |
| // @match https://trade.aliexpress.com/orderList.htm* | |
| // @grant unsafeWindow | |
| // @grant GM_xmlhttpRequest | |
| // @grant GM_setClipboard |
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
| with table_stats as ( | |
| select psut.relname, | |
| psut.n_live_tup, | |
| 1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio | |
| from pg_stat_user_tables psut | |
| order by psut.n_live_tup desc | |
| ), | |
| table_io as ( | |
| select psiut.relname, | |
| sum(psiut.heap_blks_read) as table_page_read, |
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
| #---------------------------------------------------------------- | |
| # Example: | |
| # start_spocket_apps | |
| #---------------------------------------------------------------- | |
| function source_zshrc() { | |
| # Edit these if you have different dir or editor | |
| export CODE_DIR='~/Code' | |
| export ED='code' | |
| source ~/.zshrc; echo "sourced ~/.zshrc"; |
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
| #!/usr/bin/env ruby | |
| require 'english' | |
| require 'rubocop' | |
| ADDED_OR_MODIFIED = /A|AM|^M/.freeze | |
| changed_files = `git status --porcelain`.split(/\n/). | |
| select { |file_name_with_status| | |
| file_name_with_status =~ ADDED_OR_MODIFIED |
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
| #!/usr/bin/env ruby | |
| # diff-filter=AM = only show added and modified, not removed | |
| changed_files = `git diff-tree --no-commit-id --name-only --diff-filter=AM -r HEAD`.lines.map(&:chomp) | |
| unless changed_files.empty? # E.g. an "--allow-empty" commit. | |
| bg_process = fork do | |
| # This will report offenses in the entirety of the updated files, not just the changed lines. Not sure if we could easily get Rubocop to check changed-lines only, but this may be good enough. | |
| rubocop_results = `bundle exec rubocop --color #{changed_files.join(" ")}` |
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
| # One of the steps, insert where you wish: | |
| - run: | |
| name: run rubocop | |
| command: | | |
| source /home/circleci/.rvm/scripts/rvm | |
| rvm --default use 2.3.1 | |
| bash bin/rubocop.sh | |
| # Remove the RVM lines if not needed for your setup |
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
| Rails Production and Security checklists/resources: | |
| ---------------------------------------------------- | |
| https://github.com/ankane/production_rails | |
| https://github.com/ankane/production_rails/blob/master/Scaling.md | |
| https://github.com/ankane/production_rails/blob/master/Development.md | |
| http://www.akitaonrails.com/2016/03/22/is-your-rails-app-ready-for-production | |
| https://thoughtbot.com/playbook/production/production-checklist | |
| https://dzone.com/articles/your-preproduction-checklist-for-your-rails-app | |
| https://blog.codeship.com/preproduction-checklist-for-a-rails-app/ |
#SOLID Principles with ruby examples
##SRP - Single responsibility principle A class should have only a single responsibility.
Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.
##OCP - Open/closed principle Software entities should be open for extension, but closed for modification.
NewerOlder