This file contains 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 StressTestOrders | |
def call(order_number, amount) | |
logger = Logger.new('log/stress_test_orders.log') | |
200.times do | |
order = Spree::Order.find_by_number(order_number) | |
new_order = Spree::Cart::Create.call(user: order.user, store: nil, currency: nil) | |
new_order = new_order.value | |
new_order.email = order.email | |
new_order.ship_address = order.ship_address.dup |
This file contains 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
from torchvision.io import read_image | |
from torchvision.models import resnet50, ResNet50_Weights | |
import torch | |
import glob | |
import pickle | |
from tqdm import tqdm | |
from PIL import Image | |
def pil_loader(path): | |
# ПРЕДВАРИТЕЛЬНАЯ ОБРАБОТКА ИЗОБРАЕНИЙ. Некоторые изображения из датасета представленны не в RGB формате, необходимо их конверитровать в RGB |
This file contains 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
#!/bin/bash | |
# Removes old revisions of snaps | |
# CLOSE ALL SNAPS BEFORE RUNNING THIS | |
set -eu | |
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' | | |
while read snapname revision; do | |
snap remove "$snapname" --revision="$revision" | |
done |
This file contains 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
########################################################### | |
#################### Rubocop Rspec ######################## | |
########################################################### | |
# You can find all configuration options for rubocop-rspec here: https://docs.rubocop.org/rubocop-rspec/cops.html | |
RSpec/AnyInstance: | |
Enabled: false | |
RSpec/BeforeAfterAll: |
This file contains 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
########################################################### | |
#################### Rubocop Rails ######################## | |
########################################################### | |
# You can find all configuration options for rubocop-rails here: https://docs.rubocop.org/rubocop-rails/cops_rails.html | |
Rails/ActiveRecordCallbacksOrder: | |
Enabled: true | |
Rails/AfterCommitOverride: |
This file contains 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
#~/.config/systemd/user/puma.service | |
#systemctl --user status|start|stop puma | |
[Unit] | |
Description=Puma HTTP Server | |
After=network.target | |
[Service] | |
Type=simple | |
WorkingDirectory=/home/www/PROJET_NAME/current | |
Environment=RAILS_ENV=production | |
ExecStart=/home/${USER}/.rbenv/bin/rbenv exec bundle exec puma |
This file contains 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 pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn.decomposition import NMF | |
from sklearn.decomposition import PCA | |
from sklearn.decomposition import TruncatedSVD as SVD | |
from sklearn.metrics import mean_absolute_error as mae | |
from sklearn.metrics import explained_variance_score as evs | |
from sklearn.metrics import mean_squared_error as mse |
This file contains 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
# negative numbers are also taken into code | |
def max_multiplication(str) | |
return nil if !str.is_a?(String) | |
multipliers = CircularBuffer.new(4) | |
negative_factor = 1 | |
max_multiplication = nil | |
str.each_char do |char| | |
if char == '-' && negative_factor == 1 |
This file contains 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
# inherit_from: | |
# - ".rubocop-rspec.yml" | |
# - ".rubocop-rails.yml" | |
# require: | |
# - rubocop-rails | |
# - rubocop-rspec | |
AllCops: | |
TargetRubyVersion: 3 |
This file contains 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
YourModel.find_each do |ym| | |
begin | |
ym.process_your_uploader_upload = true # only if you use carrierwave_backgrounder | |
ym.your_uploader.cache_stored_file! | |
ym.your_uploader.retrieve_from_cache!(ym.your_uploader.cache_name) | |
ym.your_uploader.recreate_versions!(:version1, :version2) | |
ym.save! | |
rescue => e | |
puts "ERROR: YourModel: #{ym.id} -> #{e.to_s}" | |
end |
NewerOlder