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
| # Obs: Work only in Firefox 66.x or prior, because the function "driver.switch_to.alert.send_keys" not work in new versions. | |
| # tested in selenium-webdriver (3.142.7), webdrivers (4.6.0) and firefox (66.0.5) | |
| # Download firefox to folder | |
| # config/initializers/selenium.rb | |
| Selenium::WebDriver::Firefox::Binary.path = 'path/to/firefox/66.x' | |
| # ----------------------------------------------------------------------------------------------------- | |
| # Code |
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
| def ip_valid?(ip_str) | |
| begin | |
| ip = IPAddr.new(ip_str).to_i | |
| rescue | |
| return false | |
| end | |
| blacklist_ranges = [ | |
| ['0.0.0.0', '0.255.255.255'], | |
| ['10.0.0.0', '10.255.255.255'], |
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
| Mongo::Logger.logger.level = Logger::FATAL | |
| mongo_client = Mongo::Client.new(['127.0.0.1']) | |
| ignore_dbs = [ | |
| 'admin', | |
| 'config', | |
| ].freeze | |
| dbs_data = mongo_client.list_mongo_databases.reject { |db| ignore_dbs.include?(db.name) }.map do |mongo_database| | |
| puts mongo_database.name |
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
| > user = User.new | |
| > user.username | |
| => nil | |
| > user.username = 'kira' | |
| => "kira" | |
| > user.username = 'kira' | |
| => "kira" | |
| > user.username = 'Light' | |
| Mongoid::Errors::Validations: | |
| message: |
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 InsertManyWithValidations | |
| user = User.first | |
| games = [ | |
| { game_id: '1', name: 'Halo' }, | |
| { game_id: '2', name: 'GoW' }, | |
| { game_id: '2', name: 'KF' }, | |
| ] | |
| games = games.map do |game| |
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
| process.env.NODE_ENV = process.env.NODE_ENV || 'development' | |
| require('dotenv-flow').config() | |
| const url = process.env.MONGO_URL || 'mongodb://localhost:27017/DATABASE_NAME' | |
| const MongoClient = require('mongodb').MongoClient | |
| const index = (key, options = null) => ({ key: key, options: options }) | |
| const indexesCollections = [ | |
| { |
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
| import JSZip from 'jszip'; | |
| import JSZipUtils from 'jszip-utils'; | |
| import saveAs from 'file-saver'; | |
| function urlToPromise(url) { | |
| return new Promise(function(resolve, reject) { | |
| JSZipUtils.getBinaryContent(url, function (err, data) { | |
| if(err) { | |
| reject(err); | |
| } else { |
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
| en: | |
| errors: &errors | |
| messages: | |
| bad_uri: is an invalid url | |
| bad_protocol: must start with %{protocols} | |
| activemodel: | |
| errors: | |
| <<: *errors | |
| activerecord: | |
| errors: |