Skip to content

Instantly share code, notes, and snippets.

@stp-che
stp-che / backup.sh
Last active October 2, 2015 19:58
Simple backup automation
#!/bin/sh
d=`date +%Y%m%d`
path=/home/keeper/backup
pg_dump -U postgres -d my_database -n my_schema -f $path"dump"$d -O
zip -jq $path"dump"$d".zip" $path"dump"$d
require 'active_support/all'
class A < HashWithIndifferentAccess
end
class B < HashWithIndifferentAccess
def initialize(*args)
super
freeze
end

Геометрия

1. Гем

Создать гем, позволяющий вычислять пересечение геометрических объектов на плоскости.

Все объекты задаются в декартовой системе координат.

Должны поддерживаться cледующие виды объектов:

@stp-che
stp-che / SlickTraits.scala
Created January 18, 2017 07:25 — forked from dragisak/SlickTraits.scala
Composing Slick tables as traits in Play!
import javax.inject.{Inject, Singleton}
import play.api.db.slick.DatabaseConfigProvider
import slick.backend.DatabaseConfig
import slick.driver.JdbcProfile
import scala.concurrent.Future
/*
* The problem we are trying to solve here is how to have one trait per Slick table definition.
@stp-che
stp-che / Dockerfile
Created October 3, 2018 11:12 — forked from RoyalIcing/Dockerfile
Rails 5.1 Dockerfile
FROM ruby:2.4-alpine
ENV PATH /root/.yarn/bin:$PATH
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh build-base nodejs tzdata
RUN apk update \
&& apk add curl bash binutils tar gnupg \
&& rm -rf /var/cache/apk/* \
require 'json'
require 'net/http'
HOST = '192.168.242.150'
USER = 'Администратор'
PASSWORD = ''
DB = 'DemoHRM1'
# Идентификаторы
# ПАО "Винтерфелл" - a878eda5-9484-11e8-a45d-e269cdf4837d
require 'json'
require 'net/http'
HOST = '192.168.242.150'
USER = 'Администратор'
PASSWORD = ''
DB = 'DemoHRM1'
def json_date(d)
d.strftime '%Y-%m-%dT00:00:00'
class CreateBook
def initialize(title, author_guid)
@title, @author_guid = title, author_guid
end
def perform
unless author
log "Could not find author"
else
book.save!
@stp-che
stp-che / save_scoping_spec.rb
Last active October 8, 2019 09:13
Role scopes manipulation testing strategy
describe SaveScoping do
let(:role){ create :role }
let(:cities){ (0..2).map{ create :city } }
let(:orgs){ (0..2).map{ create :legl_organization } }
context 'creating initial role scoping' do
it '...' do
expect {
SaveScoping.(role, RoleScope::CITY, [cities[0].id, cities[1].id])
}.to change{ role.reload.divided }.to true
class ExtraChargeGroundsController < WithSessionController
require_global_permission Access::P_EXTRA_CHARGE_MANAGE
end