Used nodes:
Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux
Linux localhost.localdomain 4.14.5-200.fc26.x86_64 #1 SMP Mon Dec 11 16:29:08 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
require 'openssl' | |
class String | |
def encrypt(key) | |
cipher = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC').encrypt | |
cipher.key = Digest::SHA1.hexdigest key | |
s = cipher.update(self) + cipher.final | |
s.unpack('H*')[0].upcase | |
end |
# MODEL | |
class Case < ActiveRecord::Base | |
include Eventable | |
has_many :tasks | |
concerning :Assignment do | |
def assign_to(new_owner:, details:) | |
transaction do |
# Sum feature's price and convert to cents | |
amount = self.features.inject(0) { |sum, feature| sum + feature.price} | |
amount_in_cents = (amount * 100).to_i | |
# Create needed Paymill object (client / payment / offer / subscription) | |
client = Paymill::Client.create email: email, description: name | |
payment = Paymill::Payment.create token: paymill_card_token, client: client.id | |
offer = Paymill::Offer.create amount: amount_in_cents, currency: "EUR", interval: "1 MONTH", name: "Subscription for #{name}" | |
subscription = Paymill::Subscription.create offer: offer.id, client: client.id, payment: payment.id |
# config/unicorn.rb | |
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) | |
timeout 30 | |
preload_app true | |
before_fork do |server, worker| | |
Signal.trap 'TERM' do | |
puts 'Unicorn master intercepting TERM and sending myself QUIT instead' | |
Process.kill 'QUIT', Process.pid |
def recalc | |
['right', 'left'].each do |side| | |
if send("#{side}_eye_cylinder").to_f < 0 | |
send("#{side}_eye_sphere=", send("#{side}_eye_sphere").to_f + send("#{side}_eye_cylinder").to_f ) | |
send("#{side}_eye_cylinder=", send("#{side}_eye_cylinder").to_f.abs ) | |
if send("#{side}_eye_axe").to_i < 90 | |
send("#{side}_eye_axe=", send("#{side}_eye_axe").to_i + 90) | |
else | |
send("#{side}_eye_axe=", send("#{side}_eye_axe").to_i - 90) | |
end |
# --------------------------------------------------------- | |
# Display the name of the home directory | |
# --------------------------------------------------------- | |
windowTitle = "$TM_DISPLAYNAME - ${CWD/^.*\///}" | |
# --------------------------------------------------------- | |
# Configure Git | |
# --------------------------------------------------------- | |
TM_GIT = "/usr/local/git/bin/git" |